A Fastify 5 REST API starter for Node.js 22 in plain JavaScript, for developers who want a lean API skeleton with a single runtime dependency. It includes routes written as Fastify plugins, structured request logs from Fastify's built-in pino logger, a /health check and node:test tests that use app.inject().
by Light CloudREST APIs
Everything goes through buildApp(): the server calls it with the logger on and listens, while the tests call it with no logger and inject requests straight into the router. That split, plus Fastify's own JSON error replies, is why the starter needs no extra error middleware. The first change is usually a new plugin file next to src/routes/root.js with a JSON schema on each route, which Fastify uses to validate bodies and answer 400 on a mismatch. On Light Cloud it runs npm start in a container on the PORT the platform sets, and each push to your copy redeploys it.
Create a plugin in src/routes/ shaped like root.js, an async function (app) that calls app.get, app.post and so on, then register it in src/app.js with app.register(require('./routes/things')).
Pass a JSON schema in the route options, for example { schema: { body: { type: 'object', required: ['name'] } } }. Fastify checks the body and answers 400 in JSON when it does not match.
No. Install @fastify/cors and register it in buildApp() with the origins you want to allow.
Fastify listens on localhost by default, which nothing outside the container can reach. This starter sets the host to 0.0.0.0 in src/config.js, so platform traffic gets in.
Yes. It has no Light Cloud code: any host with Node.js 22 runs it with npm ci --omit=dev and npm start, with PORT set.
Start a Node.js REST API with Express, CORS, JSON errors and tests already wired up
Start a Web Standards API with Hono on Node.js, with JSON errors and tests and no build
Start an Express CRUD API on PostgreSQL with validation, paging and tests set up