FastCRUDAPI is a versatile and robust CRUD API built with Node.js and Express. It supports two storage backends for different use cases:
- JSON-based API: Ideal for lightweight testing, utilizing local
.jsonfiles for data storage. - MongoDB-based API: Production-ready implementation with Mongoose, offering full security, validation, and monitoring.
Both versions are fully functional and organized in a clean project structure.
- Comprehensive RESTful endpoints for CRUD operations:
GET: Retrieve dataPOST: Create dataPUT: Update dataDELETE: Remove data
- Two independent storage backends:
- JSON-based: Lightweight file operations.
- MongoDB-based: Scalable, production-ready database operations.
- Helmet: Adds secure HTTP headers.
- CORS: Cross-origin request handling with a whitelist configuration.
- Rate Limiting: Prevents request flooding (100 requests per 15 minutes).
- Input Validation: Ensures safe data using
express-validator.
- Integrated with Prometheus and Grafana for detailed monitoring of system metrics.
/metricsendpoint for Node.js telemetry (CPU, memory, event loop).
http://localhost:5123 (configurable via .env file)
| Method | Endpoint | Description |
|---|---|---|
| GET | /items |
Retrieve all items |
| GET | /items/:id |
Retrieve a single item by ID |
| POST | /items |
Create a new item |
| PUT | /items/:id |
Update an existing item |
| DELETE | /items/:id |
Delete an item |
Request Body Example (for POST/PUT):
{
"name": "Example Item",
"value": "Some value"
}- Node.js (v14+ recommended)
- npm or yarn
- MongoDB (for MongoDB version)
-
Clone the repository:
git clone https://github.com/tslime/FastCRUDAPI.git cd FastCRUDAPI -
Install dependencies:
npm install
-
Configure environment variables:
- Copy the included
bridge.envfile:cp bridge.env .env
- Update the
.envfile with your desired configuration:PORT=5123 MONGO_URI=mongodb://127.0.0.1:27017/fastcrud
- Copy the included
- JSON-based API:
node server_jsondb.js
- MongoDB-based API:
node server_mgdb.js
- Prometheus: Scrapes metrics from
/metricsendpoint. - Grafana: Dashboards for observing API performance.
Example Prometheus configuration:
scrape_configs:
- job_name: 'fastcrudapi'
static_configs:
- targets: ['https://localhost:5123']