diff --git a/docker-compose.yml b/docker-compose.yml index 2142aaf..0c31e1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,9 +13,7 @@ services: - MOCK_HOME_DIR=/fellow volumes: - /home/xiaoyh/node2/schoolfellow:/fellow - - /home/xiaoyh/node2/schoolfellow/logs:/home/node/logs - # - ./package/fellow.json:/fellow/package.json:ro - # - ./patch/gzip.js:/fellow/app/middleware/gzip.js + - /home/xiaoyh/node2/schoolfellow/logs:/home/node/logs working_dir: /fellow # command: /bin/sh -c "while true; do echo hello world; sleep 1;done" command: npm run start-docker @@ -34,9 +32,7 @@ services: - MOCK_HOME_DIR=/foundation volumes: - /home/xiaoyh/node2/jjh-server:/foundation - - /home/xiaoyh/node2/jjh-server/logs:/home/node/logs - # - ./package/foundation.json:/foundation/package.json:ro - # - ./patch/gzip.js:/foundation/app/middleware/gzip.js + - /home/xiaoyh/node2/jjh-server/logs:/home/node/logs working_dir: /foundation command: npm run start-docker ports: diff --git a/package/fellow.json b/package/fellow.json deleted file mode 100644 index ed37592..0000000 --- a/package/fellow.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "schoolefellow-server", - "version": "1.0.0", - "description": "后台管理系统api", - "private": true, - "egg": { - "declarations": true - }, - "dependencies": { - "egg": "^2.15.1", - "egg-bcrypt": "^1.1.0", - "egg-cors": "^2.2.3", - "egg-scripts": "^2.11.0", - "egg-sequelize": "^6.0.0", - "egg-validate-plus": "^1.1.6", - "jsonwebtoken": "^8.5.1", - "mysql2": "^2.2.5", - "svg-captcha": "^1.4.0" - }, - "devDependencies": { - "autod": "^3.0.1", - "autod-egg": "^1.1.0", - "egg-bin": "^4.11.0", - "egg-ci": "^1.11.0", - "egg-mock": "^3.21.0", - "eslint": "^5.13.0", - "eslint-config-egg": "^7.1.0", - "sequelize-cli": "^6.2.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "scripts": { - "start": "egg-scripts start --daemon --title=egg-server-cms-api --ignore-stderr", - "start-docker": "egg-scripts start --title=egg-server-cms-api --ignore-stderr", - "stop": "egg-scripts stop --title=egg-server-cms-api", - "dev": "egg-bin dev", - "debug": "egg-bin debug", - "test": "npm run lint -- --fix && npm run test-local", - "test-local": "egg-bin test", - "cov": "egg-bin cov", - "lint": "eslint .", - "ci": "npm run lint && npm run cov", - "autod": "autod" - }, - "ci": { - "version": "10" - }, - "repository": { - "type": "git", - "url": "" - }, - "author": "gaoxiangan", - "license": "MIT" -} - diff --git a/package/foundation.json b/package/foundation.json deleted file mode 100644 index b954636..0000000 --- a/package/foundation.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "name": "schoolefellow-server", - "version": "1.0.0", - "description": "后台管理系统api", - "private": true, - "egg": { - "declarations": true - }, - "dependencies": { - "egg": "^2.15.1", - "egg-bcrypt": "^1.1.0", - "egg-cors": "^2.2.3", - "egg-scripts": "^2.11.0", - "egg-sequelize": "^6.0.0", - "egg-validate-plus": "^1.1.6", - "jsonwebtoken": "^8.5.1", - "mysql2": "^2.2.5", - "svg-captcha": "^1.4.0" - }, - "devDependencies": { - "autod": "^3.0.1", - "autod-egg": "^1.1.0", - "egg-bin": "^4.11.0", - "egg-ci": "^1.11.0", - "egg-mock": "^3.21.0", - "eslint": "^5.13.0", - "eslint-config-egg": "^7.1.0", - "sequelize-cli": "^6.2.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "scripts": { - "start": "egg-scripts start --daemon --title=egg-server-cms-api --ignore-stderr", - "start-docker": "egg-scripts start --title=egg-server-cms-api --ignore-stderr", - "stop": "egg-scripts stop --title=egg-server-cms-api", - "dev": "egg-bin dev", - "debug": "egg-bin debug", - "test": "npm run lint -- --fix && npm run test-local", - "test-local": "egg-bin test", - "cov": "egg-bin cov", - "lint": "eslint .", - "ci": "npm run lint && npm run cov", - "autod": "autod" - }, - "ci": { - "version": "10" - }, - "repository": { - "type": "git", - "url": "" - }, - "author": "gaoxiangan", - "license": "MIT" -} diff --git a/patch/gzip.js b/patch/gzip.js deleted file mode 100644 index 863d858..0000000 --- a/patch/gzip.js +++ /dev/null @@ -1,35 +0,0 @@ -const isJSON = require("koa-is-json"); -const zlib = require("zlib"); - -module.exports = (options) => { - return async function gzip(ctx, next) { - // 限制域名访问 added by steven @2023-07-11 - const ipCheck = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; - const host = ctx.request.host.indexOf(":") - ? ctx.request.host.split(":")[0] - : ctx.request.host; - if (ipCheck.test(host)) { - ctx.status = 200; - ctx.body = `访问禁止只允许域名方式访问`; - // ctx.throw(401, "只允许域名访问"); - return; - } - ///// - await next(); - - // 后续中间件执行完成后将响应体转换成 gzip - let body = ctx.body; - if (!body) return; - - // 支持 options.threshold - if (options.threshold && ctx.length < options.threshold) return; - - if (isJSON(body)) body = JSON.stringify(body); - - // 设置 gzip body,修正响应头 - const stream = zlib.createGzip(); - stream.end(body); - ctx.body = stream; - ctx.set("Content-Encoding", "gzip"); - }; -};