request.query is ugly when printed because of prototype, so we make a shallow-copy
Massimo Melina committed
Dec 23, 2021 at 16:56 UTC
546c87eb475aca7a6f3c077c6ffa84adb5caf473
1 file changed
+3
-1
src/apis.ts
+3
-1
@@ -16,7 +16,7 @@ type ApiHandlers = Record<string, ApiHandler>
16
export function apiMw(apis: ApiHandlers) : Koa.Middleware {
17
return async (ctx, next) => {
18
const params = ctx.method === 'POST' ? ctx.request.body : ctx.request.query
19
- console.debug('API', ctx.method, ctx.path, params)
19
+ console.debug('API', ctx.method, ctx.path, { ...params })
20
if (!(ctx.path in apis))
21
return ctx.throw(404, 'invalid api')
22
const cb = (apis as any)[ctx.path]
@@ -58,6 +58,7 @@ export const frontEndApis: ApiHandlers = {
58
59
async function produceEntries() {
60
const list = []
61
+ const h = sseSrv && setInterval(()=> console.log('WALKING'), 500)
62
for await (const sub of walker) {
63
if (sseSrv?.stopped) break
64
const filename = basename(sub.name||'')
@@ -84,6 +85,7 @@ export const frontEndApis: ApiHandlers = {
85
if (limit && !--limit)
86
break
87
}
88
+ if (h) clearInterval(h)
89
sseSrv?.close()
90
return list
91
}