@samitouri / QOSami-HFS / commits / 20572461

fix: console error in case of bad server_code

Massimo Melina committed Sep 19, 2023 at 14:25 UTC 20572461534e0cda69d93619dae2cc2ac5808194
1 file changed +5 -1
src/plugins.ts
+5 -1
@@ -143,7 +143,11 @@ async function initPlugin<T>(pl: any, more?: T) {
143 export const pluginsMiddleware: Koa.Middleware = async (ctx, next) => {
144 const after: Dict<CallMeAfter> = {}
145 // run middleware plugins
146 - for (const [id,pl] of Object.entries(plugins).concat([['.', await serverCode.compiled()]]))
146 + const entries = Object.entries(plugins)
147 + const sc = await serverCode.compiled()
148 + if (sc)
149 + entries.push(['.', await serverCode.compiled()])
150 + for (const [id,pl] of entries)
151 try {
152 const res = await pl.middleware?.(ctx)
153 if (res === true)