chore: 更新Dockerfile和TypeScript配置,优化代码结构

- 将基础镜像版本从Node.js 18 Alpine更新至Node.js 22 Alpine
- 修改生产阶段镜像为Node.js 22 Alpine
- 在tsconfig.json中添加对Node.js类型的支持
- 在wechat.adapter.ts中优化crypto模块的导入方式
This commit is contained in:
iHeyTang 2025-09-04 18:16:12 +08:00
parent 21a2865e43
commit 0bc27df560
3 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,5 @@
# 使用官方 Node.js 18 Alpine 镜像作为基础镜像 # 使用官方 Node.js 22 Alpine 镜像作为基础镜像
FROM node:18-alpine AS base FROM node:22-alpine AS base
# 构建参数 # 构建参数
ARG GIT_COMMIT="" ARG GIT_COMMIT=""
@ -30,7 +30,7 @@ COPY . .
RUN npm run build RUN npm run build
# 生产阶段 # 生产阶段
FROM node:18-alpine AS production FROM node:22-alpine AS production
# 设置环境变量 # 设置环境变量
ENV NODE_ENV=production ENV NODE_ENV=production
# 创建非root用户 # 创建非root用户
@ -52,4 +52,4 @@ EXPOSE 3000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:3000/health || exit 1 CMD curl -f http://localhost:3000/health || exit 1
# 启动应用 # 启动应用
CMD ["node", "dist/main"] CMD ["node", "dist/src/main"]

View File

@ -14,6 +14,7 @@ import {
PlatformUserInfo, PlatformUserInfo,
TokenRefreshResult, TokenRefreshResult,
} from '../interfaces/platform.interface'; } from '../interfaces/platform.interface';
import crypto from 'crypto';
interface WechatAuthResponse { interface WechatAuthResponse {
openid: string; openid: string;
@ -227,7 +228,6 @@ export class WechatAdapter extends BaseAdapter {
): WechatUserInfo { ): WechatUserInfo {
// 实现微信用户信息解密逻辑 // 实现微信用户信息解密逻辑
// 使用crypto模块进行AES解密 // 使用crypto模块进行AES解密
const crypto = require('crypto');
const decipher = crypto.createDecipheriv( const decipher = crypto.createDecipheriv(
'aes-128-cbc', 'aes-128-cbc',
Buffer.from(sessionKey, 'base64'), Buffer.from(sessionKey, 'base64'),

View File

@ -20,6 +20,7 @@
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"noImplicitAny": false, "noImplicitAny": false,
"strictBindCallApply": false, "strictBindCallApply": false,
"noFallthroughCasesInSwitch": false "noFallthroughCasesInSwitch": false,
"types": ["node"]
} }
} }