Skip to content
Snippets Groups Projects
Commit 6ea2108d authored by michael.minelli's avatar michael.minelli
Browse files

Merge branch 'v3.2.0'

parents 7fc2994e 63c34071
Branches
Tags
No related merge requests found
Pipeline #27394 passed
......@@ -17,8 +17,13 @@
- No modifications / Keep major and minors versions in sync with all parts of the project
-->
## 3.2.0 (???)
## 3.1.0 (???)
### 🤏 Minor change
- **Exercices**: Set names of students in exercise name in alphabetical order
## 3.1.0 (2023-12-06)
### 🔨 Internal / Developers
- **Typescript**: Add linter (ESLint)
......
This diff is collapsed.
openapi: 3.1.0
info:
title: Dojo API
version: 3.1.3
version: 3.2.0
description: |
**Backend API of the Dojo project.**
......
{
"name": "dojo_backend_api",
"version": "3.1.0",
"version": "3.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "dojo_backend_api",
"version": "3.1.0",
"version": "3.2.0",
"license": "AGPLv3",
"dependencies": {
"@prisma/client": "^5.6.0",
......@@ -50,6 +50,7 @@
"@types/uuid": "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser": "^6.13.2",
"dotenv-cli": "^7.3.0",
"dotenv-vault": "^1.25.0",
"genversion": "^3.1.1",
"nodemon": "^3.0.2",
......@@ -2298,6 +2299,21 @@
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/dotenv-cli": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/dotenv-cli/-/dotenv-cli-7.3.0.tgz",
"integrity": "sha512-314CA4TyK34YEJ6ntBf80eUY+t1XaFLyem1k9P0sX1gn30qThZ5qZr/ZwE318gEnzyYP9yj9HJk6SqwE0upkfw==",
"dev": true,
"dependencies": {
"cross-spawn": "^7.0.3",
"dotenv": "^16.3.0",
"dotenv-expand": "^10.0.0",
"minimist": "^1.2.6"
},
"bin": {
"dotenv": "cli.js"
}
},
"node_modules/dotenv-expand": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-10.0.0.tgz",
......
{
"name" : "dojo_backend_api",
"description" : "Backend API of the Dojo project",
"version" : "3.1.3",
"version" : "3.2.0",
"license" : "AGPLv3",
"author" : "Michaël Minelli <dojo@minelli.me>",
"main" : "dist/src/app.js",
......@@ -13,12 +13,16 @@
"build:openapi" : "sed -i -r \"1,20 s/^\\([ ]*version:\\).*$/\\1 $(jq -r .version package.json)/\" assets/OpenAPI/OpenAPI.yaml; npx @redocly/cli build-docs assets/OpenAPI/OpenAPI.yaml --output=assets/OpenAPI/redoc.html",
"build:project" : "npm run genversion; npx prisma generate && npx tsc --project ./ && cp -R assets dist/assets",
"build" : "npm run build:openapi; npm run build:project",
"database:migrate" : "npx prisma migrate deploy",
"database:seed" : "npm run genversion; npx prisma db seed",
"database:deploy" : "npm run database:migrate && npm run database:seed",
"database:migrate:create": "npx dotenv -e .env.development -- npx prisma migrate dev",
"database:migrate:dev" : "npx dotenv -e .env.development -- npx prisma migrate deploy",
"database:migrate:prod" : "npx prisma migrate deploy",
"database:seed:dev" : "npm run genversion; npm run build; npx dotenv -e .env.development -- npx prisma db seed",
"database:seed:prod" : "npm run genversion; npm run build; NODE_ENV=production npx prisma db seed",
"database:deploy:dev" : "npm run database:migrate:dev && npm run database:seed:dev",
"database:deploy:prod" : "npm run database:migrate:prod && npm run database:seed:prod",
"start:dev" : "npm run genversion; npx nodemon src/app.ts",
"start:prod" : "npm run genversion; NODE_ENV=production npx node --max-http-header-size=1048576 dist/src/app.js",
"start:migrate:prod": "npm run genversion; npm run database:deploy && npm run start:prod"
"start:migrate:prod" : "npm run genversion; npm run database:deploy:prod && npm run start:prod"
},
"prisma" : {
"seed": "node dist/prisma/seed"
......@@ -65,6 +69,7 @@
"@types/uuid" : "^9.0.7",
"@typescript-eslint/eslint-plugin": "^6.13.2",
"@typescript-eslint/parser" : "^6.13.2",
"dotenv-cli" : "^7.3.0",
"dotenv-vault" : "^1.25.0",
"genversion" : "^3.1.1",
"nodemon" : "^3.0.2",
......
This diff is collapsed.
......@@ -10,7 +10,7 @@ class SecurityMiddleware {
check(checkIfConnected: boolean, ...checkTypes: Array<SecurityCheckType>): (req: express.Request, res: express.Response, next: express.NextFunction) => void {
return async (req: express.Request, res: express.Response, next: express.NextFunction) => {
if ( checkIfConnected ) {
if ( req.session.profile === null ) {
if ( req.session.profile === null || req.session.profile === undefined ) {
return req.session.sendResponse(res, StatusCodes.UNAUTHORIZED);
}
}
......
......@@ -77,7 +77,7 @@ class ExerciseRoutes implements RoutesManager {
}
private getExerciseName(assignment: Assignment, members: Array<GitlabUser>, suffix: number): string {
return `DojoEx - ${ assignment.name } - ${ members.map(member => member.username).join(' + ') }${ suffix > 0 ? ` - ${ suffix }` : '' }`;
return `DojoEx - ${ assignment.name } - ${ members.map(member => member.username).sort((a, b) => a.localeCompare(b)).join(' + ') }${ suffix > 0 ? ` - ${ suffix }` : '' }`;
}
private getExercisePath(assignment: Assignment, exerciseId: string): string {
......
# DojoBackendAPI
## Development environment
### Env vars
You can decrypt env var stored in the `.env.vault` file with the following commands in the `ExpressAPI` folder:
```bash
> npx dotenv-vault local keys
environment DOTENV_KEY
─────────── ─────────────────────────────────────────────────────────────────────────
development dotenv://:key_1234@dotenv.local/vault/.env.vault?environment=development
Set DOTENV_KEY on your server
> npx dotenv-vault local decrypt dotenv://:key_1234@dotenv.local/vault/.env.vault?environment=development > .env.development
```
**The `.env.keys` file have to be requested to the project maintainers.**
### Database
For development, you can use the docker-compose file in the `Resources/DevInfra/` folder.
```bash
docker-compose -f Resources/DevInfra/docker-compose.yml up -d
```
This will run a MariaDB database on port `59231` with the following credentials: `root:9buz7f312479g6234f1gnioubervw79b8z`
A second container is created with the Adminer tool on port `62394`.
#### Structure creation and seeding
The following command will create the database structure and seed it with some exemple data.
```bash
npm run database:deploy:dev
```
\ No newline at end of file
version: '3.8'
services:
dojo-database:
container_name: dojo-database
image: mariadb:11.0
environment:
MARIADB_ROOT_PASSWORD: '9buz7f312479g6234f1gnioubervw79b8z'
networks:
dojo-network:
aliases:
- dojo-database
volumes:
- dojo-database:/var/lib/mysql
ports:
- "59231:3306"
restart: always
adminer:
container_name: adminer
image: adminer:latest
environment:
- ADMINER_DEFAULT_SERVER=dojo-database
- TZ=Europe/Zurich
- ADMINER_PLUGINS=dump-alter dump-bz2 dump-date dump-json dump-xml dump-zip edit-foreign edit-textarea foreign-system json-column sql-log struct-comments tables-filter
networks:
dojo-network:
aliases:
- adminer
depends_on:
- dojo-database
ports:
- "62394:8080"
restart: always
networks:
dojo-network:
volumes:
dojo-database:
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment