Skip to content

Commit

Permalink
Merge pull request #450 from tcet-opensource/development
Browse files Browse the repository at this point in the history
Biweekly Merge
  • Loading branch information
TejasNair9977 authored Nov 9, 2023
2 parents aa2379a + 09824b0 commit 0f4da0a
Show file tree
Hide file tree
Showing 102 changed files with 3,943 additions and 459 deletions.
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
Expand Up @@ -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"]
}
Expand Down
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
Expand Up @@ -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
Expand Up @@ -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.

Expand Down Expand Up @@ -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`,
Expand Down
16 changes: 12 additions & 4 deletions _apidoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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.
*/

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
Expand All @@ -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.
*/

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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).
Expand All @@ -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
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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
Expand Up @@ -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));
Expand All @@ -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")));

Expand Down Expand Up @@ -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
Expand Up @@ -10,7 +10,6 @@ async function addActivity(req, res) {
const {
activityBlueprint,
startTime,
duration,
course,
faculty,
type,
Expand All @@ -22,7 +21,6 @@ async function addActivity(req, res) {
const newActivity = await createActivity(
activityBlueprint,
startTime,
duration,
course,
faculty,
type,
Expand Down
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

0 comments on commit 0f4da0a

Please sign in to comment.