This Reposository hosts the backend of Easy Help web app. It is done using NodeJs and ExpressJs. It is tested using Mocha, Chai and Jest with nearly 82% coverage. This project uses MongoDB for database management. Bellow is a detailed file structure description as well as explanation of app and API flow.
To run the application on your machine, follow the steps below:
git clone https://github.com/EasyHelpV1/SP-Backend.git
npm install
JWT_SECRET
: This token is used to verify authentication of users and admins.JWT_LIFETIME
: JWT token expiration period. I set it up for 2d
but other values are possible. MONGO_URL
: URL for your database on MongoDBmongodb+srv://<yourUsername>:<yourPassword>@nodeexpressproject.eiqifly.mongodb.net/<yourDBName>?retryWrites=true&w=majority
MONGO_URL_TEST
: Similar to MONGO_URL but is a new database built specifcally for testing.LINK_ADDRESS
: API address after hosting, currently is https://sp-backend-b70z.onrender.com/api/v1LINK_ADDRESS_FRONT
Frontend address after hosting, currently is https://sp-frontend-6181.onrender.comAPP_EMAIL
: easyhelp.com@gmail.comAPP_PASS
: password for email account app that is used to automatically send emails to users after registration.VALID_PASS
: a user account password, used for testing.npm start
npm test
npm run coverage
This application uses the MVC model for program organization, which results in having controllers folder for the functionality of the app, models for the database structure and components, and views which revolves around the user interaction with the app.
Database connection, and configuration.
Error handling setup, including a custom error, with children of Not Found error, Bad Request, and Unauthenticated.
Middlewares used throught the application routes:
The database model for each of the elements in the project according to MongoDB collection and document structure. The collections for this project are: User, Post, Comment, Reply, and Img.
Application routes, each file has the routes corresponding to their specific controllers with similar naming covention. Routes categories include: admin, auth, user, posts, comments, replies, and images. Note that all routes are preceded with a common configuration "api/v1", and that is set up in the app.js file.
Includes the functionalities of the app that include interaction with external sources to provide convenience and security for the app. This currently includes email verification using Google emails.
This folder contains tests for routes and controllers of the application, as well as test configuration. To run the tests, use the commands provided above.
This is the entry point for the application, it has most of the imports, and the setup for all middleware, routes, and db connection start.
This file includes the configuration for the Node and Express project as well as the packages names, and versions and some of their configuration.