feat: 依赖升级

This commit is contained in:
陶林 2024-03-01 09:19:49 +08:00
parent b53ac87c76
commit 10ed284461
8 changed files with 26 additions and 6731 deletions

15
Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM node:lts-alpine
WORKDIR /app
RUN sed -i "s@http://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories
RUN apk add --no-cache tzdata
ENV TZ="Asia/Shanghai"
RUN npm config set registry https://registry.npm.taobao.org
COPY package.json ./package.json
RUN npm install
COPY . .
RUN npm run build
RUN rm -rf node_modules && rm package-lock.json
RUN npm install --production
EXPOSE 3000
CMD ["npm", "run", "start"]

View File

@ -4,20 +4,20 @@
"description": "",
"private": true,
"dependencies": {
"@midwayjs/bootstrap": "^3.12.3",
"@midwayjs/core": "^3.12.3",
"@midwayjs/cross-domain": "^3.12.3",
"@midwayjs/decorator": "^3.12.3",
"@midwayjs/info": "^3.12.3",
"@midwayjs/koa": "^3.12.3",
"@midwayjs/bootstrap": "^3.15.0",
"@midwayjs/core": "^3.15.0",
"@midwayjs/cross-domain": "^3.15.1",
"@midwayjs/decorator": "^3.15.0",
"@midwayjs/info": "^3.15.1",
"@midwayjs/koa": "^3.15.1",
"@midwayjs/logger": "^2.14.0",
"@midwayjs/swagger": "^3.12.4",
"@midwayjs/validate": "^3.12.3",
"@midwayjs/view-ejs": "^3.12.3"
"@midwayjs/swagger": "^3.15.1",
"@midwayjs/validate": "^3.15.1",
"@midwayjs/view-ejs": "^3.15.1"
},
"devDependencies": {
"@midwayjs/cli": "^2.1.1",
"@midwayjs/mock": "^3.12.3",
"@midwayjs/mock": "^3.15.0",
"@types/jest": "^29.2.0",
"@types/koa": "^2.13.4",
"@types/node": "14",

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,6 @@ import * as koa from '@midwayjs/koa';
import * as validate from '@midwayjs/validate';
import * as info from '@midwayjs/info';
import { join } from 'path';
// import { DefaultErrorFilter } from './filter/default.filter';
// import { NotFoundFilter } from './filter/notfound.filter';
import { ReportMiddleware } from './middleware/report.middleware';
import * as swagger from '@midwayjs/swagger';
import * as view from '@midwayjs/view-ejs';
import * as crossDomain from '@midwayjs/cross-domain';
@ -33,6 +30,6 @@ export class MainConfiguration {
app: koa.Application;
async onReady() {
this.app.useMiddleware([ReportMiddleware]);
this.app.useMiddleware([]);
}
}

View File

@ -1,13 +0,0 @@
import { Catch } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
@Catch()
export class DefaultErrorFilter {
async catch(err: Error, ctx: Context) {
// 所有的未分类错误会到这里
return {
success: false,
message: err.message,
};
}
}

View File

@ -1,10 +0,0 @@
import { Catch, httpError, MidwayHttpError } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
@Catch(httpError.NotFoundError)
export class NotFoundFilter {
async catch(err: MidwayHttpError, ctx: Context) {
// 404 错误会到这里
ctx.redirect('/404.html');
}
}

View File

@ -1,7 +0,0 @@
export interface IUserOptions {
uid: number;
}
declare module '@midwayjs/core' {
interface Context {
}
}

View File

@ -1,27 +0,0 @@
import { Middleware, IMiddleware } from '@midwayjs/core';
import { NextFunction, Context } from '@midwayjs/koa';
@Middleware()
export class ReportMiddleware implements IMiddleware<Context, NextFunction> {
resolve() {
return async (ctx: Context, next: NextFunction) => {
// 控制器前执行的逻辑
const startTime = Date.now();
// 执行下一个 Web 中间件,最后执行到控制器
// 这里可以拿到下一个中间件或者控制器的返回值
const result = await next();
// 控制器之后执行的逻辑
ctx.logger.info(
`Report in "src/middleware/report.middleware.ts", rt = ${
Date.now() - startTime
}ms`
);
// 返回给上一个中间件的结果
return result;
};
}
static getName(): string {
return 'report';
}
}