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
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#65c89b",
"activityBar.background": "#65c89b",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#945bc4",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#65c89b",
"statusBar.background": "#42b883",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#359268",
"statusBarItem.remoteBackground": "#42b883",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#42b883",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#42b88399",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#42b883"
}
12 changes: 12 additions & 0 deletions backend/authMiddleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { User } from "./schemas";

// FIXME - add error handling, put accesstoken req into variable
export const authentificateUser = async (req, res, next) => {
const user = await User.findOne({ accessToken: req.header("Authorization") });
if (user) {
req.user = user;
next();
} else {
res.status(401).json({ loggedOut: true });
}
};
26 changes: 17 additions & 9 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@
"version": "1.0.0",
"description": "Server part of final project",
"scripts": {
"start": "babel-node server.js",
"dev": "nodemon server.js --exec babel-node"
"start": "nodemon server.js --exec babel-node",
"dev": "nodemon server.js --exec babel-node",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@babel/core": "^7.17.9",
"@babel/node": "^7.16.8",
"@babel/preset-env": "^7.16.11",
"@babel/core": "^7.29.0",
"@babel/node": "^7.29.0",
"@babel/preset-env": "^7.29.0",
"bcrypt": "^6.0.0",
"bcrypt-nodejs": "^0.0.3",
"cors": "^2.8.5",
"express": "^4.17.3",
"mongoose": "^8.4.0",
"nodemon": "^3.0.1"
"crypto": "^1.0.1",
"dotenv": "^17.3.1",
"express": "^4.22.1",
"express-list-endpoints": "^7.1.1",
"mongodb": "^7.1.0",
"mongoose": "^8.23.0",
"nodemon": "^3.1.11",
"test": "^3.3.0"
}
}
}
54 changes: 54 additions & 0 deletions backend/quests.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"_id": "682bab8c12155b00101732db",
"message": "Clean the toilet",
"timeNeed": 20,
"category": ["Cleaning", "Bathroom"],
"deadline": "2026-03-15T22:07:08.999Z",
"done": "true",
"createdAt": "2026-03-08T22:07:08.999Z",
"updatedAt": "2025-03-14T22:07:08.999Z",
"createdBy": "",
"__v": 0
},
{
"_id": "682bab8c12155b00101732nb",
"message": "Do one laundry run",
"timeNeed": 12,
"category": ["Washing", "Clothes"],
"deadline": "2026-03-17T22:07:08.999Z",
"done": "false",
"createdAt": "2026-03-08T22:07:08.999Z",
"__v": 0
},
{
"_id": "682bab8c12155b00101732cb",
"message": "Vacuum clean bedroom",
"timeNeed": 25,
"category": ["Cleaning", "Bedroom"],
"deadline": "2026-03-10T22:07:08.999Z",
"done": "true",
"createdAt": "2026-03-04T22:07:08.999Z",
"updatedAt": "2025-03-09T22:07:08.999Z",
"__v": 0
},
{
"_id": "682bab8c12155b00101732kb",
"message": "Water your plants",
"timeNeed": 5,
"category": ["Plants"],
"done": "false",
"createdAt": "2026-03-08T22:07:08.999Z",
"__v": 0
},
{
"_id": "682bab8c12155b00101732db",
"message": "Unload dishwasher",
"timeNeed": 16,
"category": ["Cleaning"],
"done": "true",
"createdAt": "2026-03-08T22:07:08.999Z",
"updatedAt": "2025-03-09T22:07:08.999Z",
"__v": 0
}
]
112 changes: 112 additions & 0 deletions backend/schemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import mongoose from "mongoose";
import crypto from "crypto";
import bcrypt from "bcrypt-nodejs";

const mongoUrl = process.env.MONGO_URL || "mongodb://localhost/final-project";
mongoose.connect(mongoUrl);
mongoose.Promise = Promise;

// FIXME MUST ---- Quest ----

const questSchema = new mongoose.Schema(
{
message: {
type: String,
required: true,
minLength: 2,
},

timeNeeded: {
type: Number,
require: true,
},

category: [
{
type: String,
lowercase: true,
trim: true,
},
],

deadline: {
type: Date,
require: false,
},

done: {
type: Boolean,
default: false,
},

createdBy: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
},

{ timestamps: true },
);

export const Quest = mongoose.model("Quest", questSchema);

// FIXME MUST ---- User ----

const userSchema = new mongoose.Schema(
{
name: {
type: String,
unique: true,
required: true,
minLength: 3,
maxLength: 24,
},

email: {
type: String,
required: true,
unique: true,
},

password: {
type: String,
required: true,
minLength: 8,
},

registerDate: {
type: Date,
default: () => new Date(),
},

streak: {
type: Number,
default: 0,
},

todayTaskCompleted: {
type: Boolean,
default: false,
},

lastTaskCompleted: {
type: Date,
},

moodUrl: String,

accessToken: {
type: String,
default: () => crypto.randomBytes(128).toString("hex"),
},
},

{ timestamps: true },
);

export const User = mongoose.model("User", userSchema);

// TODO ---- Session ----
// Schema to randomize and sessions?

// TODO ???NICE+ ---- Friends -----
Loading