Merge branch 'main' into fix-issue-51

This commit is contained in:
wancat committed 2024-02-08 17:48:11 +08:00
commit ca2a40341c
72 files changed
+11372 -7146

No files matched your search

+7 -3
View File
@@ -1,13 +1,14 @@
FROM node:20-alpine AS build
RUN yarn set version berry
WORKDIR /app
COPY ./package.json yarn.lock ./
COPY ./package.json yarn.lock tsconfig.json ./
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/utils/package.json ./packages/utils/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/constants/package.json ./packages/constants/package.json
COPY server/package.json ./server/package.json
RUN yarn install --frozen-lockfile --production
RUN yarn install
# Install docker cli
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
@@ -22,10 +23,11 @@ COPY packages/file-graph ./packages/file-graph
COPY packages/utils ./packages/utils
COPY packages/models ./packages/models
COPY packages/constants ./packages/constants
COPY ./server ./server
COPY server ./server
COPY quests ./quests
ENV NODE_ENV=production
RUN yarn build
WORKDIR /app/server
CMD [ "yarn", "start" ]
@@ -34,5 +36,7 @@ FROM build as dev
RUN yarn install --frozen-lockfile
COPY server/nodemon.json ./server/nodemon.json
COPY tsconfig.json ./tsconfig.json
COPY server/tsconfig.json ./server/tsconfig.json
ENV NODE_ENV=development
CMD [ "yarn", "server" ]
+4 -2
View File
@@ -1,4 +1,6 @@
{
"watch": ["src", "swagger.yaml", "../quests", "../packages"],
"ext": "js,yaml,yml"
"watch": ["dist", "swagger.yaml", "../quests", "../packages"],
"ext": "js,ts,yaml,yml",
"exec": "node dist/index.js",
"delay": 200
}
+14 -7
View File
@@ -4,12 +4,13 @@
"description": "Linux Odyssey Server",
"type": "module",
"scripts": {
"start": "node src/index.js",
"dev": "nodemon src/index.js",
"test": "yarn node --experimental-vm-modules $(yarn bin jest)",
"setup": "node src/cli/setup.js",
"clean": "node src/cli/clean.js",
"build:quests": "node src/cli/build.js"
"start": "node dist/index.js",
"dev": "nodemon",
"setup": "node dist/cli/setup.js",
"clean": "node dist/cli/clean.js",
"build": "tsc",
"watch": "concurrently \"tsc -w\" \"nodemon\"",
"build:quests": "node dist/cli/build.js"
},
"dependencies": {
"@linux-odyssey/constants": "*",
@@ -21,6 +22,7 @@
"connect-mongo": "^5.0.0",
"cookie-parser": "^1.4.6",
"dockerode": "^3.3.5",
"dotenv": "^16.4.1",
"express": "^4.18.2",
"express-rate-limit": "^7.1.3",
"express-session": "^1.17.3",
@@ -28,6 +30,7 @@
"jsonwebtoken": "^9.0.1",
"lusca": "^1.7.0",
"minimist": "^1.2.8",
"mongodb": "^6.3.0",
"mongoose": "^8.0.3",
"node-schedule": "^2.1.1",
"passport": "^0.6.0",
@@ -42,7 +45,11 @@
"yaml": "^2.3.1"
},
"devDependencies": {
"@types/express": "^4.17.21",
"@types/express-session": "^1.17.10",
"concurrently": "^8.2.2",
"jest": "^29.6.1",
"nodemon": "^3.0.1"
"nodemon": "^3.0.1",
"typescript": "^5.3.3"
}
}
+6 -1
View File
@@ -1,6 +1,10 @@
import validator from 'validator'
import dotenv from 'dotenv'
import { get } from './utils/env.js'
// Import dotenv and load ../.env
dotenv.config({ path: '../.env' })
function getTrustProxies(key) {
if (!process.env[key]) {
return []
@@ -40,7 +44,7 @@ const config = {
bugReportUrl: getUrl('BUG_REPORT_URL', ''),
docker: {
network: get('DOCKER_NETWORK', 'linux-odyssey-players'),
network: get('DOCKER_NETWORK', 'host'),
defaultImage: get('QUEST_IMAGE', 'linuxodyssey/quest-base'),
imagePrefix: get('DOCKER_PREFIX', 'linuxodyssey/quest-'),
mountQuest: get('MOUNT_QUEST', ''),
@@ -53,6 +57,7 @@ const config = {
}
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
config.backendUrl = get('BACKEND_URL', config.baseUrl)
config.testing = {
enabled: !config.isProduction && process.env.TESTING === 'true',
username: get('TESTING_USERNAME', ''),
+1 -3
View File
@@ -16,8 +16,6 @@ const containerOptions = {
},
}
// const network = engine.getNetwork(config.dockerNetwork)
export function createContainer(name, questId) {
const option = {
...containerOptions,
@@ -56,7 +54,7 @@ export async function attachContainer(container, { token }) {
Tty: true,
Env: [
`TOKEN=${token}`,
`API_ENDPOINT=http://backend:3000`,
`API_ENDPOINT=${config.backendUrl}`,
'ZDOTDIR=/etc/zsh',
],
})
-2
View File
@@ -41,7 +41,6 @@ async function loadGlobalExceptions() {
export async function loadAndUpdateQuests() {
await Quest.deleteMany({})
const { exceptions } = await loadGlobalExceptions()
console.log(exceptions)
return mapQuests(async (id, questPath) => {
const files = await fs.readdir(questPath)
if (!files.includes('game.yml')) {
@@ -64,7 +63,6 @@ export async function loadAndUpdateQuests() {
quest.exceptions.push(...exceptions)
await quest.save()
} catch (error) {
console.error(error)
logger.error(`Error parsing quest`, { id, error })
throw new QuestValidationError(`Error parsing quest`, id, error)
}
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "./dist"
},
"include": ["src"],
"exclude": ["node_modules", "src/*.test.js", "dist"]
}