We welcome all contributions to the Open Science Community in Saudi Arabia. The contribution can be an issue report or a pull request.
This project is meant to serve as the backend API for the MOOCs platform. The program aims to build an educational platform to serve courses and videos, where each course may have exercises attached.
The API is hosted for testing at https://moocs-test.onrender.com/
Documentation for consuming the API endpoints can be found here https://documenter.getpostman.com/view/20633788/2s8YemuZwv
- Node JS - Backend Environment
- Express JS - Framework for APIs
- Mongo DB - Non Relational Database
- Mocha - Framework for Unit tests
- Chai - Assertion library for Node
.....
backend_API/
-- node_modules/
-- src/
-- controllers/
-- auth.controllers.js
-- course.controllers.js
-- routes/
-- auth.routes.js
-- course.routes.js
-- routes_handler.js
-- models/
-- user.models.js
-- course.models.js
-- middlewares/
-- auth.js
-- error_handler.js
-- permission_handler.js
-- db/
-- test/
-- db.test.js
-- auth.test.js
-- utils/
-- async_wrapper.js
-- config.js
-- custom_errors.js
-- .env
-- .env.test
-- .env.dev
-- app.js
-- server.js
package-lock.json
package.json
- /src/controllers - API functions to implement major features like, uploading courses, deleting courses
- /src/routes - Contains API routes
- /src/models - Contains MongoDB schema models
- /src/middlewares - Contains express framework middlewares
- /src/utils - Contains utilities files for frequently imported API functions
- /src/db - Contains DB connection files
- /src/test - Contains files for unit tests
- controllers should have a suffix
.controllers.js
- route files should have a suffux
.routes.js
- models files should have a suffix
.model.js
Each route file should be imported to the routes_handler.js
file. The route_handler.js will have a uniform route path pattern. All routes will then be exported to the app.js
file
Route path format - /api/v1/<ROUTE GROUP>/<ROUTE ACTION>/
. v1 is the current API version
/api/v1/<ROUTE GROUP>/
prefix is applied in the routes_handler.js
file
ROUTE GROUPS includes - auth, course, exercise, question
- For
auth
routes group use/api/v1/auth/<ROUTE ACTION>
- For
course
routes group use/api/v1/course/<ROUTE ACTION>
- For
exercise
routes group use/api/v1/exercise/<ROUTE ACTION>
ROUTE ACTIONS may vary as the case may be, good examples of ROUTE ACTIONS are update new create
A good example of a complete route path is /api/v1/auth/signup
where auth
is the route group and signup
is the route action
- Open
Git bash
or any terminal inside the projects root directory - Navigate to the
backend_API
folder
cd backend_API
- Install dependencies
npm install
- To start the server locally, run
npm start
- All API request should be made to https://localhost:5555 or replace port with matching environment variable
- To run unit tests, run
npm test
-
Check that there isn't already an issue about your idea to avoid duplicating work.
- If there isn't one already, please create one so that others know you're working on it.
-
Fork the Open-Science-Community-Saudi-Arabia/MOOCs to your GitHub account.
-
Clone the forked repository on your local machine.
git clone https://github.com/<your-github-username>/MOOCs.git
- Sync the fork, to avoid merge conflicts.
git remote add upstream https://github.com/Open-Science-Community-Saudi-Arabia/MOOCs.git
git fetch upstream
git pull upstream main
git push
- From the dev_team2 branch, create a new branch with a different name.
git checkout dev_team2
git checkout -b <new-branch-name>
Your branch name should be descriptive enough, an example is feat-signpup
or fix-failed-login
-
Make the necessary changes and additions / subtractions within your forked repository.
-
Add and commit changes made.
git add .
git commit -m "commit message"
Your commit messages should be descriptive enough
- Push the changes to forked repository.
git push origin <branch-name>
- Submit a Pull Request against the
dev_team2
branch and wait for the code to be reviewed and merged.
If you're not used to this workflow with git, you can start with some basic docs from GitHub.