HTTP API Reference
Last updated
This page lists every node-image-server HTTP endpoint and the behavior shared by all requests.
Endpoints
| Method | Path | Description | Handler | Details |
|---|---|---|---|---|
GET | /c/img/{path} | Fetch an image, converting on the fly and writing the cache | GetFromPath (app/src/router/get) | Image Parameters |
POST | /upload/{path} | Upload a file to storage/image/upload/{path}/ | PostToPath (app/src/router/post) | Upload API |
DELETE | /del/{path} | Move a file or folder to today's trash | DeleteFromPath (app/src/router/delete) | Delete API |
GET | /check/state | Health check, returns 200 ok | — | — |
GET | /storage/image/... | express.static serves files under storage/image/ directly (including upload/ and cache/) | — | — |
GET / POST / DELETE | Other paths | 404 with text 404 Not Found | — | — |
HEAD | Same paths as GET | Answered by the GET routes, headers only | — | — |
OPTIONS | Any path | Express automatic reply: 200, Allow: GET,HEAD, body GET,HEAD | — | — |
PUT / PATCH / other methods | Any path | Express default 404 ("Cannot {METHOD} {path}") | — | — |
{path} may contain / and maps to a path relative to storage/image/upload/.Shared Behavior
| Item | Behavior | Implementation |
|---|---|---|
User-Agent | Requests without a User-Agent header have their socket destroyed with no response | middlewares/dataInit.ts |
| CORS | Access-Control-Allow-Origin: *, allowing GET,PUT,PATCH,POST,DELETE | middlewares/cors.ts |
| Request log | Written to storage/logs/req.log (rotated every 3 days) with Taipei time, status, country, IP, method, URL, duration, referrer | middlewares/logger.ts |
| Error format | Success responses are JSON; errors are plain-text messages | Each handler |
Routing Through Nginx
| Path | Upstream | Caching |
|---|---|---|
| /c/img/ | nodejs:8080 | proxy_cache |
/upload/, /del/, everything else | nodejs:3000 | Not cached |
Path segments starting with . (e.g. /.trash) | Denied | — |
Upstream ports must match
NODE_PORT; see Configuration.