Skip to content
Merged

Dev #16

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
05a97e5
initialize project structure with empty configuration and source files
LuisAll12 Nov 18, 2025
1043fd0
[feat] Changed Docs in Readme
Jamie-Poeffel Nov 18, 2025
fc430de
Merge branch 'main' of github.com:MindsofD23b/Backend
LuisAll12 Nov 18, 2025
07647ed
[feat] Update .gitignore to include additional environment files and …
LuisAll12 Nov 18, 2025
b9ab41c
feat: initialize TypeScript Express application with Prisma integration
LuisAll12 Nov 18, 2025
9c2091f
Merge branch 'main' of github.com:MindsofD23b/Backend
LuisAll12 Nov 18, 2025
75fed68
feat: enhance error handling in auth controllers and update ESLint co…
LuisAll12 Nov 18, 2025
52d799e
refactor: reorganize package.json scripts and update module type
LuisAll12 Nov 18, 2025
d0888b5
fix: update linting workflow and ESLint configuration for improved ac…
LuisAll12 Nov 18, 2025
0f32bc7
refactor: update Prisma schema and migration files for user and user_…
LuisAll12 Nov 19, 2025
3b52ba5
fix: correct password field reference in user repository and auth ser…
LuisAll12 Nov 19, 2025
634ab5a
feat: add getUserByEmail functionality and update last login in auth …
LuisAll12 Nov 19, 2025
38b48cc
chore: update testing setup and add initial test files
LuisAll12 Nov 19, 2025
2376fea
[feat] renamed __tests__ to tests
Jamie-Poeffel Nov 19, 2025
d050fb8
[feat] fixed duplicate jest config
Jamie-Poeffel Nov 19, 2025
d75fb5a
[feat] Fixed testing error for Typescript
Jamie-Poeffel Nov 19, 2025
e78680f
[feat] fixed Make docker build
Jamie-Poeffel Nov 19, 2025
f547679
test: add integration tests for user registration and unit tests for …
LuisAll12 Nov 19, 2025
563a76a
Merge branch 'feature/auth-lint-fix' of github.com:MindsofD23b/Backen…
LuisAll12 Nov 19, 2025
f4c9bbf
feat: add password hashing utility and corresponding tests
LuisAll12 Nov 19, 2025
52deba2
refactor: reorganize test files and update paths for auth and passwor…
LuisAll12 Nov 19, 2025
e87df6a
Install bcryptjs and typings for auth/password hashing
LuisAll12 Nov 19, 2025
af8cfb6
Merge pull request #7 from MindsofD23b/feature/main-with-tests-and-au…
Jamie-Poeffel Nov 19, 2025
e77362c
feat: add registration tests for user creation and email validation
LuisAll12 Nov 19, 2025
bf1c0a2
feat(auth): implement JWT authentication and user retrieval
LuisAll12 Nov 19, 2025
f28bd41
test(auth): enhance authService tests for registration and login func…
LuisAll12 Nov 19, 2025
3a140bd
feat: add Server and Plan models with migrations
LuisAll12 Nov 19, 2025
35ab33d
feat: add email verification functionality and nodemailer integration
LuisAll12 Nov 20, 2025
adfd3e0
fix: correct .gitignore entries for environment files
LuisAll12 Nov 20, 2025
3a8dac3
Merge branch 'main' of github.com:MindsofD23b/Backend
Jamie-Poeffel Nov 20, 2025
82924b6
[fix] added Database url to make file
Jamie-Poeffel Nov 20, 2025
d6fbb8c
Update dev (#12)
Jamie-Poeffel Nov 20, 2025
8725f12
fix deletion of .env
Jamie-Poeffel Nov 20, 2025
000b878
[fix] remove package-lock.json
Jamie-Poeffel Nov 20, 2025
1ba8cc9
Merge branch 'main' of github.com:MindsofD23b/Backend into dev
Jamie-Poeffel Nov 20, 2025
5f603bd
Merge branch 'main' into dev
Jamie-Poeffel Nov 20, 2025
ebc8eb0
[fix] Added migration because it was out of sync with Production migr…
Jamie-Poeffel Nov 20, 2025
61c6231
[refactor] removed package-lock.json because of merge conflicts
Jamie-Poeffel Nov 20, 2025
ac4e799
feat(auth): implement email verification process with Prisma and Post…
LuisAll12 Nov 20, 2025
d9d9b88
Update linting-backend.yml
Jamie-Poeffel Nov 20, 2025
3c0f17e
Change npm ci to npm install in workflow
Jamie-Poeffel Nov 20, 2025
4b20a90
Update testing-backend.yml
Jamie-Poeffel Nov 20, 2025
675499f
Update testing-backend.yml
Jamie-Poeffel Nov 20, 2025
58d3aa7
Enable LFS support in GitHub Actions workflow
Jamie-Poeffel Nov 20, 2025
4c9603e
[fix] adding JWT_SECRET for testing
Jamie-Poeffel Nov 20, 2025
700d73c
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
Jamie-Poeffel Nov 20, 2025
18a4f33
feat: refactor authentication flow and enhance test coverage
LuisAll12 Nov 20, 2025
05e81d2
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
LuisAll12 Nov 20, 2025
3c7186b
feat: add PostgreSQL support and update mail service configuration
LuisAll12 Nov 21, 2025
0d3fc77
changing Makefile
Jamie-Poeffel Nov 21, 2025
3555425
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
Jamie-Poeffel Nov 21, 2025
d80aefd
Add environment variables for testing workflow
Jamie-Poeffel Nov 21, 2025
7fed51c
Update testing-backend.yml
Jamie-Poeffel Nov 21, 2025
2cdfc7c
[feat] Nodemailer and Make testing with env variables added
Jamie-Poeffel Nov 21, 2025
b59c879
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
Jamie-Poeffel Nov 21, 2025
4bc61a6
[chore] Reworked Gito Template for faster commit Messages
Jamie-Poeffel Nov 21, 2025
72172f2
feat: implement user profile management with controllers and repository
LuisAll12 Nov 21, 2025
bf273b5
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
LuisAll12 Nov 21, 2025
7d07b55
[feat] Added Sonarqube to check Coverage of tests
Jamie-Poeffel Nov 22, 2025
f29623a
[fix] Added corsOptions
Jamie-Poeffel Nov 24, 2025
1423f42
feat: add verified middleware for token validation and user verification
LuisAll12 Nov 24, 2025
b5522d9
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
LuisAll12 Nov 24, 2025
42b6f50
[feat] Email verification
Jamie-Poeffel Nov 24, 2025
ea3c7c3
Merge branch 'dev' of github.com:MindsofD23b/Backend into dev
Jamie-Poeffel Nov 24, 2025
54ccfb1
[fix] linting Error fixed
Jamie-Poeffel Nov 24, 2025
6013adf
feature dockerized, make
Jamie-Poeffel Dec 9, 2025
79860dc
Merge branch 'main' into dev
Jamie-Poeffel Dec 9, 2025
b5c3d0d
Fix .ts
Jamie-Poeffel Dec 9, 2025
01e7184
fix on tests
Jamie-Poeffel Dec 9, 2025
f1d096d
Check middleware test
Jamie-Poeffel Dec 9, 2025
9eb292d
fixed token test because false login
Jamie-Poeffel Dec 9, 2025
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/Backend.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"prisma.pinToPrisma6": true
}
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ FROM node:20-alpine AS builder
WORKDIR /src

COPY package*.json ./
RUN npm ci
RUN npm install


COPY . .

RUN npm run build


FROM node:20-alpine

WORKDIR /src
WORKDIR /


COPY --from=builder /src/package*.json ./
Expand All @@ -22,4 +25,4 @@ ENV PORT=5679
EXPOSE 5679


CMD ["node", "server.js"]
CMD ["node", "dist/server.js"]
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
DOCKER = docker
IMAGE_NAME = nethr-backend
CONTAINER_NAME = Nethr-server
DB_CONTAINER = nethr-srv-db

# Testing
PRISMA = prisma
Expand All @@ -17,6 +18,26 @@ all: run
build: test
$(DOCKER) build -t $(IMAGE_NAME) .

$(DOCKER) run -d --rm \
--name $(DB_CONTAINER) \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
postgres

frbuild:
$(DOCKER) build -t $(IMAGE_NAME) .

$(DOCKER) run -d --rm \
--name $(DB_CONTAINER) \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=testdb \
-p 5432:5432 \
postgres


run: build
$(DOCKER) run -d --name $(CONTAINER_NAME) -p 5679:5679 $(IMAGE_NAME):latest

Expand Down Expand Up @@ -61,6 +82,9 @@ test-withoutsq:

$(NPX) rimraf coverage

sonar:
$(DOCKER) compose up -d

reset:
$(DOCKER) stop $(TESTING_CONTAINER)

Expand All @@ -69,3 +93,4 @@ clean:
$(DOCKER) stop $(CONTAINER_NAME)
$(DOCKER) rm $(CONTAINER_NAME)
$(DOCKER) rmi $(IMAGE_NAME)

1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ services:
- postgresql_data:/var/lib/postgresql/data
networks:
- sonar-net



networks:
Expand Down
13 changes: 13 additions & 0 deletions minecraft-srv/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
services:
dind:
image: docker:24-dind
privileged: true
volumes:
- docker-data:/var/lib/docker

app:
build: ./app
volumes:
- /var/run/docker.sock:/var/run/docker.sock
depends_on:
- dind
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@
"name": "srv",
"version": "1.0.0",
"description": "",
"main": "server.js",
"main": "src/server.ts",
"scripts": {
"dev": "nodemon",
"dev": "nodemon --watch src --ext ts --exec ts-node src/server.ts",
"prisma:migrate": "prisma migrate dev",
"prisma:generate": "prisma generate",
"start": "node server.js",
"start": "node dist/server.js",
"lint": "eslint",
"build": "tsc",
"sonarqube": "docker compose up -d"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module",
"ts-node": {
"esm": true
},
"type": "commonjs",
"devDependencies": {
"@eslint/js": "^9.39.1",
"@types/bcryptjs": "^3.0.0",
Expand All @@ -37,6 +35,8 @@
"rimraf": "^6.1.2",
"supertest": "^7.1.4",
"ts-jest": "^29.4.5",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.9.3"
},
"dependencies": {
Expand All @@ -51,7 +51,6 @@
"jsonwebtoken": "^9.0.2",
"nodemailer": "^7.0.10",
"nodemon": "^3.1.11",
"ts-node": "^10.9.2",
"typescript-eslint": "^8.47.0"
}
}
22 changes: 11 additions & 11 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ generator client {

// User-Tabelle (mapped auf "users")
model User {
id String @id @default(uuid())
email String @unique
passwordHash String @map("password_hash")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
lastLogin DateTime? @map("last_login")
status String @default("active")
role String @default("user")
locale String @default("en")
timezone String @default("UTC")
emailVerifiedAt DateTime? @map("email_verified_at")
id String @id @default(uuid())
email String @unique
passwordHash String @map("password_hash")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @map("updated_at")
lastLogin DateTime? @map("last_login")
status String @default("active")
role String @default("user")
locale String @default("en")
timezone String @default("UTC")
emailVerifiedAt DateTime? @map("email_verified_at")

profile UserProfile?
servers Server[]
Expand Down
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import express from "express";
import cors from "cors";
import { env } from "./config/env.ts";
import { router } from "./routes/index.ts";
import { env } from "./config/env";
import { router } from "./routes/index";

export const createApp = () => {
const corsOptions = {
origin: '*'
origin: 'http://localhost:3000'
};

const app = express();
Expand Down
19 changes: 15 additions & 4 deletions src/controllers/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Request, Response, NextFunction } from "express";
import { authService } from "../services/auth.service.ts";
import { env } from "../config/env.ts";
import { authService } from "../services/auth.service";
import { env } from "../config/env";
import { Logger } from "../utils/logger";
import { signAccessToken } from "../core/security/jwt";

export const registerController = async (
req: Request,
Expand All @@ -11,9 +13,11 @@ export const registerController = async (
const { email, password } = req.body;
const user = await authService.register(email, password);
res.status(201).json({ id: user.id, email: user.email });
Logger.success(`${user.id} created a account`);
} catch (err: unknown) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message}`);
} else {
res.status(400).json({ error: "Unknown error", err });
}
Expand All @@ -28,10 +32,13 @@ export const loginController = async (
try {
const { email, password } = req.body;
const user = await authService.login(email, password);
res.json({ id: user.id, email: user.email });
const token = signAccessToken({ sub: user.id, email: user.email, role: user.role })
res.json({ id: user.id, email: user.email, token: token });
Logger.success(`${user.id} logged in `);
} catch (err: unknown) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message} `);
} else {
res.status(400).json({ error: "Unknown error" });
}
Expand All @@ -50,6 +57,7 @@ export const getUserByEmailController = async (
} catch (err: unknown) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message} `)
} else {
res.status(400).json({ error: "Unknown error", err });
}
Expand All @@ -64,12 +72,15 @@ export const verifyEmailController = async (
try {
const token = req.query.token;

await authService.verifyEmail(token as string);
const user = await authService.verifyEmail(token as string);

Logger.success(`${user.id} has verified a email`);

res.redirect(env.appBaseUrl)
} catch (err: unknown) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message} `)
} else {
res.status(400).json({ error: "Unknown error", err });
}
Expand Down
8 changes: 7 additions & 1 deletion src/controllers/user.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Request, Response, NextFunction } from "express";
import { userService } from "../services/user.service.ts";
import { userService } from "../services/user.service";
import { Logger } from "../utils/logger";

export const getMyProfileController = async (
req: Request,
Expand All @@ -9,10 +10,13 @@ export const getMyProfileController = async (
try {
const userId = req.user!.id;
const result = await userService.getUserWithProfileById(userId);

res.json(result);
Logger.success(`${req.user!.id} has requested their profile`);
} catch (err) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message}`);
} else {
res.status(400).json({ error: "Unknown error" });
}
Expand All @@ -29,9 +33,11 @@ export const updateMyProfileController = async (
const profileData = req.body;
const result = await userService.updateProfile(userId, profileData);
res.json(result);
Logger.success(`${userId} has updated their profile`)
} catch (err) {
if (err instanceof Error) {
res.status(400).json({ error: err.message });
Logger.error(`${err.message}`)
} else {
res.status(400).json({ error: "Unknown error" });
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/security/jwt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import jwt from "jsonwebtoken";
import type { Secret, SignOptions } from "jsonwebtoken";
import { env } from '../../config/env.ts';
import { env } from '../../config/env';

export interface JwtPayload {
sub: string;
Expand Down
3 changes: 2 additions & 1 deletion src/middleware/auth.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Request, Response, NextFunction } from "express";
import { verifyAccessToken } from "../core/security/jwt.ts";
import { verifyAccessToken } from "../core/security/jwt";

export function authMiddleware(
req: Request,
res: Response,
next: NextFunction
) {

const authHeader = req.headers.authorization;
if (!authHeader?.startsWith("Bearer ")) {
return res.status(401).json({ error: "Unauthorized" });
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/user.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from "../config/db.ts";
import { prisma } from "../config/db";

export const userRepository = {
findByEmail(email: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/repositories/userProfile.repository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { prisma } from "../config/db.ts";
import { prisma } from "../config/db";

export const userProfileRepository = {
findByUserId(userId: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/auth.routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from "express";
import { getUserByEmailController, loginController, registerController, verifyEmailController } from "../controllers/auth.controller.ts";
import { getUserByEmailController, loginController, registerController, verifyEmailController } from "../controllers/auth.controller";

export const authRouter = Router();

Expand Down
4 changes: 3 additions & 1 deletion src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Router } from "express";
import { authRouter } from "./auth.routes.ts";
import { authRouter } from "./auth.routes";
import { userRouter } from "./user.routes";

export const router = Router();

router.use("/auth", authRouter);
router.use("/user", userRouter);
2 changes: 1 addition & 1 deletion src/routes/user.routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Router } from "express";
import { authMiddleware } from "../middleware/auth.middleware.ts";
import { authMiddleware } from "../middleware/auth.middleware";

import {
getMyProfileController,
Expand Down
Loading