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

[minor] schema refactoring and APIDOC setup #132

Merged
merged 67 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
eea008d
#54 updated installation guide and setup env file.
Aastha-S-Rai Jun 19, 2023
b6c3611
#54 minor changes in readme
Aastha-S-Rai Jun 19, 2023
7d15211
#54 Checking for readme file format
Aastha-S-Rai Jun 19, 2023
e04ed25
#54 checking for readme file format
Aastha-S-Rai Jun 19, 2023
88a2027
#54 testing the format of line break in readme
Aastha-S-Rai Jun 19, 2023
492d2e7
module schema and CURD operation parameters updated
Dhruvrg Jun 29, 2023
6e002c7
change uppercase to lowercase and used eslint
Dhruvrg Jun 29, 2023
e231ace
created a setup file to setup hook
Hitansh159 Jun 29, 2023
330241b
Merge pull request #107 from tcet-opensource/40-create_a_eslint_hook_…
TejasNair9977 Jun 29, 2023
608fe9c
Merge pull request #104 from tcet-opensource/103-Update_module_schema…
Hitansh159 Jun 29, 2023
304924b
fixed typo accreditionName to name
anipr2002 Jun 29, 2023
b1708c3
Change the name of the attribute
ANKIT638-ux Jun 29, 2023
09ded71
Merge branch 'development' of https://github.com/tcet-opensource/erp-…
ANKIT638-ux Jun 29, 2023
b1e392e
Merge pull request #111 from anipr2002/issue-109
Hitansh159 Jun 29, 2023
c466143
Merge branch 'development' of https://github.com/tcet-opensource/erp-…
ANKIT638-ux Jun 29, 2023
44facd9
Convert into lowercase
ANKIT638-ux Jun 29, 2023
f4a3bb7
setup for apidoc working
Hitansh159 Jun 29, 2023
e55b811
added _apidoc.js file to write all api docs
Hitansh159 Jun 29, 2023
962b6cd
removed _apidoc from eslint ignore
Hitansh159 Jun 29, 2023
e602821
Merge pull request #114 from tcet-opensource/113-Change_name_of_the_a…
Hitansh159 Jun 29, 2023
8f99a8b
removed eslintignore
Hitansh159 Jun 29, 2023
05572c4
Merge pull request #130 from tcet-opensource/129-setup_APIDOC
TejasNair9977 Jun 29, 2023
e67d856
creatre contribution.md
ANKIT638-ux Jun 30, 2023
98898dd
Addresed #69: Refactored and added crud ops to course.js (previously …
sumitst05 Jun 30, 2023
cd75bfc
Created assignment model
Dhruvrg Jun 30, 2023
b9f2c11
Created department model
Dhruvrg Jun 30, 2023
8d1a8ce
Created bug_report and feature-request file under ISSUE_TEMPLATE
VinitChawda06 Jun 30, 2023
ee619ae
created a tutorial model
deepti-50 Jun 30, 2023
708dff5
#73 refactor and add crud to organisation model
asthasingh182004 Jun 30, 2023
a388f41
[updated] attendance schema and crud
rahulsingh2312 Jun 30, 2023
e20750d
feat: Add infrastructure route, controller, model, and service files
Vikrantsingh22 Jun 30, 2023
0854fb5
updated array to enum
hricha11 Jun 30, 2023
9ea9565
#118 Added new files and add route in app file
Aastha-S-Rai Jun 30, 2023
f88a7b9
[Added]changes to 115- Refactor Group model
sanika-wani Jun 30, 2023
3745099
Merge branch 'development' of https://github.com/tcet-opensource/erp-…
Aastha-S-Rai Jun 30, 2023
e360bf7
#54 typo fix, added instruction to run setup.js
Aastha-S-Rai Jun 30, 2023
f275449
Create-practical-model
Abhishekgoyal007 Jul 1, 2023
5bd0d56
[ADDED] Test Cases Checking through github actions (#134)
harshau007 Jul 2, 2023
34e59bf
Add external contributor part
ANKIT638-ux Jul 2, 2023
124073d
Merge branch 'development' of https://github.com/tcet-opensource/erp-…
ANKIT638-ux Jul 2, 2023
1a62b68
Merge pull request #144 from tcet-opensource/138-Create_a_Assignment_…
Hitansh159 Jul 2, 2023
41f4f70
#69 made changes as requested in the review
sumitst05 Jul 2, 2023
e21fbfd
added array for infra and accreditation
Hitansh159 Jul 2, 2023
f1aeb72
Merge pull request #145 from tcet-opensource/59-Create_Department_model
Hitansh159 Jul 2, 2023
9efbd89
Merge pull request #143 from sumitst05/69-refactor-course-add-crud
Hitansh159 Jul 2, 2023
3084c3d
refactored the schema
Hitansh159 Jul 2, 2023
dc16395
Merge pull request #147 from deepti-50/140-Deepti-Singh
Hitansh159 Jul 2, 2023
95e1831
updated eslint script
Hitansh159 Jul 2, 2023
6f61778
Merge pull request #159 from tcet-opensource/158-update_eslint_script
Hitansh159 Jul 2, 2023
d6ce031
Merge pull request #148 from rahulsingh2312/110-Refactor-Attendance-m…
Hitansh159 Jul 2, 2023
24cb4ef
Merge pull request #149 from Vikrantsingh22/123-create_add_endpoint_f…
Hitansh159 Jul 2, 2023
c446336
removed eslint skipper
Hitansh159 Jul 2, 2023
b5d0a35
Merge pull request #150 from asthasingh182004/73-refractor-organizati…
Hitansh159 Jul 2, 2023
76063e2
Merge pull request #141 from tcet-opensource/95-create_Contribution.md
TejasNair9977 Jul 2, 2023
fdf28d0
changed type to array of object
Hitansh159 Jul 2, 2023
d7c0abb
Merge pull request #151 from avidavatar/139-refractor_module_model
Hitansh159 Jul 2, 2023
5ea1005
changed to array of student
Hitansh159 Jul 2, 2023
ac06611
Merge pull request #152 from sanika-wani/115-RefactorGroupmodel
Hitansh159 Jul 2, 2023
eda2eb9
Merge branch 'development' into 118-create-add-endpoint-for-accredita…
Hitansh159 Jul 2, 2023
e2db853
Merge pull request #153 from tcet-opensource/118-create-add-endpoint-…
Hitansh159 Jul 2, 2023
5e3b501
not required already configured
Hitansh159 Jul 2, 2023
11e3621
cognitive level converted to array
Hitansh159 Jul 2, 2023
e3b47f6
Merge pull request #156 from Abhishekgoyal007/135-Create_Practical_Model
Hitansh159 Jul 2, 2023
a75d96a
Merge pull request #154 from tcet-opensource/54-update-the-documentat…
Hitansh159 Jul 2, 2023
c15eb7f
Merge pull request #146 from tcet-opensource/131-Create_Issue_template
Hitansh159 Jul 2, 2023
c33f304
[ADDED] Added curd operation for Departemnt
skyline-r34v Jul 2, 2023
d0a4462
Merge pull request #160 from skyline-r34v/68-Create_CURD_Operation_fo…
Hitansh159 Jul 2, 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apidoc
65 changes: 65 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Bug Report
about: Use this template for reporting bugs.
title: "[Bug]: [DATE]"
labels: bug, needs triage
assignees: [your GitHub username]

---



<!--
🐞 Welcome to the Bug Report! 🐛

Please provide detailed information to help us identify and reproduce the issue you encountered.

Before you proceed, make sure to search existing issues to avoid duplicates.

Fill in the sections below. You can remove any sections that are not applicable to your bug report.

Please use the following format for the title: [Bug] Brief description of the issue

-->

## Description 📝

[Write a brief description of the issue here]

## Steps to Reproduce 🔄

[Outline the steps to reproduce the issue]

1. [Step 1]
2. [Step 2]
3. [Step 3]
...

## Expected Behavior ✨

[Describe what you expected to happen]

## Actual Behavior ❌

[Describe what actually happened]

## Screenshots 📷

[If applicable, add screenshots to help explain the issue]

## Environment 🌍

- Operating System: [e.g., Windows 10, macOS Big Sur]
- Browser/Device: [e.g., Chrome, iPhone 12]
- Version/Build: [e.g., 1.0.0, 2021-09-30]

## Additional Information ℹ️

[Add any additional information about the issue here]

<!--
🚨 Thank you for reporting the bug!
Your input helps us improve our application.
We will investigate the issue and provide updates as soon as possible.
-->

39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

name: Feature Request
about: Use this template for submitting new feature requests.
title: "[FEATURE NAME]: [DATE]"
labels: feature request, needs review
assignees: [your GitHub username]

---

# Feature Request

🎉 Thank you for taking the time to submit a feature request! 🎉

To help us better understand and prioritize your request, please provide the following information:

## Description

❓ Please provide a clear and concise description of the feature you are requesting. What problem does it solve or what improvement does it bring?

## Use Case

📚 Please provide a use case or scenario where this feature would be beneficial. How would you envision using this feature in your workflow?

## Proposed Solution

💡 If you have any ideas or suggestions on how this feature could be implemented, please share them here.

## Alternatives Considered

🔍 Have you considered any alternatives or workarounds to achieve the same goal? If so, please describe them.

## Additional Context

📝 Please provide any additional information, screenshots, or examples that can help us better understand your request.

---

Thank you for submitting your feature request! We appreciate your feedback and will carefully review your suggestions. Your input helps us improve our product and better meet the needs of our users.
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Testing Services

on:
pull_request:
branches:
- main
- development


env:
TOKEN_SECRET: ${{ secrets.TOKEN_SECRET }}
DB_URL: ${{ secrets.DB_URL }}

permissions:
contents: read

jobs:
test:
name: Testing files
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'
cache: npm
- name: Installation
run: npm ci
- name: Running Tests
run: npm run test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,5 @@ dist
.yarn/install-state.gz
.pnp.*

# ingore genrated APIdocs
apidoc
99 changes: 99 additions & 0 deletions Contribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Welcome to TCET Open Source contributing guide

Thank you for investing your time in contributing to our project!

In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, and merging the PR.


## New contributor guide

To get an overview and installation of the project, read the [README](README.md). Here are some resources to help you get started with open source contributions:

- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)


## Getting started

To navigate our codebase with confidence, see our [Github Repository](https://github.com/tcet-opensource/erp-backend)

## Issues


#### Asking to work on an issue

Scan through our [existing issues](https://github.com/tcet-opensource/erp-backend/issues) to find one that interests you. You can narrow down the search using `labels` as filters. See [Labels](https://github.com/tcet-opensource/erp-backend/labels) for more information. For contributing comment on that specific issue that you want to work on it and we will assign that specific issue to you. Please remember only start working on the issue after it is assigned to you.

#### Create a new issue

If you find a bug or want to add any sort of feature in the repository , [search if an issue already exists](https://github.com/tcet-opensource/erp-backend/issues). If a related issue doesn't exist, you can open a new issue using a relevant [issue form](https://github.com/tcet-opensource/erp-backend/issues/new). Please note that the name of the issue title should be relevant and should give an idea about what you are working on.


## Make Changes

### Make changes in the UI

Click **Make a contribution** at the bottom of erp-backend to make small changes such as a typo, sentence fix, or a broken link. This takes you to the `.md` file where you can make your changes and [create a pull request](#pull-request) for a review.


### Make changes locally

1. External Contributors , Fork the repository
- Using GitHub Desktop:
- [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop.
- Once Desktop is set up, you can use it to fork the repo
- Using the command line:
- [Fork the repo](https://github.com/tcet-opensource/erp-backend/fork), so that you can make your changes without affecting the original project until you're ready to merge them.
- After forking clone the forked repository
- Switch from main branch to development branch in your cloned repository
- To switch to development write command `git remote add upstream <link of original repo>` and `git fetch upstream` in the terminal
- To install node modules use command `npm ci`
- Switch to Development Branch and create a working branch for each issue.
- To create a branch use command `git branch <name of the branch>`
- NOTE: The name of the branch should in the format of -> Issue number-name of the issue (eg: 50-create_CRUD_for_infra_model)
- Then from the development branch move to the branch created by using command `git checkout <branch name>`
- All changes on the code should be done on your specific branch
- Test your changes: After making your changes, it is crucial to thoroughly test them to ensure they function as intended and do not introduce any new bugs. Run any relevant tests or simulations and verify that the modified code performs correctly.
- Before pushing the changes sync fork in the forked repo and pull the changes before pushing
- After pushing go to the forked repository and press contribute and make a pull request

2. Internal Contributors, Clone the Repository
&nbsp;
`git clone -b development https://github.com/tcet-opensource/erp-backend.git`
- To install node modules use command `npm ci`
- Switch to Development Branch and create a working branch for each issue.
- To create a branch use command `git branch <name of the branch>`
- NOTE: The name of the branch should in the format of -> Issue number-name of the issue (eg: 50-create_CRUD_for_infra_model)
- Then from the development branch move to the branch created by using command `git checkout <branch name>`
- All changes on the code should be done on your specific branch
- Test your changes: After making your changes, it is crucial to thoroughly test them to ensure they function as intended and do not introduce any new bugs. Run any relevant tests or simulations and verify that the modified code performs correctly.


### Commit your changes
- Stage your changes: Use the git add command to stage the modified files for the commit. This marks the changes as ready to be included in the next commit.
`git add <file1> <file2> ...` or `git add .`
- Commit your changes: Create a commit to record your modifications with a meaningful commit message. This helps in tracking and understanding the purpose of the changes.
`git commit -m "relevant info of the change"`
- Before pushing the changes on the repository always remember to pull the code to avoid any merge conflicts
`git pull origin development`
- try pushing the code on the development branch and not directly to the main branch

### Push your Changes
- After committing your changes, you push them to a remote repository (in this case, your forked repository on GitHub) using the git push command. Pushing your changes uploads them to the remote repository, making them visible to others and allowing you to share your work.
`git push origin <branch name>`


### Pull Request

When you're finished with the changes, create a pull request, also known as a PR.
- Don't forget to link PR to issue by using "#" issue number , if you are solving one.
- Once you submit your PR, a team member will review your proposal. We may ask questions or request additional information.
- We may ask for changes to be made before a PR can be merged, either using suggested changes or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch.
- As you update your PR and apply changes, mark each conversation as resolved
- If you run into any merge issues, checkout this [git merge conflicts](https://github.com/skills/resolve-merge-conflicts) to help you resolve merge conflicts and other issues.

### Your PR is merged!

Congratulations , The TCET Open Source team thanks you.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ EXPOSE 3500
CMD ["npm", "run", "start"]



31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,38 @@ All the dependencies used in this project will be listed in the `package.json` f

## Installation

To start working on this project, follow the steps given above until you complete Step 4, then make a MongoDB Atlas database, get the connection URI, and save it as `DB_URL` in your `.env` file. Also, make sure to use
To start working on this project first you need to create `.env` file. This .env file will contain:

`PORT`
You can set it on any port number you want. `eg: 4000`

`TOKEN_SECRET` which you will get by running following line in terminal
```
node -e "console.log(require('crypto').randomBytes(256).toString('base64'));
```
to generate a token secret that you will use for JWT authentication, save it as `TOKEN_SECRET` in your `.env` file.
`ENVIRONMENT`
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.

`EMAIL_HOST`,
`EMAIL_PORT`,
`EMAIL_USER`,
`EMAIL_PASS`

Once you are done with this, install the packages through `npm i` and run the server with `npm run serverstart` or `npm run serverstartWin` depending on your operating system.
For these above parameters, first you need to open an account on any SMTP server, we use mailtrap, then start testing where you will see show credentials in which you will get all the values we need which are host, port, username and password.

You don't need to assign values to these parameters in double or single quotes, just write directly, .env automatically converts it into quoted string.

Once you are done with this, install the packages through `npm ci` which stands for clean install.
Also, you need to run 'setup.js' file. You can do that by running following command in your terminal
```
node setup.js
```
And finally, run the server with `npm run serverstart` or `npm run serverstartWin` depending on your operating system.

## Contributing
## How to Contribute

1. Choose an issue, bug, exploit, or feature to work on: Start by identifying an issue or feature in the repository that you would like to work on. If you can't find an existing issue or feature, you can create a new one.

Expand Down
19 changes: 19 additions & 0 deletions _apidoc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// ------------------------------------------------------------------------------------------
// General apiDoc documentation blocks and old history blocks.
// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------
// Current Success.
// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------
// Current Errors.
// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------
// Current Permissions.
// ------------------------------------------------------------------------------------------

// ------------------------------------------------------------------------------------------
// History.
// ------------------------------------------------------------------------------------------
5 changes: 5 additions & 0 deletions apidoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "ERP-backend",
"version": "0.1.0",
"description": "TCET ERP System is a project that aims to simplify and automate daily operation in TCET."
}
4 changes: 4 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { logger } from "#util";
import indexRouter from "#routes/index";
import usersRouter from "#routes/users";
import authRouter from "#routes/auth";
import accreditationRouter from "#routes/accreditation";
import infrastructureRouter from "#routes/infrastructure";

const app = express();
const currDirName = dirname(fileURLToPath(import.meta.url));
Expand All @@ -26,5 +28,7 @@ app.use(express.static(path.join(currDirName, "public")));
app.use("/", indexRouter);
app.use("/users", usersRouter);
app.use("/auth", authRouter);
app.use("/accreditation", accreditationRouter);
app.use("/infrastructure", infrastructureRouter);

export default app;
19 changes: 19 additions & 0 deletions controller/accreditation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { addNewAccreditation } from "#services/accreditation";
import { logger } from "#util";

async function addAccreditation(req, res) {
const {
name, agencyName, dateofAccreditation, dateofExpiry,
} = req.body;
try {
// eslint-disable-next-line max-len
const accreditation = await addNewAccreditation(name, agencyName, dateofAccreditation, dateofExpiry);
res.json({ res: `added accreditation ${accreditation.name}` });
} catch (error) {
logger.error("Error while inserting", error);
res.status(500);
res.json({ err: "Error while inserting in DB" });
}
}

export default { addAccreditation };
18 changes: 18 additions & 0 deletions controller/infrastructure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createinfrastructure } from "#services/infrastructure";
import { logger } from "#util";

async function addinfrastructure(req, res) {
const {
name, type, wing, floor, capacity,
} = req.body;
try {
const newinfrastructure = await createinfrastructure(name, type, wing, floor, capacity);
res.json({ res: `added user ${newinfrastructure.id}` });
} catch (error) {
logger.error("Error while inserting", error);
res.status(500);
res.json({ err: "Error while inserting in DB" });
}
}

export default { addinfrastructure };
10 changes: 10 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

for file in $(git diff --diff-filter=d --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | npm run eslint --stdin --stdin-filename "$file"
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1
fi
done
Loading