A RESTful API template to be able to integrate your API with API HUB.
The API is available at:
- Development:
http://localhost:3005
- Node.js (v20 or later recommended)
- pnpm
-
Clone the repository:
git clone <repository-url> cd api-template
-
Install dependencies:
pnpm install
Development Mode (with hot-reloading):
pnpm run dev
The API will be available at http://localhost:3005
. Nodemon will automatically restart the server when you make changes to the source code.
Production Mode:
-
Build the TypeScript code:
pnpm run build
-
Start the server:
pnpm start
The API will be available at
http://localhost:3005
.
Requests to the API endpoints (prefixed with /api
) require a Bearer token to be included in the request headers.
Use the Authorization
header with the Bearer scheme to send your token:
Authorization: Bearer YOUR_TOKEN
Replace YOUR_TOKEN
with your actual API token. The valid tokens are configured through the API_KEYS
environment variable.
Create a .env
file in the root of the project with the following variables:
API_KEYS=your_token_here,another_token_here
You can add multiple tokens by separating them with commas. For development purposes, you can use the example tokens provided in .env.example
.