Cleanup, functional

This commit is contained in:
Zef Hemel
2022-02-21 13:25:41 +01:00
parent cbe0677f93
commit c9f4266d34
21 changed files with 237 additions and 451 deletions
+14 -4
View File
@@ -27,14 +27,24 @@ fsRouter.get('/', async context => {
fsRouter.get('/:note', async context => {
const noteName = context.params.note;
const localPath = `${notesPath}/${noteName}.md`;
const text = await Deno.readTextFile(localPath);
context.response.body = text;
try {
const text = await Deno.readTextFile(localPath);
context.response.body = text;
} catch (e) {
context.response.status = 404;
context.response.body = "";
}
});
fsRouter.options('/:note', async context => {
const localPath = `${notesPath}/${context.params.note}.md`;
const stat = await Deno.stat(localPath);
context.response.headers.set('Content-length', `${stat.size}`);
try {
const stat = await Deno.stat(localPath);
context.response.headers.set('Content-length', `${stat.size}`);
} catch (e) {
context.response.status = 200;
context.response.body = "";
}
})
fsRouter.put('/:note', async context => {