Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cynthiawahome/node-replit-library-backend
This Node.js API manages a list of books using the Replit database. It provides endpoints to create, read, update, and delete books, as well as clear the entire database. The project is beginner-friendly, built with Express, and includes installation instructions for easy setup.
https://github.com/cynthiawahome/node-replit-library-backend
Last synced: 10 days ago
JSON representation
This Node.js API manages a list of books using the Replit database. It provides endpoints to create, read, update, and delete books, as well as clear the entire database. The project is beginner-friendly, built with Express, and includes installation instructions for easy setup.
- Host: GitHub
- URL: https://github.com/cynthiawahome/node-replit-library-backend
- Owner: CynthiaWahome
- Created: 2024-09-08T17:02:13.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2024-09-09T09:39:17.000Z (2 months ago)
- Last Synced: 2024-09-09T19:38:29.517Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node.js Book Library API
This is a simple Node.js API built using Express and the Replit database. The API allows for CRUD (Create, Read, Update, Delete) operations on a collection of books.
## Features
- Create a new book entry
- Retrieve all book entries
- Retrieve a single book entry by ID
- Update an existing book entry
- Delete a book entry
- Clear the entire database## Prerequisites
Ensure you have the following installed:
- [Node.js](https://nodejs.org/) (version 12 or later)
- [NPM](https://www.npmjs.com/) (comes with Node.js)
- [Replit Database](https://www.npmjs.com/package/@replit/database)## Installation
1. Clone the repository or download the project files.
2. Navigate to the project directory.
3. Install the dependencies using npm:```bash
npm install
```The Replit database package is included in the dependencies section of the package.json, so it will be installed automatically when you run npm install.
## Scripts
- **Start the Server:** Start the Node.js server using the following command:
```bash
npm start
```- **Development Mode:** Start the server with Nodemon for automatic restarting:
```bash
npm run dev
```## API Endpoints
### Get All Books
- **Endpoint:** `GET /api/books`
- **Description:** Retrieves all books from the database.### Get a Single Book
- **Endpoint:** `GET /api/books/:id`
- **Description:** Retrieves a single book by its ID.### Create a New Book
- **Endpoint:** `POST /api/books`
- **Description:** Adds a new book to the database.
- **Payload:**
```json
{
"id" : "1",
"title": "Book Title",
"author": "Author Name"
}
```### Update a Book
- **Endpoint:** `PUT /api/books/:id`
- **Description:** Updates the details of an existing book.
- **Payload:**
```json
{
"id" : "1",
"title": "Updated Title",
"author": "Updated Author"
}
```### Delete a Book
- **Endpoint:** `DELETE /api/books/:id`
- **Description:** Deletes a book by its ID.### Clear the Database
- **Endpoint:** `DELETE /api/delete-database`
- **Description:** Deletes all book entries from the database.## Dependencies
- **Express**: Web framework for Node.js
- **@replit/database**: Replit database client
- **Nodemon**: Tool for monitoring changes in your Node.js applications (development dependency)## License
This project is licensed under the ISC License.
## Notes
This project is a beginner-friendly introduction to using Express and the Replit database in a Node.js application.
Make sure to monitor your database usage to avoid exceeding any limits on the Replit platform.```