This is a TypeScript backend API built with Express.js. It provides endpoints for various functionalities including managing blogs, comments, subscriptions, contact us messages, and user authentication.
-
repository_url=https://github.com/ambroisegithub/MyBackendBlandTs.git
-
Hosted One=https://mybackendblandts.onrender.com/
-
Clone the repository:
git clone <repository_url>
-
Navigate to the project directory:
cd <project_directory>
-
Install dependencies:
npm install
Before running the application, make sure to set up the necessary environment variables. Create a .env
file in the root directory and define the following variables:
MONGODB_URL= PORT=9999 CLOUDINARYNAME= APIKEY=<.....> APISECRET=<.....> JWT_SECRET=<......> MONGODB_URL_TEST=<.....> PORT_TEST=7777
- api/v1
- api/blog
- Method: POST
- URL:
/post-blog
- Payload: FormData with 'blogImage' field and other blog details
- Middleware: Authorization
- Controller: BlogController.createBlog
- Method: PUT
- URL:
/update-blog/:id
- Payload: FormData with 'blogImage' field and other updated blog details
- Controller: BlogController.updateBlog
- Method: GET
- URL:
/getall-blog
- Controller: BlogController.getAllBlogs
- Method: GET
- URL:
/getone-blog/:id
- Controller: BlogController.getOneBlog
- Method: DELETE
- URL:
/delete-blog/:id
- Controller: BlogController.deleteBlog
- Method: POST
- URL:
/:blogId/comments
- Middleware: UserMiddleware
- Controller: CommentsLikesController.addComment
- Method: POST
- URL:
/:blogId/like
- Middleware: UserMiddleware
- Controller: CommentsLikesController.likeBlog
- Method: POST
- URL:
/post-contact-us
- Controller: ContactUsController.createContactUs
- Method: PUT
- URL:
/update-contact-us/:id
- Controller: ContactUsController.updateContactUs
- Method: GET
- URL:
/getall-contact-us
- Controller: ContactUsController.getAllContactUs
- Method: GET
- URL:
/getone-contact-us/:id
- Controller: ContactUsController.getOneContactUs
- Method: DELETE
- URL:
/delete-contact-us/:id
- Controller: ContactUsController.deleteContactUs
- Method: POST
- URL:
/post-subscribe
- Controller: SubscribeController.createSubscribe
- Method: PUT
- URL:
/update-subscribe/:id
- Controller: SubscribeController.updateSubscribe
- Method: GET
- URL:
/getall-subscribe
- Controller: SubscribeController.getAllSubscriptions
- Method: GET
- URL:
/getone-subscribe/:id
- Controller: SubscribeController.getOneSubscription
- Method: DELETE
- URL:
/delete-subscribe/:id
- Controller: SubscribeController.deleteSubscription
- Method: POST
- URL:
/signup
- Controller: UserController.createUser
- Method: GET
- URL:
/all
- Controller: UserController.getAllUsers
- Method: GET
- URL:
/:id
- Controller: UserController.getUserById
- Method: PUT
- URL:
/:id
- Controller: UserController.updateUser
- Method: DELETE
- URL:
/:id
- Controller: UserController.deleteUser
- Method: POST
- URL:
/login
- Controller: UserController.loginUser
To run the application, execute the following command:
npm run start:dev
The API will start listening on the configured port (default: 3000).
Author
[Your Name]
Replace `<repository_url>` with the URL of your Git repository, and `[Your Name]` with your name or your team's name.
This README provides a comprehensive guide on how to set up, configure, run, and use your backend TypeScript API, including detailed information about each endpoint.