This commit is contained in:
moyin
2025-12-18 14:12:45 +08:00
4 changed files with 24 additions and 20 deletions

View File

@@ -40,9 +40,8 @@ sudo mkdir -p /var/www
cd /var/www cd /var/www
# 克隆项目(替换为你的实际仓库地址) # 克隆项目(替换为你的实际仓库地址)
sudo git clone https://your-gitea-server.com/username/pixel-game-server.git git clone https://gitea.xinghangee.icu/datawhale/whale-town-end.git
sudo chown -R $USER:$USER pixel-game-server cd whale-town-end
cd pixel-game-server
``` ```
### 3. 配置环境 ### 3. 配置环境
@@ -111,7 +110,7 @@ pm2 startup
创建 Nginx 配置文件: 创建 Nginx 配置文件:
```bash ```bash
sudo nano /etc/nginx/sites-available/pixel-game-server sudo nano /etc/nginx/sites-available/whale-town-end
``` ```
添加以下内容: 添加以下内容:
@@ -147,7 +146,7 @@ server {
启用站点: 启用站点:
```bash ```bash
sudo ln -s /etc/nginx/sites-available/pixel-game-server /etc/nginx/sites-enabled/ sudo ln -s /etc/nginx/sites-available/whale-town-end /etc/nginx/sites-enabled/
sudo nginx -t sudo nginx -t
sudo systemctl reload nginx sudo systemctl reload nginx
``` ```
@@ -171,7 +170,7 @@ sudo systemctl reload nginx
pm2 status pm2 status
# 查看日志 # 查看日志
pm2 logs pixel-game-server pm2 logs whale-town-end
pm2 logs webhook-handler pm2 logs webhook-handler
# 测试 API # 测试 API
@@ -183,10 +182,10 @@ curl http://localhost:3000/api-docs
```bash ```bash
# 重启服务 # 重启服务
pm2 restart pixel-game-server pm2 restart whale-town-end
# 查看日志 # 查看日志
pm2 logs pixel-game-server --lines 100 pm2 logs whale-town-end --lines 100
# 手动部署 # 手动部署
bash deploy.sh bash deploy.sh
@@ -195,7 +194,7 @@ bash deploy.sh
git pull origin main git pull origin main
pnpm install pnpm install
pnpm run build pnpm run build
pm2 reload pixel-game-server pm2 reload whale-town-end
``` ```
## 故障排除 ## 故障排除

View File

@@ -1,17 +1,22 @@
# 使用官方 Node.js 镜像 # 使用官方 Node.js 镜像
FROM node:18-alpine FROM node:lts-alpine
# 设置工作目录 # 设置工作目录
WORKDIR /app WORKDIR /app
# 安装 pnpm # 设置构建参数
RUN npm install -g pnpm ARG NPM_REGISTRY=https://registry.npmmirror.com
# 复制 package.json 和 pnpm-lock.yaml # 设置 npm 和 pnpm 镜像源
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./ RUN npm config set registry ${NPM_REGISTRY} && \
npm install -g pnpm && \
pnpm config set registry ${NPM_REGISTRY}
# 复制 package.json
COPY package.json pnpm-workspace.yaml ./
# 安装依赖 # 安装依赖
RUN pnpm install --frozen-lockfile RUN pnpm install
# 复制源代码 # 复制源代码
COPY . . COPY . .

View File

@@ -72,7 +72,7 @@ describe('EmailService', () => {
configService.get.mockReturnValue(undefined); configService.get.mockReturnValue(undefined);
// 重新创建服务实例来测试测试模式 // 重新创建服务实例来测试测试模式
const testService = new EmailService(configService); new EmailService(configService);
expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({ expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({
streamTransport: true, streamTransport: true,
@@ -89,7 +89,7 @@ describe('EmailService', () => {
.mockReturnValueOnce('test@gmail.com') // EMAIL_USER .mockReturnValueOnce('test@gmail.com') // EMAIL_USER
.mockReturnValueOnce('password'); // EMAIL_PASS .mockReturnValueOnce('password'); // EMAIL_PASS
const testService = new EmailService(configService); new EmailService(configService);
expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({ expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({
host: 'smtp.gmail.com', host: 'smtp.gmail.com',
@@ -403,7 +403,7 @@ describe('EmailService', () => {
.mockReturnValueOnce(undefined) // EMAIL_USER .mockReturnValueOnce(undefined) // EMAIL_USER
.mockReturnValueOnce(undefined); // EMAIL_PASS .mockReturnValueOnce(undefined); // EMAIL_PASS
const testService = new EmailService(configService); new EmailService(configService);
expect(configService.get).toHaveBeenCalledWith('EMAIL_HOST', 'smtp.gmail.com'); expect(configService.get).toHaveBeenCalledWith('EMAIL_HOST', 'smtp.gmail.com');
expect(configService.get).toHaveBeenCalledWith('EMAIL_PORT', 587); expect(configService.get).toHaveBeenCalledWith('EMAIL_PORT', 587);
@@ -418,7 +418,7 @@ describe('EmailService', () => {
.mockReturnValueOnce('custom@163.com') // EMAIL_USER .mockReturnValueOnce('custom@163.com') // EMAIL_USER
.mockReturnValueOnce('custompass'); // EMAIL_PASS .mockReturnValueOnce('custompass'); // EMAIL_PASS
const testService = new EmailService(configService); new EmailService(configService);
expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({ expect(mockedNodemailer.createTransport).toHaveBeenCalledWith({
host: 'smtp.163.com', host: 'smtp.163.com',

View File

@@ -377,7 +377,7 @@ describe('VerificationService', () => {
it('应该返回存在的验证码统计信息', async () => { it('应该返回存在的验证码统计信息', async () => {
const codeInfo = { const codeInfo = {
code: '123456', code: '123456',
createdAt: Date.now(), createdAt: 1766035834340,
attempts: 1, attempts: 1,
maxAttempts: 3, maxAttempts: 3,
}; };