Skip to content

Repository files navigation

Dynamic REST API Server

This server provides a dynamic REST API that can be configured through a JSON file. It's designed to support Android app development by allowing quick creation of new endpoints without server restarts.

Setup

  1. Install Node.js if you haven't already
  2. Install dependencies:
npm install
  1. Start the server:
npm run dev

The server will run on port 3000 by default.

Adding New Endpoints

To add new endpoints, modify the endpoints.json file. The server will automatically detect changes and update the available endpoints without requiring a restart.

Endpoint Configuration Format

{
  "endpoints": [
    {
      "url": "/api/your/endpoint",
      "method": "GET|POST|PUT|DELETE",
      "request": {
        "field1": "type",
        "field2": "type"
      },
      "response": {
        // Your response object structure
      }
    }
  ]
}

Example Endpoint Configuration

{
  "url": "/api/users",
  "method": "POST",
  "request": {
    "name": "string",
    "age": "number"
  },
  "response": {
    "status": "success",
    "data": {
      "id": 1,
      "name": "string",
      "age": "number"
    }
  }
}

Available Endpoints

  • GET /api/endpoints: Lists all registered endpoints
  • Other endpoints as configured in endpoints.json

Features

  • Dynamic endpoint creation without server restart
  • Automatic request validation based on schema
  • CORS enabled
  • JSON request/response format
  • Real-time endpoint updates

For Android Developers

When making requests from your Android app:

  1. Base URL: http://[server-ip]:3000
  2. All endpoints return JSON responses
  3. For POST/PUT requests, send JSON in the request body
  4. Check the /api/endpoints endpoint to see all available routes

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages