A lightweight, auto-loading REST API built with Express.js that automatically registers endpoints from the file system. Features elegant documentation and error pages with consistent styling.
InuSoft API is a modern REST API implementation that automatically loads endpoints from the api/ directory. It features a clean documentation interface, automatic endpoint registration, and a service-layer architecture for better code organization.
- 🔄 Auto-Loading Endpoints: Automatically registers API endpoints from file structure
- 📚 Beautiful Documentation: Interactive API documentation with search functionality
- 🎨 Consistent Styling: Elegant UI with gradient themes and responsive design
- 🔧 Service Layer Architecture: Separated business logic for maintainability
- 📊 Request Logging: Automatic API request logging with response times
- 🚀 Error Handling: Custom 404 and 500 error pages with helpful UX
- ⚡ Lightweight: Minimal dependencies and fast performance
Restfull-Api/
├── api/ # API endpoints (auto-loaded)
│ ├── ai/ # AI-related endpoints
│ │ ├── gpt.js # GPT chat endpoint
│ │ └── write-cream.js # Content writing endpoint
│ └── random/ # Random data endpoints
│ └── bluearchive.js # Blue Archive related data
├── public/ # Static files
│ ├── index.html # API documentation
│ ├── 404.html # Custom 404 error page
│ └── 500.html # Custom 500 error page
├── src/
│ ├── app/ # Application configuration
│ │ ├── index.js # Main app setup
│ │ ├── middleware.js # Middleware configuration
│ │ └── responseFormatter.js # Response formatting
│ ├── services/ # Business logic layer
│ │ └── ai/
│ │ └── gptService.js # GPT service logic
│ └── utils/ # Utility functions
│ ├── loader.js # Auto-loading utility
│ ├── logger.js # Logging utility
│ ├── color.js # Console colors
│ └── logApiRequest.js # Request logging
├── server.js # Application entry point
├── package.json
└── vercel.json # Vercel deployment config
| Endpoint | Methods | Category | Description |
|---|---|---|---|
GET /api/ai/gpt |
GET, POST | AI | GPT chat completion endpoint |
GET /api/ai/write-cream |
GET, POST | AI | Content writing assistance |
GET /api/random/bluearchive |
GET | Random | Blue Archive related data |
GET /api/openapi.json |
GET | Documentation | API specification |
GET / |
GET | Documentation | Web interface |
Each endpoint file follows this structure:
export default {
name: "Endpoint Name",
description: "Endpoint description",
category: "Category",
methods: ["GET", "POST"], // Supported HTTP methods
params: ["param1", "param2"], // Expected parameters
paramsSchema: { // Optional parameter validation
param1: { type: "string", required: true }
},
async run(req, res) {
try {
// Your endpoint logic here
const result = await someService.process(req.query);
res.json({
success: true,
data: result,
timestamp: new Date().toISOString(),
attribution: "@synshin9"
});
} catch (error) {
res.status(500).json({
success: false,
error: error.message
});
}
}
}File: api/ai/gpt.js
import GptService from '../../src/services/ai/gptService.js';
export default {
name: "GPT Chat",
description: "Chat completion using GPT models",
category: "AI",
methods: ["GET", "POST"],
params: ["message", "model"],
async run(req, res) {
try {
const { message, model = "gpt-3.5-turbo" } = req.method === 'GET' ? req.query : req.body;
if (!message) {
return res.status(400).json({
success: false,
error: "Message parameter is required"
});
}
const result = await GptService.process(message, { model });
res.json({
success: true,
data: result
});
} catch (error) {
res.status(500).json({
success: false,
error: error.message
});
}
}
}File: src/services/ai/gptService.js
export class GptService {
static async process(message, options = {}) {
// Business logic implementation
return {
response: `Processed: ${message}`,
model: options.model || 'default',
timestamp: new Date().toISOString()
};
}
}
export default GptService;Setup and Installation
- Clone the repository
git clone https://github.com/synshin9/Restfull-Api.git cd Restfull-Api - Install dependencies
npm install
- Start the development server
npm run dev
- Access the API
- API Documentation: http://localhost:3000
- API Endpoints: http://localhost:3000/api/ai/gpt
- OpenAPI Spec: http://localhost:3000/api/openapi.json
The project includes vercel.json for zero-config deployment:
npm i -g vercel
vercelEnvironment Variables
Create a .env file for environment-specific configurations:
PORT=3000
NODE_ENV=productionAdding New Endpoints
- Create Endpoint File
Create a new JavaScript file in the api/ directory:
// api/weather/forecast.js
export default {
name: "Weather Forecast",
description: "Get weather forecast for a location",
category: "Weather",
methods: ["GET"],
params: ["city", "days"],
async run(req, res) {
try {
const { city, days = 7 } = req.query;
// Your implementation here
const forecast = await WeatherService.getForecast(city, days);
res.json({
success: true,
data: forecast
});
} catch (error) {
res.status(500).json({
success: false,
error: error.message
});
}
}
}- The endpoint will be automatically available at:
- GET /api/weather/forecast?city=London&days=5
All successful responses follow this format:
{
"statusCode": 200,
"success": true,
"data": {
"response": "Your data here"
},
"timestamp": "2023-01-01T00:00:00.000Z",
"attribution": "@synshin9"
}Error responses:
{
"statusCode": 400,
"success": false,
"error": "Error message description"
}The API includes comprehensive error handling:
- 400 Bad Request: Invalid parameters
- 404 Not Found: Endpoint not found
- 500 Internal Server Error: Server-side errors
Custom error pages are served for web requests.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add some amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- 📧 Email: admin@inusoft.xyz
- 💬 Telegram: t.me/synshin9
- Built with Express.js
- Styled with Tailwind CSS
- Icons from Material Icons
- Fonts from Google Fonts
InuSoft API • Modern REST API with Auto-Loading Endpoints