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

Biweekly Merge #450

Merged
merged 46 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
19550ef
minor_typo corrected
callistox9 Oct 22, 2023
8b362d7
Merge pull request #416 from callistox9/typo_readme
TejasNair9977 Oct 22, 2023
7537299
added mock data for accred, org, infra, department, topics, modules, …
TejasNair9977 Oct 24, 2023
0628964
docker compose added for handling replicaSets
Gauravpadam Oct 26, 2023
b60d7c2
fixed dockerfile
TejasNair9977 Oct 27, 2023
7c49e5a
used mongo instead of bitnami
TejasNair9977 Oct 27, 2023
4c412ed
added .env back to dockerignore
TejasNair9977 Oct 28, 2023
5118489
Merge pull request #417 from Gauravpadam/20232610_docker_compose_for_…
TejasNair9977 Oct 28, 2023
cac9c58
added faker for courses and everything under
TejasNair9977 Oct 28, 2023
9fb5d9e
completed course additions for placeholder data
TejasNair9977 Oct 28, 2023
186eb66
Merge pull request #418 from tcet-opensource/414-filldbwithplaceholde…
kskarthik5 Oct 28, 2023
1c4b14d
Initialize-all-the-test-data-in-setup.js-using-spawn
Oct 29, 2023
57e05c8
Fixed the error while closing the child process
Oct 29, 2023
0f63d5b
feat: added validation to exam controller
Shubhangam333 Oct 29, 2023
ff1d374
Merge pull request #437 from tcet-opensource/feat-436-Initialize-all-…
TejasNair9977 Oct 29, 2023
80e0d14
made middleware more portable and usable
TejasNair9977 Oct 29, 2023
795addf
Merge pull request #438 from Shubhangam333/devteam
TejasNair9977 Oct 29, 2023
0b2046e
Rename EntityIdValidation.js to entityIdValidation.js
TejasNair9977 Oct 29, 2023
db5e13e
used middleware validate service for validating ids in controller's c…
Aastha-S-Rai Oct 31, 2023
eea7c70
Added validation for Student entity
harsh31dangi Oct 31, 2023
b5767ec
[Added]validation for group
shreyam462 Oct 31, 2023
61f8ac6
added validation for timetable
sumitst05 Nov 2, 2023
2ef73e0
fixed schema definition error in activity blueprint
sumitst05 Nov 2, 2023
15b64db
[added]
deepti-50 Nov 4, 2023
eb4bf72
Updated module.js
deepti-50 Nov 4, 2023
aab4309
Docker compose refining
Gauravpadam Nov 4, 2023
2461a04
fixed replica sets on docker-compose
TejasNair9977 Nov 5, 2023
6233d2b
added mocks for even more models
TejasNair9977 Nov 6, 2023
03684f0
Create deploy.yml
harshau007 Nov 6, 2023
403e24b
added all remaining mockDBs
TejasNair9977 Nov 6, 2023
a181113
resolved a stupid merge im so dumb
TejasNair9977 Nov 6, 2023
24d22da
fixed small error with activity
TejasNair9977 Nov 6, 2023
d98dfbe
Rename deploy.yml to dockerhub.yml
harshau007 Nov 7, 2023
b7b9c88
added a mongo memory server for testing
TejasNair9977 Nov 8, 2023
52d2fb0
Merge pull request #446 from tcet-opensource/mockhotfix
TejasNair9977 Nov 8, 2023
4af0b36
Merge branch 'development' into 20233110_docker_compose_refining
TejasNair9977 Nov 8, 2023
83418f3
Merge pull request #445 from Gauravpadam/20233110_docker_compose_refi…
TejasNair9977 Nov 8, 2023
1956e3b
Merge pull request #447 from harshau007/dockerhub-img-upload
TejasNair9977 Nov 8, 2023
81a3509
Merge pull request #444 from tcet-opensource/426-added-validation-for…
TejasNair9977 Nov 8, 2023
0f0e834
Merge pull request #440 from harsh31dangi/430-Student-Validation
TejasNair9977 Nov 8, 2023
22235ee
Merge pull request #439 from tcet-opensource/420-feat-add-validation-…
TejasNair9977 Nov 8, 2023
aabfee3
Merge pull request #441 from tcet-opensource/425-add-validation-for-g…
TejasNair9977 Nov 8, 2023
641e092
Merge branch 'development' into validation-for-timetable
TejasNair9977 Nov 8, 2023
7633aaf
Merge pull request #442 from tcet-opensource/validation-for-timetable
TejasNair9977 Nov 8, 2023
411b5a0
fixed all testcases
TejasNair9977 Nov 8, 2023
09824b0
Merge pull request #449 from tcet-opensource/testcasehotfix
TejasNair9977 Nov 8, 2023
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
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
coverage
logs
.env
.env
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PORT=4000
TOKEN_SECRET=mysecret
ENVIRONMENT=local
DB_URL=mongodb://mongo1:30001,mongo2:30002,mongo3:30003/?replicaSet=my-replica-set
EMAIL_HOST=
EMAIL_PORT=
EMAIL_USER=
EMAIL_PASS=

# get email stuff from mailtrap
8 changes: 5 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -22,14 +22,16 @@ module.exports = {
"alias": {
"map": [
["#app", "./app.js"],
["#util", "./util.js"],
["#constant", "./constant.js"],
["#util", "./misc/util.js"],
["#constant", "./misc/constant.js"],
["#routes", "./routes"],
["#models", "./models"],
["#middleware", "./middleware"],
["#controller", "./controller"],
["#services", "./services"],
["#error", "./error"]
["#error", "./error"],
["#misc", "./misc"],
["#mockDB", "./misc/mockDB"]
],
"extensions": [".js"]
}
25 changes: 25 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dockerhub

on:
push:
branches:
- main
workflow_dispatch:

permissions:
contents: read

jobs:
test:
name: Uploading Img
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Building Docker Image
run: docker build -t ${{ secrets.username }}/erp-backend:prod .
- name: DockerHub Login
run: docker login -u ${{ secrets.username }} -p ${{ secrets.pass }}
- name: Uploading Image to DockerHub
run: docker push ${{ secrets.username }}/erp-backend:prod
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -130,4 +130,7 @@ dist
.pnp.*

# ingore genrated APIdocs
apidoc
apidoc

# data generated by mongo replicas
data/
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ RUN npm ci

COPY . .

EXPOSE 3500
CMD ["npm", "run", "start"]
EXPOSE 4000
CMD ["npm", "run", "serverstart"]


4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TCET ERP System

TCET ERP System is a project that aims to simplify and automate daily operation in TCET.
TCET ERP System is a project that aims to simplify and automate daily operations in TCET.

This ERP system will be used to manage various aspects of the operations of colleges, including admissions, registration, student records, financial aid, course scheduling, and fees. The ERP system would typically consist of multiple integrated modules that support these functions.

@@ -32,7 +32,7 @@ node -e "console.log(require('crypto').randomBytes(256).toString('base64'));
Set this on 'local'

`DB_URL`
For this parameter you will need to open your account on MongoDB Atlas, don't forget to note down you account password, then create new cluster and through that you will get your connection string which will be your DB_URL in .env, make sure instead of "password" in connection string, you enter your own account password.
For this parameter, you will need to open your account on MongoDB Atlas, don't forget to note down your account password, then create new cluster and through that you will get your connection string which will be your DB_URL in .env, make sure instead of "password" in connection string, you enter your own account password.

`EMAIL_HOST`,
`EMAIL_PORT`,
16 changes: 12 additions & 4 deletions _apidoc.js
Original file line number Diff line number Diff line change
@@ -172,6 +172,7 @@
* @apiBody {String} wing The wing where the infrastructure is located.
* @apiBody {Number} floor The floor where the infrastructure is located.
* @apiBody {Number} capacity The capacity of the infrastructure.
* @apiBody {connector.Schema.Types.ObjectId} organization The organization which is associated.
*
* @apiSuccess {String} res Success message with the ID of the added infrastructure.
*
@@ -198,6 +199,7 @@
* @apiSuccess {String} infrastructure.wing Wing of Infrastructure. One of possible A,B,C.
* @apiSuccess {Number} infrastructure.floor Floor of Infrastructure.
* @apiSuccess {Number} infrastructure.capacity Capacity of Infrastructure.
* @apiSuccess {connector.Schema.Types.ObjectId} department.organization associated Organization.
*/

/**
@@ -226,6 +228,7 @@
* @apiBody {String} [wing] The wing where the infrastructure is located.
* @apiBody {Number} [floor] The floor where the infrastructure is located.
* @apiBody {Number} [capacity] The capacity of the infrastructure.
* @apiSuccess {connector.Schema.Types.ObjectId} department.organization associated Organization.
*
* @apiSuccess {String} res infrastructure updated.
* @apiError (Error 500) err Error in updating database
@@ -432,6 +435,7 @@
* @apiBody {Date} yearOfStarting The year of establishment of the Department.
* @apiBody {connector.Schema.Types.ObjectId} accreditations The accreditation which is associated.
* @apiBody {connector.Schema.Types.ObjectId} infrastructure The infrastructure which is associated.
* @apiBody {connector.Schema.Types.ObjectId} organization The organization which is associated.
*
* @apiSuccess {String} res added Department successfully.
*
@@ -450,6 +454,7 @@
* @apiBody {Date} [yearOfStarting] The year of establishment of the Department.
* @apiBody {connector.Schema.Types.ObjectId} [accreditations] Accreditation which is associated.
* @apiBody {connector.Schema.Types.ObjectId} [infrastructure] Infrastructure which is associated.
* @apiBody {connector.Schema.Types.ObjectId} organization The organization which is associated.
*
* @apiSuccess {Department[]} res Array of Filtered Department Doc .
* @apiSuccess {String} department._id ID of document given by database.
@@ -458,6 +463,7 @@
* @apiSuccess {Date} department.yearOfStarting The year of establishment of the Department.
* @apiSuccess {connector.Schema.Types.ObjectId} department.accreditations associated Accreditation.
* @apiSuccess {connector.Schema.Types.ObjectId} department.infrastructure associatedInfrastructure.
* @apiSuccess {connector.Schema.Types.ObjectId} department.organization associated Organization.
* @apiError (Error 500) err Error while fetching the data.
*/

@@ -488,6 +494,7 @@
* @apiSuccess {Date} department.yearOfStarting The year of establishment of the Department.
* @apiSuccess {connector.Schema.Types.ObjectId} department.accreditations associated Accreditation.
* @apiSuccess {connector.Schema.Types.ObjectId} department.infrastructure associatedInfrastructure.
* @apiSuccess {connector.Schema.Types.ObjectId} department.organization associated Organization.
*
* @apiSuccess {String} res updated infrastructure with id.
* @apiError (Error 500) err Error while inserting in DB
@@ -655,8 +662,8 @@
*
* @apiQuery {Number} [no] Module number.
* @apiQuery {String} [name] Name of the module.
* @apiQuery {String} [outcome] Module outcome.
* @apiQuery {String[]} [contents] Array of contents of the module.
* @apiQuery {ObjectId} content ID of the Topics (ObjectId).
* @apiQuery {Number} [hrsPerModule] Number of hours required per module.
* @apiQuery {String[]} [cognitiveLevels] Array of cognitive levels
* of attainment as per Bloom's Taxanomy (L1-L6).
@@ -665,7 +672,6 @@
* @apiSuccess {String} module._id ID of document given by database.
* @apiSuccess {String} module.no Module number.
* @apiSuccess {String} module.name Name of the module.
* @apiSuccess {String} module.outcome Module outcome.
* @apiSuccess {String[]} module.contents Array of contents of the module.
* @apiSuccess {Number} module.hrsPerModule Number of hours required per module.
* @apiSuccess {String[]} module.cognitiveLevels Array of cognitive levels of
@@ -741,8 +747,8 @@
*
* @apiBody {Number} [no] Module number.
* @apiBody {String} [name] Name of the module.
* @apiBody {String} [outcome] Module outcome.
* @apiBody {String[]} [contents] Array of contents of the module.
* @apiBody {ObjectId} content ID of the Topics (ObjectId).
* @apiBody {Number} [hrsPerModule] Number of hours required per module.
* @apiBody {String[]} [cognitiveLevels] Array of cognitive levels
* of attainment as per Bloom's Taxanomy (L1-L6).
@@ -772,8 +778,8 @@
* @apiParam {String} moduleId The ID of the Module document to update.
* @apiBody {Number} [no] Module number.
* @apiBody {String} [name] Name of the module.
* @apiBody {String} [outcome] Module outcome.
* @apiBody {String[]} [contents] Array of contents of the module.
* @apiBody {ObjectId} content ID of the Topics (ObjectId).
* @apiBody {Number} [hrsPerModule] Number of hours required per module.
* @apiBody {String[]} [cognitiveLevels] Array of cognitive levels
* of attainment as per Bloom's Taxanomy (L1-L6).
@@ -1875,3 +1881,5 @@
* @apiError (Error 500) err Error in updating database
*
*/

// TODO ADD COURSE ENDPOINT APIDOCS
16 changes: 11 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ import groupRouter from "#routes/group";
import performarouter from "#routes/performance";
import notificationRouter from "#routes/notification";
import topicRouter from "#routes/topic";
import courseRouter from "#routes/course";
import activityBlueprintRouter from "#routes/activityBlueprint";

const app = express();
const currDirName = dirname(fileURLToPath(import.meta.url));
@@ -40,10 +42,12 @@ app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(morgan(
":remote-addr - :remote-user \":method :url HTTP/:http-version\" :status \":referrer\" \":user-agent\"",
{ stream: logger.stream },
));
app.use(
morgan(
":remote-addr - :remote-user \":method :url HTTP/:http-version\" :status \":referrer\" \":user-agent\"",
{ stream: logger.stream },
),
);

app.use(express.static(path.join(currDirName, "public")));

@@ -71,6 +75,8 @@ app.use("/semester", semesterRouter);
app.use("/faculty", facultyRouter);
app.use("/performance", performarouter);
app.use("/notification", notificationRouter);
app.use("/topic",topicRouter);
app.use("/topic", topicRouter);
app.use("/course", courseRouter);
app.use("/activityBlueprint", activityBlueprintRouter);

export default app;
2 changes: 0 additions & 2 deletions controller/activity.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ async function addActivity(req, res) {
const {
activityBlueprint,
startTime,
duration,
course,
faculty,
type,
@@ -22,7 +21,6 @@ async function addActivity(req, res) {
const newActivity = await createActivity(
activityBlueprint,
startTime,
duration,
course,
faculty,
type,
88 changes: 88 additions & 0 deletions controller/activityBlueprint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import {
createActivityBP,
updateActivityBlueprintById,
deleteActivityBlueprintById,
activityBlueprintList,
} from "#services/activityBlueprint";
import { logger } from "#util";

async function addActivityBP(req, res) {
const {
number,
academicYear,
day,
startTime,
duration,
infra,
course,
faculty,
type,
group,
} = req.body;
try {
const newActivityBP = await createActivityBP(
number,
academicYear,
day,
startTime,
duration,
infra,
course,
faculty,
type,
group,
);
return res.json({
res: `added activity ${newActivityBP.id}`,
id: newActivityBP.id,
});
} catch (error) {
logger.error("Error while inserting", error);
res.status(500);
return res.json({ err: "Error while inserting in DB" });
}
}

async function updateActivityBP(req, res) {
const { id } = req.params;
const { ...data } = req.body;
try {
await updateActivityBlueprintById(id, data);
return res.json({ res: `updated activity with id ${id}` });
} catch (error) {
logger.error("Error while updating", error);
res.status(500);
return res.json({ err: "Error while updating in DB" });
}
}

async function getActivityBP(req, res) {
try {
const filter = req.body;
const { limit, page } = req.query;
const activitylist = await activityBlueprintList(filter, limit, page);
return res.json({ res: activitylist });
} catch (error) {
logger.error("Error while fetching", error);
res.status(500);
return res.json({ err: "Error while fetching the data" });
}
}

async function deleteActivityBP(res, req) {
const { id } = req.params;
try {
await deleteActivityBlueprintById(id);
return res.json({ res: `Deleted activity with ID ${id}` });
} catch (error) {
logger.error("Error while deleting", error);
return res.status(500).json({ error: "Error while deleting from DB" });
}
}

export default {
addActivityBP,
deleteActivityBP,
getActivityBP,
updateActivityBP,
};
Loading