summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--flake.lock116
-rw-r--r--hashes.json2
-rw-r--r--plan.md42
-rw-r--r--src/api/routes/auth/registerRoute.js2
-rw-r--r--src/db/schemas/index.js1
-rw-r--r--src/db/schemas/user.js14
7 files changed, 120 insertions, 62 deletions
diff --git a/README.md b/README.md

index ac60ea4..6386c3a 100644 --- a/README.md +++ b/README.md
@@ -1,5 +1,10 @@ [![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/3A9ByVp3) +# Safe & Sound API + +This is an API for allowing users with health issues to safely enjoy a theme park. +It provides freedom to people with health issues to enjoy the park while ensuring their safety and well-being. + # Deployment Environment variables: diff --git a/flake.lock b/flake.lock
index 29dacc6..f12b903 100644 --- a/flake.lock +++ b/flake.lock
@@ -1,61 +1,61 @@ { - "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1748370509, - "narHash": "sha256-QlL8slIgc16W5UaI3w7xHQEP+Qmv/6vSNTpoZrrSlbk=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "4faa5f5321320e49a78ae7848582f684d64783e9", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - } + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } }, - "root": "root", - "version": 7 + "nixpkgs": { + "locked": { + "lastModified": 1748460289, + "narHash": "sha256-7doLyJBzCllvqX4gszYtmZUToxKvMUrg45EUWaUYmBg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "96ec055edbe5ee227f28cdbc3f1ddf1df5965102", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 } diff --git a/hashes.json b/hashes.json
index ff7d029..bd1a93e 100644 --- a/hashes.json +++ b/hashes.json
@@ -1,3 +1,3 @@ { - "npmDepsHash": "sha256-389fxQXojG0uXtVxA7hWFeYYslNxXbBI4K2eIIzQUzw=" + "npmDepsHash": "sha256-d3l0xMvkcBSGrC15dE8rE4+brVzi6YIfQBTksqCYD10=" } diff --git a/plan.md b/plan.md new file mode 100644
index 0000000..5f9b7c4 --- /dev/null +++ b/plan.md
@@ -0,0 +1,42 @@ +# Assignment requirements + +- [ ] Express API with at least 17 endpoints +- [ ] Testing: both integration and unit tests +- [ ] Authentication & Authorization: using JWT tokens or a similar technology +- [ ] Error handling +- [ ] MongoDB CRUD operations and Mongoose modeling (with Joi validation) +- [ ] Complete data and input validation (including ObjectId validation) +- [ ] Middleware functions +- [ ] A detailed deployment step-by-step plan: the application must be deployed on a cloud server and publicly accessible +- [ ] REST Client API calls provided for all API endpoints +- [ ] Comprehensive API documentation + +# Feature plan + +- [ ] User management (user/monitor) + - [ ] Registration + - [ ] Validation based on type + - [ ] Login + - [ ] Password reset + - [ ] User profile management +- [ ] Organisation (who's coming? announcement of events, ...) +- [ ] Budgeting with tracking + - [ ] Review spending + - [ ] Request additional budget in case of emergency +- [ ] Emergency alarm + - [ ] Optional: integration with park's emergency services +- [ ] Emergency contact & info card +- [ ] Limitations on consumptions + - [ ] Allergies + - [ ] Sugar intake limitations +- [ ] Location tracking +- [ ] Sensor tracking (sugar level, heart rate, temperature, ...) +- [ ] Day planning (meetups, departure, ...) + - [ ] Location of activities + - [ ] Deadlines +- [ ] Approval of rental of material (independent of budgeting, ie. bikes, ...) +- [ ] Restrictions on attractions (health issues, age, ...) +- [ ] Integration API for park infrastructure (e.g., user-only WiFi network, payment via park wristband according to budget, ...) + - [ ] User-only WiFi network + - [ ] Payment via park wristband according to budget + - [ ] Integration with park's existing systems for seamless user experience \ No newline at end of file diff --git a/src/api/routes/auth/registerRoute.js b/src/api/routes/auth/registerRoute.js
index 725c7d8..8ad4f07 100644 --- a/src/api/routes/auth/registerRoute.js +++ b/src/api/routes/auth/registerRoute.js
@@ -1,4 +1,4 @@ -import { User } from '#db/schemas/user.js'; +import { User } from '#db/index.js'; export const registerRoute = { route: '/auth/register', diff --git a/src/db/schemas/index.js b/src/db/schemas/index.js
index e69de29..ee1c337 100644 --- a/src/db/schemas/index.js +++ b/src/db/schemas/index.js
@@ -0,0 +1 @@ +export * from './user.js'; diff --git a/src/db/schemas/user.js b/src/db/schemas/user.js
index da2516c..22856b2 100644 --- a/src/db/schemas/user.js +++ b/src/db/schemas/user.js
@@ -1,5 +1,9 @@ import { model, Schema } from 'mongoose'; +/** + * User schema for MongoDB. + * @type {module:mongoose.Schema} + */ export const userSchema = new Schema({ username: { type: String, @@ -17,12 +21,18 @@ export const userSchema = new Schema({ unique: true, trim: true }, + type: { + type: String, + enum: ['user', 'admin'], + default: 'user' + }, createdAt: { type: Date, - default: Date.now + default: Date.now, + immutable: true } }); -export const User = model('user', userSchema); +export const DbUser = model('user', userSchema); console.log('[MONGODB] User schema initialized successfully!');