import { Middleware, IMiddleware } from '@midwayjs/core';
import { NextFunction, Context } from '@midwayjs/koa';

const locals = {
  assets: 'public/',
  version: Date.now(),
};

@Middleware()
export class LocalMiddleware implements IMiddleware<Context, NextFunction> {
  resolve() {
    return async (ctx: Context, next: NextFunction) => {
      ctx.locals = locals;
      await next();
    };
  }

  static getName(): string {
    return 'local';
  }
}
