Skip to content

Using Tempo with Node HTTP


Tempo supports any server that can use Node HTTP, so you don’t have to use a serverless platform to use it. This example shows how to use Tempo with Node’s HTTP server.

For a see the online example, see the Node HTTP example on StackBlitz.

First, install the Tempo router for Node into your project:

Terminal window
npm install @tempojs/node-http-router

Next, inside your index.ts (or wherever your server handler resides) do the following steps:

  1. Import your services
import * as Services from './services';
  1. Add this line after your import call
typeof Services;

Now you’re ready to create the router:

// creates a logger that will be used by Tempo
// can be anything that implements `TempoLogger`, `ConsoleLogger` is just built in.
const logger = new ConsoleLogger('worker', TempoLogLevel.Debug);
// initialize the service registry. this class is generated for you.
const registry = new TempoServiceRegistry(logger);
// create a new router
// `any` refers to our environment objects type; it is recommended to set it an explicit type (MyEnvObj, etc.)
const router = new TempoRouter<any>(
const server = createServer(
// feed incoming messages into the router
async (req: IncomingMessage, res: ServerResponse) => {
await router.process(req, res, {}));