book.middleware.ts 466 B

12345678910111213141516171819
  1. import { IMiddleware } from '@midwayjs/core';
  2. import { Middleware } from '@midwayjs/core';
  3. import { NextFunction, Context } from '@midwayjs/koa';
  4. @Middleware()
  5. export default class BookMiddleware
  6. implements IMiddleware<Context, NextFunction>
  7. {
  8. resolve() {
  9. return async (ctx: Context, next: NextFunction) => {
  10. console.log('in book middleware');
  11. await next();
  12. return 'ok';
  13. };
  14. }
  15. static getName() {
  16. return 'book_middleware';
  17. }
  18. }