Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kostastepetes/your-own-api
🔗 The fast & simple approach on how to build your own API using Express.js
https://github.com/kostastepetes/your-own-api
api custom-api express-js
Last synced: about 1 month ago
JSON representation
🔗 The fast & simple approach on how to build your own API using Express.js
- Host: GitHub
- URL: https://github.com/kostastepetes/your-own-api
- Owner: kostastepetes
- Created: 2024-03-05T13:52:05.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-05T13:54:12.000Z (10 months ago)
- Last Synced: 2024-03-05T15:10:11.533Z (10 months ago)
- Topics: api, custom-api, express-js
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Article Management API
This Node.js application provides an API for managing articles. It allows users to perform CRUD (Create, Read, Update, Delete) operations on articles stored in a JSON file.
## Setup
1. Clone this repository.
2. Install dependencies using `npm install`.
3. Run the application using `node app.js`.## Endpoints
### All Articles
#### `GET /articles`
- Returns a JSON array of all articles.
#### `POST /articles`
- Creates a new article.
- Requires a JSON object with `title` and `content` fields in the request body.
- Example request body:
```json
{
"title": "New Article",
"content": "This is the content of the new article."
}
- Response: "Successfully added a new article."#### `DELETE /articles`
- Deletes all articles.
- Response: "Successfully deleted all the articles."### Individual Articles
#### `GET /articles/:articleTitle`
- Returns the article with the specified title.
- If no article is found, returns "No article with that title found."#### `PATCH /articles/:articleTitle`
- Updates the content of the article with the specified title.
- Requires a JSON object with `newContent` field in the request body.
- Response: "Successfully updated selected article."#### `PUT /articles/:articleTitle`
- Updates the content of the article with the specified title.
- Requires a JSON object with `newContent` field in the request body.
- Response: "Successfully updated the content of the selected article."#### `DELETE /articles/:articleTitle`
- Deletes the article with the specified title.
- Response: "Successfully deleted selected article."## Dependencies
- Express.js
- body-parser
- fs (File System)