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
68 changes: 68 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# ignores all .nx files - generated due a bug in dependencies - see https://github.com/nrwl/nx-console/issues/1975
.nx

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/
dist/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

# gnomi.txt
Gnomi.txt
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifier": "project-relative",
"typescript.preferences.importModuleSpecifierEnding": "minimal",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.removeUnusedImports": "explicit"
Expand Down
29 changes: 23 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
FROM node:20.12.2
FROM node:22.20-alpine3.21 AS ng-build-stage

# node:20.19-alpine3.20
# 22.20-alpine3.21

# Setze das Arbeitsverzeichnis im Container
WORKDIR /usr/src/app

# sourcen kopieren ausser .dockerignore
COPY . /usr/src/app/

# use local sources
RUN npm install && \
npm run build:prod

# fresh small image
FROM node:22.20-alpine3.21 AS webmud3

# Setze das Arbeitsverzeichnis im Container
WORKDIR /usr/src/app

# Kompilat kopieren
COPY backend/dist ./
# kopiere NUR das kompilat
COPY --from=ng-build-stage /usr/src/app/backend/dist /usr/src/app

# Installiere die Abhängigkeiten
RUN npm install --no-package-lock --include=prod
# nondev dependencies mitnehmen
RUN npm install --no-package-lock --omit dev

# Setze die Umgebungsvariable PORT
ENV PORT=5000
Expand All @@ -16,4 +32,5 @@ ENV PORT=5000
EXPOSE 5000

# Starte die Anwendung
CMD ["node", "main.js"]
CMD ["node", "main.js"]
# testing CMD ["/bin/sh"]
7 changes: 6 additions & 1 deletion backend/jest.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = {
diagnostics: {
ignoreCodes: [1343],
},
// We use jest in old-school CommonJS mode, so we need to tell ts-jest to
// compile to CommonJS as well, otherwise we get errors about Jest not
// being able to handle ES modules.
tsconfig: "tsconfig.jest.json",
astTransformers: {
before: [
{
Expand All @@ -30,6 +34,7 @@ module.exports = {
testEnvironment: "node",
// Notwendig, damit die Dateiendung .js nicht an den Dateinamen angehängt wird
moduleNameMapper: {
"^(.+).js$": "$1",
"^(.+)\\.js$": "$1"
},

};
6 changes: 5 additions & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "1.0.0-alpha",
"description": "Webmud3 Backend Service",
"type": "module",
"author": "Myonara",
"authors": ["Myonara", "Felag"],
"license": "MIT",
"private": true,
"engines": {
"node": "~22.20.0"
},
Expand All @@ -17,6 +18,7 @@
"dist"
],
"scripts": {
"prebuild": "npm run build --workspace @webmud3/shared",
"build": "npm run clean:dist && tsc",
"build:watch": "npm run clean:dist && tsc --watch",
"clean": "npm run clean:dist && npm run clean:packages",
Expand All @@ -31,13 +33,15 @@
"test": "jest --config=jest.config.cjs"
},
"dependencies": {
"@webmud3/shared": "1.0.0-alpha",
"body-parser": "~2.2.0",
"cors": "~2.8.5",
"dotenv": "~17.2.3",
"express": "~5.1.0",
"socket.io": "~4.8.1",
"source-map-support": "~0.5.21",
"telnet-stream": "~1.1.0",
"url": "~0.11.4",
"uuid": "~13.0.0",
"winston": "~3.18.3"
},
Expand Down
4 changes: 2 additions & 2 deletions backend/src/core/environment/environment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('Environment', () => {

const getFreshEnvironmentInstance = async () => {
// Dynamically import the Environment class to ensure a fresh instance
const { Environment } = await import('./environment');
const { Environment } = await import('./environment.js');

return Environment.getInstance();
};
Expand All @@ -33,7 +33,7 @@ describe('Environment', () => {

const env = await getFreshEnvironmentInstance();

const { Environment } = await import('./environment');
const { Environment } = await import('./environment.js');

expect(env).toBeInstanceOf(Environment);
});
Expand Down
7 changes: 2 additions & 5 deletions backend/src/core/environment/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Environment implements IEnvironment {
* Initializes the environment variables.
*/
private constructor() {
configureEnvironment();
configureEnvironment({ quiet: true });

this.host = String(getEnvironmentVariable('HOST', false, '0.0.0.0'));

Expand Down Expand Up @@ -68,10 +68,7 @@ export class Environment implements IEnvironment {

this.name = String(getEnvironmentVariable('NAME', false, 'webmud3b'));

const corsAllowList = getEnvironmentVariable(
'CORS_ALLOWED_ORIGINS',
false,
);
const corsAllowList = getEnvironmentVariable('CORS_ALLOWED_ORIGINS', false);

this.corsAllowList =
corsAllowList === null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { EnvironmentKeys } from '../types/environment-keys';
import { getEnvironmentVariable } from './get-environment-variable';
import { EnvironmentKeys } from '../types/environment-keys.js';
import { getEnvironmentVariable } from './get-environment-variable.js';

describe('getEnvironmentVariable', () => {
const ENV_KEY = 'TEST_ENV_KEY' as EnvironmentKeys;
Expand Down
3 changes: 0 additions & 3 deletions backend/src/core/middleware/types/server-config.ts

This file was deleted.

Loading