Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ server/src/configs/*
!server/src/configs/default.json
!server/src/configs/areas.example.json
!server/src/configs/local.example.json
!server/src/configs/custom-environment-variables.json
.env


# Masterfile
server/src/data/masterfile.json

Expand Down
15 changes: 15 additions & 0 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ services:
container_name: reactmap
command: sh -c "yarn start"
restart: unless-stopped
environment:
SCANNER_DB_HOST: 127.0.0.1
SCANNER_DB_PORT: 3306
SCANNER_DB_USER: scanner_username
SCANNER_DB_PASSWORD: scanner_user_pw
SCANNER_DB_NAME: realdevicemap
MANUAL_DB_HOST: 127.0.0.1
MANUAL_DB_PORT: 3306
MANUAL_DB_USER: manual_username
MANUAL_DB_PASSWORD: manual_user_pw
MANUAL_DB_NAME: manual_db
MAP_GENERAL_TITLE: ReactMap
MAP_GENERAL_START_LAT: 0
MAP_GENERAL_START_LON: 0
ARRAY_VALUE_EXAMPLE: "[3, 4, 5]"
volumes:
- ./server/src/configs/areas.json:/home/node/server/src/configs/areas.json
- ./server/src/configs/local.json:/home/node/server/src/configs/local.json
Expand Down
6 changes: 5 additions & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ const esbuild = {
sourcemap: isRelease || isDevelopment,
define: {
inject: JSON.stringify({
...env.parsed,
GOOGLE_ANALYTICS_ID: env.parsed.GOOGLE_ANALYTICS_ID || '',
ANALYTICS_DEBUG_MODE: env.parsed.ANALYTICS_DEBUG_MODE || false,
TITLE: env.parsed.TITLE || env.parsed.MAP_GENERAL_TITLE || '',
SENTRY_DSN: env.parsed.SENTRY_DSN || '',
SENTRY_TRACES_SAMPLE_RATE: env.parsed.SENTRY_TRACES_SAMPLE_RATE || 0.1,
VERSION: version,
DEVELOPMENT: isDevelopment,
CUSTOM: hasCustom,
Expand Down
1 change: 0 additions & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
GOOGLE_ANALYTICS_ID=
TITLE="Map"
TELEGRAM_BOT_NAME=""
SENTRY_DSN=""
SENTRY_AUTH_TOKEN=""
SENTRY_ORG=""
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "reactmap",
"version": "1.2.2",
"version": "1.2.3",
"description": "React based frontend map.",
"main": "ReactMap.mjs",
"author": "TurtIeSocks <58572875+TurtIeSocks@users.noreply.github.com>",
Expand All @@ -14,6 +14,7 @@
"serve": "node esbuild.config.mjs --dev --serve",
"dev": "nodemon server/src/index.js --watch server",
"generate": "node server/scripts/generateMasterfile.js",
"gen-env-config": "node server/scripts/genEnvConfig.js",
"create-locales": "node server/scripts/createLocales.js",
"missing-locales": "node server/scripts/createLocales.js --missing",
"create-area": "node server/scripts/poracleToGeoJSON.js",
Expand All @@ -31,7 +32,6 @@
"devDependencies": {
"@craftamap/esbuild-plugin-html": "^0.4.0",
"@sentry/cli": "^1.73.0",
"dotenv": "^10.0.0",
"esbuild": "^0.14.36",
"esbuild-plugin-eslinter": "^0.1.2",
"esbuild-plugin-mxn-copy": "^1.0.1",
Expand Down Expand Up @@ -65,6 +65,7 @@
"compression": "^1.7.4",
"config": "^3.3.6",
"discord.js": "^12.5.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"express-mysql-session": "^2.1.6",
"express-rate-limit": "^5.2.6",
Expand Down
2 changes: 1 addition & 1 deletion server/scripts/configMigration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const convertMapObject = (obj) => obj ? ({
customRoutes: {
discordAuthUrl: obj?.discordAuthUrl,
telegramAuthUrl: obj?.telegramAuthUrl,
telegramBotEnvRef: obj?.telegramBotEnvRef,
telegramBotName: obj?.telegramBotEnvRef,
localAuthUrl: obj?.localAuthUrl,
},
links: {
Expand Down
35 changes: 35 additions & 0 deletions server/scripts/genEnvConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* eslint-disable no-console */
const fs = require('fs')
const sourceConfig = require('../src/configs/default.json')

const camelToSnake = str => str.replace(/([a-z](?=[A-Z]))/g, '$1_').toUpperCase()

const recursiveObjCheck = (obj, key = '', parentKey = '') => {
const snakeKey = `${parentKey}${camelToSnake(key)}`
if (Array.isArray(obj)) {
return { __name: snakeKey, __format: 'json' }
}
if (typeof obj === 'object') {
return Object.fromEntries(
Object.entries(obj).map(([k, v]) => (
[k, recursiveObjCheck(v, k, key ? `${snakeKey}_` : snakeKey)]
)),
)
}
return typeof obj === 'string'
? snakeKey
: { __name: snakeKey, __format: typeof obj }
}

const generateEnvConfig = async () => {
fs.writeFileSync(
`${__dirname}/../src/configs/custom-environment-variables.json`,
JSON.stringify(recursiveObjCheck(sourceConfig), null, 2),
)
}

module.exports.generateEnvConfig = generateEnvConfig

if (require.main === module) {
generateEnvConfig().then(() => console.log('Env Config Generated'))
}
Loading