Node HTTP
Node.js is the most popular JavaScript runtime environment, and feTS supports it fully as well with a few lines of code.
This recipe shows how to use feTS with Node.js’ built-in HTTP implementation.
Installation
npmpnpmyarnbun
npm i fets
pnpm add fets
yarn add fets
bun add fets
Example
import { createServer } from 'node:http'
import { createRouter, Response } from 'fets'
const router = createRouter().route({ method: 'GET', path: '/greetings', schemas: { responses: {
200: { type: 'object', properties: { hello: { type: 'string' } } } } }, handler: () =>
Response.json({ hello: 'world' }) })
createServer(router).listen(3000, () => { console.log('Swagger UI is available at
http://localhost:3000/docs') })
import { createServer } from 'node:http'
import { createRouter, Response, Type } from 'fets'
const router = createRouter().route({
method: 'GET',
path: '/greetings',
schemas: {
responses: {
200: Type.Object({
hello: Type.String()
})
}
},
handler: () => Response.json({ hello: 'world' })
})
createServer(router).listen(3000, () => {
console.log('Swagger UI is available at http://localhost:3000/docs')
})
Last updated on March 20, 2026