fix: typo in reference to account
Massimo Melina committed
Jan 23, 2022 at 16:36 UTC
5f929768998af5e603d9f837d3caed8e07ce89d8
3 files changed
+14
-15
README.md
+1
-1
@@ -84,7 +84,7 @@ Supported entries are:
84
## Virtual File System (VFS)
85
86
The virtual file system is a tree of files and folders, collectively called *nodes*.
87
-By default a node is folder, unless you provide for it a source that's a file.
87
+By default, a node is a folder, unless you provide for it a source that's a file.
88
Valid keys in a node are:
89
- `name`: how to display it. If not provided HFS will infer it from the source.
90
- `source`: absolute or relative path of where to get the content
config.yaml
+1
-1
@@ -30,6 +30,6 @@ vfs:
30
source: tests/page
31
- name: for-admins
32
perm:
33
- admin: r
33
+ admins: r
34
children:
35
- source: tests/alfa.txt
src/apis.ts
+12
-13
@@ -11,7 +11,7 @@ export type ApiHandler = (params:any, ctx:Koa.Context) => ApiHandlerResult | Pro
11
export type ApiHandlers = Record<string, ApiHandler>
12
13
export function apiMiddleware(apis: ApiHandlers) : Koa.Middleware {
14
- return async (ctx, next) => {
14
+ return async (ctx) => {
15
const params = ctx.method === 'POST' ? await getJsonFromReq(ctx.req) : ctx.request.query
16
console.debug('API', ctx.method, ctx.path, { ...params })
17
if (!apis.hasOwnProperty(ctx.path)) {
@@ -29,18 +29,17 @@ export function apiMiddleware(apis: ApiHandlers) : Koa.Middleware {
29
catch(e) {
30
ctx.throw(500, String(e))
31
}
32
- if (res)
33
- if (res instanceof ApiError) {
34
- ctx.body = res.message
35
- ctx.status = res.status
36
- }
37
- else if (res instanceof Error) {
38
- ctx.body = String(res)
39
- ctx.status = 400
40
- }
41
- else
42
- ctx.body = res
43
- await next()
32
+ if (!res) // this should happen only in case of SSE
33
+ return
34
+ if (res instanceof ApiError) {
35
+ ctx.body = res.message
36
+ return ctx.status = res.status
37
+ }
38
+ if (res instanceof Error) {
39
+ ctx.body = String(res)
40
+ return ctx.status = 400
41
+ }
42
+ ctx.body = res
43
}
44
}
45