Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the teachers schema and fixed some commas(all) #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
16 changes: 8 additions & 8 deletions controllers/authorApiRouter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const authorApiRouter = require('express').Router()
const authorApiRouter = require("express").Router();

authorApiRouter.get('/', (request, response) => {
response.json({
authors: "Alok Kumar Sahoo 😉, Rajarshee Basu 😋, Abhipsa Mohapatra 🤭",
message: "The API Works! 🎊"
})
})
authorApiRouter.get("/", (request, response) => {
response.json({
authors: "Alok Kumar Sahoo 😉, Rajarshee Basu 😋, Abhipsa Mohapatra 🤭",
message: "The API Works! 🎊",
});
});

module.exports = authorApiRouter
module.exports = authorApiRouter;
50 changes: 25 additions & 25 deletions models/assignmentModel.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const mongoose = require('mongoose');
const mongoose = require("mongoose");

const assignmentSchema = mongoose.Schema({
assignmentId: {
type: int,
required: true,
},
assignmentName: {
type: String,
required: true,
},
grade: {
type: String,
required: true,
},
dateDue: {
type: Date,
required: true,
},
course: {
type: mongoose.Schema.ObjectId,
ref: 'Course',
},
student: {
type: mongoose.Schema.ObjectId,
ref: 'Student',
},
assignmentId: {
type: int,
required: true,
},
assignmentName: {
type: String,
required: true,
},
grade: {
type: String,
required: true,
},
dateDue: {
type: Date,
required: true,
},
course: {
type: mongoose.Schema.ObjectId,
ref: "Course",
},
student: {
type: mongoose.Schema.ObjectId,
ref: "Student",
},
});
28 changes: 14 additions & 14 deletions models/branchModel.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const mongoose = require('mongoose')
const mongoose = require("mongoose");

const branchSchema = mongoose.Schema({
branchId: {
type: String,
required: true
},
branchName: {
type: String,
required: true
},
branchProgramme: {
type: String,
required: true
}
})
branchId: {
type: String,
required: true,
},
branchName: {
type: String,
required: true,
},
branchProgramme: {
type: String,
required: true,
},
});
36 changes: 18 additions & 18 deletions models/courseModel.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const mongoose = require('mongoose')
const mongoose = require("mongoose");

const courseSchema = mongoose.Schema({
courseId: {
type: String,
required: true
},
courseName: {
type: String,
required: true
},
courseCredits: {
type: Number,
required: true
},
courseMarks: {
type: mongoose.Schema.Types.ObjectId,
ref: 'theoryMarks'
}
})
courseId: {
type: String,
required: true,
},
courseName: {
type: String,
required: true,
},
courseCredits: {
type: Number,
required: true,
},
courseMarks: {
type: mongoose.Schema.Types.ObjectId,
ref: "theoryMarks",
},
});
70 changes: 35 additions & 35 deletions models/facultyModel.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
const mongoose = require('mongoose');
const mongoose = require("mongoose");

const facultySchema = mongoose.Schema({
facultyId: {
type: String,
required: true,
},
facultyName: {
type: String,
required: true,
},
qualification: {
type: String,
required: true,
},
experience: {
type: String,
required: true,
},
phone: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
dateOfJoining: {
type: Date,
required: true,
},
coursesTeaching: [
{
type: mongoose.Schema.ObjectId,
ref: 'Courses',
},
],
facultyId: {
type: String,
required: true,
},
facultyName: {
type: String,
required: true,
},
qualification: {
type: String,
required: true,
},
experience: {
type: String,
required: true,
},
phone: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
dateOfJoining: {
type: Date,
required: true,
},
coursesTeaching: [
{
type: mongoose.Schema.ObjectId,
ref: "Courses",
},
],
});
64 changes: 32 additions & 32 deletions models/studentModel.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
const mongoose = require('mongoose')
const mongoose = require("mongoose");

const studentSchema = mongoose.Schema({
studentId: {
type: String,
required: true,
},
studentName: {
type: String,
required: true,
},
studentProgramme: {
type: String,
required: true,
},
studentBranch: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Branches',
},
studentStartYear: {
type: Number,
required: true,
},
studentEndYear: {
type: Number,
required: true,
},
studentCourses: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'Courses'
}
]
})
studentId: {
type: String,
required: true,
},
studentName: {
type: String,
required: true,
},
studentProgramme: {
type: String,
required: true,
},
studentBranch: {
type: mongoose.Schema.Types.ObjectId,
ref: "Branches",
},
studentStartYear: {
type: Number,
required: true,
},
studentEndYear: {
type: Number,
required: true,
},
studentCourses: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Courses",
},
],
});
32 changes: 32 additions & 0 deletions models/teacherModel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const mongoose = require("mongoose");

const teacherSchema = mongoose.Schema({
teacherId: {
type: String,
required: true,
},
teacherName: {
type: String,
required: true,
},
teacherMajorSubject: {
type: String,
required: true,
},
teacherFacultyBranch: {
type: mongoose.Schema.Types.ObjectId,
ref: "Branches",
},
teacherStartYear: {
type: Number,
required: true,
},
teacherPayrollAmount: {
type: Number,
required: true,
},
teacherPayDate: {
type: Date,
required: true,
},
});
10 changes: 5 additions & 5 deletions models/theoryMarkModel.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const mongoose = require('mongoose')
const mongoose = require("mongoose");

const theoryMarkModelSchema = mongoose.Schema({
midsemMarks: Number,
quizMarks: Number,
endsemMarks: Number,
})
midsemMarks: Number,
quizMarks: Number,
endsemMarks: Number,
});
24 changes: 12 additions & 12 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ const config = require("./utils/config");
const middleware = require("./utils/middleware");
const logger = require("./utils/logger");

const author = require('./controllers/authorApiRouter')
const author = require("./controllers/authorApiRouter");

logger.info("Connecting to", process.env.MONGO_URI);
mongoose
.connect(config.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
})
.then((res) => logger.info("Successfully connected to MongoDB Atlas"))
.catch((e) => logger.info("Something bad happened", e));
.connect(config.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
})
.then((res) => logger.info("Successfully connected to MongoDB Atlas"))
.catch((e) => logger.info("Something bad happened", e));

app.use(morgan("common"));
app.use(helmet());
app.use(cors());
app.use(express.json());

app.use('/authors', author)
app.use("/authors", author);

app.use(middleware.errorHandler)
app.use(middleware.unknownEndpoint)
app.use(middleware.errorHandler);
app.use(middleware.unknownEndpoint);

const PORT = config.PORT || 5000;
app.listen(PORT, () => {
console.log(`App listening on http://localhost:${PORT}/`);
console.log(`App listening on http://localhost:${PORT}/`);
});
16 changes: 8 additions & 8 deletions utils/config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
require('dotenv').config()
require("dotenv").config();

const PORT = process.env.PORT
const MONGO_URI = process.env.MONGO_URI
const NODE_ENV = process.env.NODE_ENV
const PORT = process.env.PORT;
const MONGO_URI = process.env.MONGO_URI;
const NODE_ENV = process.env.NODE_ENV;

module.exports = {
PORT,
MONGO_URI,
NODE_ENV,
}
PORT,
MONGO_URI,
NODE_ENV,
};
Loading