天天看點

修複 egg.js 配置資訊無法聯想的問題

解決方案:将 config\config.default.ts 末尾的

return {
    ...config,
    ...bizConfig,
  };      

修改為

return {
    ...config as {},
    ...bizConfig,
  };      
import { Context, EggAppConfig } from 'egg';
import { appendFileSync } from 'fs';
export default (options:) => {
  return async (ctx: Context, next: () => Promise<any>) => {
    const startTime = Date.now();
    const requestTime = new Date();
    await next();
    const ms = Date.now() - startTime;
    const logTime = `${requestTime} -- ${ctx.method} --${ctx.url} -- ${ms}ms`;
    if (options.recordUrlList.includes(ctx.url)) {
      appendFileSync('./log.txt', logTime + '\n');
    }
  };
};