Skip to content
Myr

fix: basic auth (#83)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Installing `buffer` and `crypto` packages enables basic auth, if `buffer` of `crypto` is not in pollyfills such as webpack 5 environment. Close #82

authored by Yusuke Wada · committed by GitHub · parent 5587878 · Browse files · 4 files+30 added−16 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+30 added−16 removed

  • other:+30 added−16 removed

4 files+30 added−16 removed

modified:src/middleware/basic-auth/basic-auth.ts+21 added-12 removed
modified:src/middleware/mustache/mustache.ts+1 added-1 removed
modified:src/middleware/mustache/README.md+3 added-2 removed
modified:src/compose.ts+5 added-1 removed
1// Based on the code in the MIT licensed `koa-compose` package.2export const compose = (middleware: any) => {3 const errors: Error[] = []4 return function (context: any, next?: Function) {5 let index = -16 return dispatch(0)7 function dispatch(i: number): any {
2 unmodified lines
10 let fn = middleware[i]11 if (i === middleware.length) fn = next12 if (!fn) return Promise.resolve()13 try {13 return Promise.resolve(fn(context, dispatch.bind(null, i + 1)))14 return Promise.resolve(fn(context, dispatch.bind(null, i + 1))).catch((e) => {15 errors.push(e)16 throw errors[0] // XXX17 })18 } catch (err) {19 return Promise.reject(err)20 }21 }
2 unmodified lines