Skip to content

Commit

Permalink
feat: add init with ctx.jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
npmstudy committed Oct 28, 2023
1 parent 8daa498 commit 0141081
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export async function loadBuildinMiddlewaire(rpc?) {
}

export async function loadMiddleware(rpc, lifeCycle, mw) {
console.dir(lifeCycle);
console.dir(mw);
log(lifeCycle);
log(mw);
rpc.config.hooks[lifeCycle].push(mw);
}
7 changes: 5 additions & 2 deletions packages/app/src/mw/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import koajwt from 'koa-jwt';

export const jwt = {
name: 'jwt',
lifeCycle: 'load',
mw: async (ctx: any, next: any) => {
await next();
mw: (opts) => {
// console.dir(opts);
return koajwt(opts);
},
};
2 changes: 0 additions & 2 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,6 @@ export const createServer = function (config?: any) {
const key = ctx.path.replace('/', '').split('/').join('.');
_cfg.beforeOne(ctx, key);

console.dir(ctx.jwt);

const lastKey = key.split('.').pop();
const httpMethods = getHttpMethods();

Expand Down

0 comments on commit 0141081

Please sign in to comment.