Skip to content
Open
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
Empty file added .github/.keep
Empty file.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/QUdQy4ix)
# CS3219 Project (PeerPrep) - AY2526S1
## Group: Gxx
## Group: G14

### Note:
- You are required to develop individual microservices within separate folders within this repository.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.
- The teaching team should be given access to the repositories as we may require viewing the history of the repository in case of any disputes or disagreements.

### Running the app
#### Frontend
1. Switch to `frontend` directory.
```
cd frontend
```
2. Install dependencies.
```
npm install
```
3. Start the app locally.
```
npm start
```

#### Backend
36 changes: 36 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Node modules
node_modules/

# Environment variables
.env
.env.local
.env.*.local

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

# OS files
.DS_Store
Thumbs.db

# Build / output folders
dist/
build/

# Temporary files
tmp/
temp/

# MongoDB local storage (optional, if using local db files)
data/

# IDE / editor files
.vscode/
.idea/

# Coverage reports
coverage/
23 changes: 23 additions & 0 deletions backend/controller/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const User = require('../model/user');

const getUsernames = async (req, res) => {
try {
const users = await User.find();
res.status(200).json({ success: true, payload: users });
} catch (error) {
console.error(error);
res.status(500).json({ success: false, error: 'Server Error' });
}
};

const postUsername = async (req, res) => {
try {
const user = await User.create(req.body);
res.status(201).json({ success: true, payload: user });
} catch (error) {
console.error(error);
res.status(500).json({ success: false, error: 'Server Error' });
}
};

module.exports = { getUsernames, postUsername };
13 changes: 13 additions & 0 deletions backend/model/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const mongoose = require("mongoose");

const userSchema = new mongoose.Schema(
{
username: {
type: String,
required: true,
}
},
{ timestamps: true, collection: 'user' }
);

module.exports = mongoose.model("user", userSchema);
Loading