This project is a RESTful API for a blogging platform. It allows for the creation, reading, updating, and deletion of blog posts. Additionally, it provides features for user registration and authentication, as well as adding comments to posts.
- Blog post management:
- Create a new post
- Read details of a specific post
- Update an existing post
- Delete a post
- User registration and authentication:
- Register a new user
- Authenticate an existing user
- Add comments to blog posts
- Post listing:
- Get a list of all posts
- Filter posts by author
- Sort posts by date
- Post search:
- Search posts by title or content
- Proper error handling and data validation
- Node.js
- Express.js
- MySQL
- Sequelize
- Nodemon
- Docker
Before running the application, make sure you have the following prerequisites installed:
- Node.js
- Docker
Follow the steps below to set up and run the application:
- Clone the repository:
git clone https://github.com/luccarendall/blogs-api.git
- Navigate to the project directory:
cd blogs-api
- Install dependencies:
npm install
- Configure environment variables:
- Rename the .env.example file to .env.
- Edit the .env file and set appropriate values for the environment variables.
- Start the server:
npm start
The application is now running and can be accessed at the following endpoint: http://localhost:3000.
The API has the following endpoints:
GET /posts: Get a list of all blog posts. GET /posts/:id: Get details of a specific post. POST /posts: Create a new post. PUT /posts/:id: Update an existing post. DELETE /posts/:id: Delete a post. POST /users/register: Register a new user. POST /users/login: Authenticate a user. POST /posts/:id/comments: Add a comment to a post. GET /users/:id/posts: Get all posts from a specific user. GET /search/posts: Search posts by title or content.
Contributions Contributions are welcome! To contribute to the project, follow the steps below:
- Fork the repository.
- Create a branch for your feature:
git checkout -b my-feature
- Make necessary changes and commit:
git commit -m "My contribution"
- Push to the remote repository:
git push origin my-feature