Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/duanedave/cms_api
https://github.com/duanedave/cms_api
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/duanedave/cms_api
- Owner: DuaneDave
- Created: 2023-12-04T15:06:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-07T14:54:31.000Z (about 1 year ago)
- Last Synced: 2024-10-24T14:19:55.998Z (2 months ago)
- Language: JavaScript
- Size: 77.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
**CMS_API** is a solution to the take home assignment given and a solution to the problem was done using popular design pattern in the industry such as MVC and the well known Repository design pattern.
Server
- Node Js
- Express
- Socket.io
- JWT
- Google OAuth
- etc..
Database
- Mongo DB
- Mongoose ODM
- **Authentication strategy using JWT and Google OAuth**
- **Real-time activities feed on the admin route**
- **CRUD operation on the post route**
- **CRUD operations on the category route**
- **CRUD operations on the user**
- **Database relationship**
- **Proper error handling of all requests**
- [Link To Documentation](https://documenter.getpostman.com/view/24263371/2s9YkgBjfH)
To get a local copy up and running, follow these steps.
### Prerequisites
In order to run this project you need:
- [Node.js](https://nodejs.dev/en/) installed
- VsCode or any other code editor installed
- Postman or any other API testing tool installed
### Setup
Clone this repository to your desired folder:
```sh
cd my-folder
git clone https://github.com/DuaneDave/CMS_API.git
```
```sh
create a .env file in the root directory and add the following variables
PORT = 8080
NODE_ENV = DEVELOPMENT
DB_URI = your mongo db URI
JWT_EXPIRES_TIME = 3d
JWT_SECRET = bdjbbiugiuwehohfibifhhwioufgwftu
COOKIE_EXPIRES_TIME = 3
RESET_PASSWORD_EXPIRES_TIME = 10
MAIL_USERNAME = your gmail address
MAIL_PASSWORD = your gmail password
OAUTH_CLIENTID = your google oauth client id
OAUTH_CLIENT_SECRET = your google oauth client secret
OAUTH_REFRESH_TOKEN = your google oauth refresh token
OAUTH_FROM_EMAIL = [email protected]
OAUTH_FROM_NAME = CMS_API
```
### Install
Install this project with:
```sh
cd CMS_API
npm install
```
### Usage
To run the project, execute the following command:
```sh
npm run dev to run the project in development mode
npm run prod to run the project in production mode
```
### Run checks on the activiy feed
You can utilize postman for hooking up with the socket at the backend. To do this, you need to send a post request to the following route
```sh
http://localhost:8080/api/v1/admin
```
Once the connection is successful, you can hook up on the following events
```sh
postDeleted
postCreated
postUpdated
categoryCreated
categoryUpdated
categoryDeleted
userCreated
userUpdated
```
- **Why did you use repository design pattern?**
Repository Pattern introduces an additional layer of abstraction, the benefits it provides in terms of maintainability, testability, and adaptability often outweigh the overhead. It's especially beneficial in larger applications where clear separation of concerns becomes crucial for long-term maintainability.
Reasons includes:
- Separation of Concerns:
- Following design patterns like the Repository Pattern aligns with best practices for structuring maintainable and scalable software. It makes your codebase more readable and easier for other developers to understand.
- Testability:
- The Repository Pattern makes it easier to mock dependencies for testing. This is especially useful in unit testing, where you want to isolate the system under test from its dependencies.
- Adaptability:
- The Repository Pattern makes it easier to swap out data sources. For example, you can easily replace a repository that fetches data from a remote server with one that uses a local database instead. This is especially useful when you want to write tests that don't touch the network or a database.
- Maintainability:
- The Repository Pattern makes it easier to maintain your codebase. For example, if you want to change the way you fetch data from a remote server, you only need to change the implementation of the repository. The rest of your codebase can remain the same.