Starter Kit for building modern RESTful APIs with scalable ๐๏ธ, modular ๐งฉ, and secure ๐ architecture. Suitable for use as an initial foundation for developing small to large scale backend applications, equipped with various built-in features that are ready to use ๐งฐ and easy to develop further ๐ง.
JavaScriptMIT
๐ RESTful-API Starter Kit
Starter Kit for building modern RESTful APIs with scalable ๐๏ธ, modular ๐งฉ, and secure ๐ architecture. Suitable for use as an initial foundation for developing small to large scale backend applications, equipped with various built-in features that are ready to use ๐งฐ and easy to develop further ๐ง.
๐ Built-in Features
โ Authentication
๐งผ Input Validation & Sanitation
๐ Password Hashing
๐ JWT Token Auth
๐ Database Switching (MySQL / PostgreSQL)
๐งฉ Modular
๐ฆ ORM Sequelize
๐งฏ Handling errors
๐๏ธ Scalable Project Structure
๐ก๏ธ Rate Limiting
๐ Security Headers
โก Redis Caching
โค๏ธ Health Check & Monitoring
๐ Asynchronous Task Handling (Bull Queue)
๐ฅ Upload File Handlers
๐ Graceful Shutdown
๐๏ธ Request Profiling
๐ HTTP Compression
๐จ Anomaly Detection
๐ Webhook
Quick Start
git clone https://github.com/fitri-hy/restfull-api-starter-nodejs.git
cd restfull-api-starter-nodejs
cp .env.example .env
npm install
npm run dev
๐งพ Configuration .env Variables
Variable
Function
HOST
Server host address
PORT
Port number the application listens on
NODE_ENV
Application mode (development / production)
API_KEY_ENABLE
Enable API key protection
API_KEY
API key value for authentication
CORS_ORIGIN
Allowed origin domain for API access (CORS)
DB
Database type (mysql / postgres)
DB_HOST
Database host address
DB_USER
Database username
DB_PASS
Database password
DB_NAME
Database name
DB_PORT
Database port number
WEBHOOK_ENABLE
Enable webhook notifications
WEBHOOK_URL
Webhook target URL
JWT_SECRET
Secret key to generate JWT tokens
JWT_EXPIRATION
JWT token expiration time (e.g., 1h, 30m)
RATE_LIMIT_MAX
Maximum number of requests before rate limiting
RATE_LIMIT_WINDOW_MS
Rate limit window in milliseconds
REDIS_CACHE_ENABLE
Enable Redis caching
REDIS_TASK_ENABLE
Enable Redis task queue
REDIS_HOST
Redis host address
REDIS_PORT
Redis port number
REDIS_TTL
Time-to-live (TTL) for Redis cache (in seconds)
FILE_MAX_SIZE
Maximum file upload size (in bytes)
FILE_UPLOAD_PATH
Directory path for file uploads
FILE_ALLOWED_TYPES
Allowed file types for upload
COMPRESSION_ENABLE
Enable response compression
COMPRESSION_THRESHOLD
Minimum response size to be compressed
COMPRESSION_LEVEL
Compression level (0-9)
ANOMALY_ENABLED
Enable anomaly detection for requests
ANOMALY_TIME
Time interval for detecting anomalies (in milliseconds)
ANOMALY_REQUEST
Number of suspicious requests before being flagged as an anomaly
ANOMALY_URL_LENGTH
Maximum URL length for anomaly detection
๐ Status Monitoring
Endpoint
GET http://localhost:5000/status
๐ Task Handling
Endpoint
POST http://localhost:5000/api/v1/tasks/add
Header Request (If using ApiKey)
Key
Value
x-api-key
my_secret_api_key
๐ง Redis Caching
Endpoint
GET http://localhost:5000/api/v1/data/:key
Header Request (If using ApiKey)
Key
Value
x-api-key
my_secret_api_key
๐ค Example Case (Login, Register, Get All User, User Detail, Edit User Detail)
For testing purposes, you can import the sample.sql sample file available in the /src/config/sample.sql directory.