HTTP API Reference

Last updated


This page lists every node-image-server HTTP endpoint and the behavior shared by all requests.

Endpoints


MethodPathDescriptionHandlerDetails
GET/c/img/{path}Fetch an image, converting on the fly and writing the cacheGetFromPath (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 trashDeleteFromPath (app/src/router/delete)Delete API
GET/check/stateHealth check, returns 200 ok——
GET/storage/image/...express.static serves files under storage/image/ directly (including upload/ and cache/)——
GET / POST / DELETEOther paths404 with text 404 Not Found——
HEADSame paths as GETAnswered by the GET routes, headers only——
OPTIONSAny pathExpress automatic reply: 200, Allow: GET,HEAD, body GET,HEAD——
PUT / PATCH / other methodsAny pathExpress default 404 ("Cannot {METHOD} {path}")——

{path} may contain / and maps to a path relative to storage/image/upload/.

Shared Behavior


ItemBehaviorImplementation
User-AgentRequests without a User-Agent header have their socket destroyed with no responsemiddlewares/dataInit.ts
CORSAccess-Control-Allow-Origin: *, allowing GET,PUT,PATCH,POST,DELETEmiddlewares/cors.ts
Request logWritten to storage/logs/req.log (rotated every 3 days) with Taipei time, status, country, IP, method, URL, duration, referrermiddlewares/logger.ts
Error formatSuccess responses are JSON; errors are plain-text messagesEach handler

Routing Through Nginx


PathUpstreamCaching
/c/img/nodejs:8080proxy_cache
/upload/, /del/, everything elsenodejs:3000Not cached
Path segments starting with . (e.g. /.trash)Denied—

Upstream ports must match NODE_PORT; see Configuration.
中文