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
41 changes: 41 additions & 0 deletions backend/controllers/Project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const Project = require('../modules/Project');

const project = (req, res) => {
const data = req.body;
const newProject = new Project({
team_id: data.team_id,
ppt_link: data.ppt_link,
theme: data.theme,
github_link: data.github_link,
hosted_web_app_link: data.hosted_web_app_link,
description: data.description,
challenges: data.challenges
});

newProject.save((err, project) => {
if (err) {
console.log(err);
res.status(500).send('Error in project information, please try again.');
} else {
console.log(project);
res.send('Project creation successful!');
}
});
};
// A method to retrieve all the project information
const getProjects = (req, res) => {
Registration.find({}, (err, projects) => {
if (err) {
console.log(err);
res.status(500).send('Error retrieving project information.');
} else {
res.json(projects);
}
});
};

module.exports = {
project,
getProjects
};

40 changes: 40 additions & 0 deletions backend/modules/Project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// define the schema
const mongoose = require('mongoose');
const Schema = mongoose.Schema;

const ProjectSchema = new Schema({
team_id: {
type: String,
required: true,
unique: true
},
ppt_link: {
type: String,
required: true,
unique: true
},
theme: {
type: String,
required: true
},
github_link: {
type: String,
required: true
},
hosted_web_app_link: {
type: String,
required: true
},
description: {
type: String,
required: true
},
challenges: {
type: String,
required: true
}
});

const Project = mongoose.model('Project', ProjectSchema);

module.exports = Project;
11 changes: 11 additions & 0 deletions backend/routes/Project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const express = require('express');
const router = express.Router();
const projectController = require('../controllers/Project');

// GET all project information
router.get('/', projectController.getProjects);

// POST new project information
router.post('/', projectController.project);

module.exports = router;