From c32bbd91243c207cd87aeb0204568c7d34143cb2 Mon Sep 17 00:00:00 2001 From: sudoooooo Date: Wed, 17 Jan 2024 15:16:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=92=8Clint=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 6 +++++- server/.env.example | 16 ---------------- server/package.json | 1 - server/src/config/index.ts | 10 +++++----- server/src/index.ts | 1 - 5 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 server/.env.example diff --git a/docker-compose.yaml b/docker-compose.yaml index 00e22879..7eaceee8 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -16,11 +16,15 @@ services: - xiaoju-survey xiaoju-survey: - image: "xiaojusurvey/xiaoju-survey:1.0.0" + image: "xiaojusurvey/xiaoju-survey:1.0.3" container_name: xiaoju-survey restart: always ports: - "8080:3000" # API端口 + environment: + XIAOJU_SURVEY_MONGO_URL: mongodb://${MONGO_INITDB_ROOT_USERNAME}:${MONGO_INITDB_ROOT_PASSWORD}@xiaoju-survey-mongo:27017 # docker-compose 会根据容器名称自动处理 + XIAOJU_SURVEY_JWT_SECRET: surveyEngineJwtSecret + XIAOJU_SURVEY_JWT_EXPIRES_IN: 8h links: - mongo:mongo depends_on: diff --git a/server/.env.example b/server/.env.example deleted file mode 100644 index 4d51295f..00000000 --- a/server/.env.example +++ /dev/null @@ -1,16 +0,0 @@ -# mongo -XIAOJU_SURVEY_MONGO_URL=mongodb://localhost:27017 -XIAOJU_SURVER_MONGO_DBNAME=xiaojuSurvey - -# session -# 8 * 3600 * 1000 -XIAOJU_SURVEY_SESSION_EXPIRE_TIME=28800000 - -# encrypt -XIAOJU_SURVEY_ENCRYPT_TYPE=aes -XIAOJU_SURVEY_ENCRYPT_SECRET_KEY=dataAesEncryptSecretKey -XIAOJU_SURVEY_ENCRYPT_TYPE_LEN=10 - -# jwt -XIAOJU_SURVEY_JWT_SECRET=xiaojuSurveyJwtSecret -XIAOJU_SURVEY_JWT_EXPIRES_IN=8h \ No newline at end of file diff --git a/server/package.json b/server/package.json index 50b166ee..4a094a23 100644 --- a/server/package.json +++ b/server/package.json @@ -33,7 +33,6 @@ "dependencies": { "cheerio": "^1.0.0-rc.12", "crypto-js": "^4.2.0", - "dotenv": "^16.3.1", "glob": "^10.3.10", "joi": "^17.9.2", "jsonwebtoken": "^9.0.1", diff --git a/server/src/config/index.ts b/server/src/config/index.ts index ccb267c8..4ca78c6c 100644 --- a/server/src/config/index.ts +++ b/server/src/config/index.ts @@ -1,21 +1,21 @@ const mongo = { url: process.env.XIAOJU_SURVEY_MONGO_URL || 'mongodb://localhost:27017', dbName: process.env.XIAOJU_SURVER_MONGO_DBNAME || 'xiaojuSurvey', -} +}; const session = { expireTime: parseInt(process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN) || 8 * 3600 * 1000 -} +}; const encrypt = { type: process.env.XIAOJU_SURVEY_ENCRYPT_TYPE || 'aes', aesCodelength: parseInt(process.env.XIAOJU_SURVEY_ENCRYPT_TYPE_LEN) || 10 //aes密钥长度 -} +}; const jwt = { secret: process.env.XIAOJU_SURVEY_JWT_SECRET || 'xiaojuSurveyJwtSecret', expiresIn: process.env.XIAOJU_SURVEY_JWT_EXPIRES_IN || '8h' -} +}; export{ @@ -23,4 +23,4 @@ export{ session, encrypt, jwt, -} +}; diff --git a/server/src/index.ts b/server/src/index.ts index a3c505ca..0331d2cc 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -1,4 +1,3 @@ -import 'dotenv/config'; import * as os from 'os'; import * as Koa from 'koa'; import * as KoaBodyparser from 'koa-bodyparser';