Align API metadata routes with standard
This commit is contained in:
@@ -3,5 +3,4 @@ SERVICE_BASE_URL=https://api.blackroad.systems
|
|||||||
CORE_BASE_URL=https://core.blackroad.systems
|
CORE_BASE_URL=https://core.blackroad.systems
|
||||||
OPERATOR_BASE_URL=https://operator.blackroad.systems
|
OPERATOR_BASE_URL=https://operator.blackroad.systems
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
NODE_ENV=development
|
|
||||||
PORT=8080
|
PORT=8080
|
||||||
|
|||||||
69
README.md
69
README.md
@@ -1,42 +1,42 @@
|
|||||||
# BlackRoad OS – Public API
|
# BlackRoad OS – Public API
|
||||||
|
|
||||||
Public API gateway for the BlackRoad Operating System. This service exposes common health/info endpoints and versioned API routes that coordinate with core BlackRoad services.
|
Public API gateway for the BlackRoad Operating System. This service fronts the platform's public-facing endpoints and relays metadata about the OS ecosystem services.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
- **Service Name:** BlackRoad OS – Public API
|
||||||
|
- **Service ID:** `api`
|
||||||
|
- **Base URL:** https://api.blackroad.systems
|
||||||
|
- **Default Port:** 8080
|
||||||
|
|
||||||
## Endpoints
|
## Endpoints
|
||||||
|
- `GET /health` – Liveness check returning service id and timestamp.
|
||||||
|
- `GET /info` – Service metadata including base URL, OS root, and version.
|
||||||
|
- `GET /version` – Service id and version from `package.json`.
|
||||||
|
- `GET /debug/env` – Safe subset of environment configuration.
|
||||||
|
- `GET /v1/ping` – Versioned ping endpoint for API consumers.
|
||||||
|
|
||||||
- `GET /health` – Liveness check
|
## Getting Started
|
||||||
- `GET /info` – Service metadata
|
1. Install dependencies
|
||||||
- `GET /version` – Version info
|
|
||||||
- `GET /debug/env` – Safe subset of environment values
|
|
||||||
- `GET /v1/ping` – Example API endpoint
|
|
||||||
|
|
||||||
## Running locally
|
|
||||||
|
|
||||||
1. Install dependencies:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
|
2. Run in development mode (with live reload)
|
||||||
2. Start the development server:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
3. Build for production
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
4. Start the compiled server
|
||||||
|
```bash
|
||||||
|
npm start
|
||||||
|
```
|
||||||
|
|
||||||
The API listens on `http://localhost:8080` by default.
|
The server listens on `http://localhost:8080` by default or `PORT` if provided.
|
||||||
|
|
||||||
## Build and start
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm run build
|
|
||||||
npm start
|
|
||||||
```
|
|
||||||
|
|
||||||
## Environment variables
|
|
||||||
|
|
||||||
See `.env.example` for defaults. Key values:
|
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
See `.env.example` for defaults:
|
||||||
- `OS_ROOT` – Base URL for the BlackRoad OS
|
- `OS_ROOT` – Base URL for the BlackRoad OS
|
||||||
- `SERVICE_BASE_URL` – External URL for this public API
|
- `SERVICE_BASE_URL` – External URL for this public API
|
||||||
- `CORE_BASE_URL` – Core service base URL
|
- `CORE_BASE_URL` – Core service base URL
|
||||||
@@ -44,18 +44,15 @@ See `.env.example` for defaults. Key values:
|
|||||||
- `LOG_LEVEL` – Logging verbosity
|
- `LOG_LEVEL` – Logging verbosity
|
||||||
- `PORT` – Port to bind (default `8080`)
|
- `PORT` – Port to bind (default `8080`)
|
||||||
|
|
||||||
## Tests
|
## Railway Deployment
|
||||||
|
`railway.json` is configured for deployment:
|
||||||
|
- Build: `npm install && npm run build`
|
||||||
|
- Start: `npm start`
|
||||||
|
- Port: `8080`
|
||||||
|
- Healthcheck: `/health`
|
||||||
|
|
||||||
|
## Testing
|
||||||
Run the test suite with:
|
Run the test suite with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm test
|
npm test
|
||||||
```
|
```
|
||||||
|
|
||||||
## Deployment (Railway)
|
|
||||||
|
|
||||||
Railway uses `railway.json`:
|
|
||||||
|
|
||||||
- Build: `npm install && npm run build`
|
|
||||||
- Start: `npm start`
|
|
||||||
- Healthcheck: `/health` on port `8080`
|
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ router.get("/debug/env", (req: Request, res: Response) => {
|
|||||||
env: {
|
env: {
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
OS_ROOT,
|
OS_ROOT,
|
||||||
LOG_LEVEL: process.env.LOG_LEVEL,
|
|
||||||
CORE_BASE_URL,
|
CORE_BASE_URL,
|
||||||
OPERATOR_BASE_URL,
|
OPERATOR_BASE_URL,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
import { Router, Request, Response } from "express";
|
import { Router, Request, Response } from "express";
|
||||||
import packageInfo from "../../package.json";
|
import packageInfo from "../../package.json";
|
||||||
import { SERVICE_ID, SERVICE_NAME } from "../config/serviceConfig";
|
import {
|
||||||
|
SERVICE_ID,
|
||||||
|
SERVICE_NAME,
|
||||||
|
SERVICE_BASE_URL,
|
||||||
|
OS_ROOT,
|
||||||
|
} from "../config/serviceConfig";
|
||||||
|
|
||||||
const router = Router();
|
const router = Router();
|
||||||
|
|
||||||
@@ -8,9 +13,10 @@ router.get("/info", (req: Request, res: Response) => {
|
|||||||
res.json({
|
res.json({
|
||||||
name: SERVICE_NAME,
|
name: SERVICE_NAME,
|
||||||
id: SERVICE_ID,
|
id: SERVICE_ID,
|
||||||
|
baseUrl: SERVICE_BASE_URL,
|
||||||
version: packageInfo.version,
|
version: packageInfo.version,
|
||||||
|
osRoot: OS_ROOT,
|
||||||
time: new Date().toISOString(),
|
time: new Date().toISOString(),
|
||||||
env: process.env.NODE_ENV || "development",
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user