Node.js (Backend/API)
This tutorial demonstrates how to add auth to a Node application using BlitzWare.
Lightweight Node.js SDK for BlitzWare resource servers (APIs).
This package provides simple middleware for Express and Koa to validate incoming bearer tokens. It prefers token introspection (avoids shipping a shared signing secret) and also supports the common pattern of mounting a non-enforcing parser once and enforcing auth on a per-route basis.
1) Configure BlitzWare
Get Your Application Keys
You will need some details about your application to communicate with BlitzWare. You can get these details from the Application Settings section in the BlitzWare dashboard.

You need the Client ID and Client Secret (given when app was created).
Configure Redirect URIs
A redirect URI is a URL in your application where BlitzWare redirects the user after they have authenticated. The redirect URI for your app must be added to the Redirect URIs list in your Application Settings under the Security tab. If this is not set, users will be unable to log in to the application and will get an error.
2) Install the BlitzWare Node API SDK
Run the following command within your project directory to install the BlitzWare Node API SDK:
3) Configure environment
Create a .env file:
4) Express setup
5) Koa setup
6) How it works
What this package exports
expressAuth(options)-> returns an Express parser middleware. Mount withapp.use(expressAuth(...)).expressRequireAuth()-> returns an Express per-route enforcer middleware.koaAuth(options)-> returns a Koa parser middleware. Mount withapp.use(koaAuth(...)).koaRequireAuth()-> returns a Koa per-route enforcer middleware.
These helpers are implemented in src/middleware.ts and re-exported from src/index.ts (the package entry).
Quick concepts and recommended pattern
Parser (non-enforcing): the middleware returned by
expressAuth()/koaAuth()tries to parse and introspect a bearer token on every request and will attach the result toreq.auth(Express) orctx.state.auth(Koa) when a valid token is present. The parser does not block anonymous requests.Require (per-route): the middleware returned by
expressRequireAuth()/koaRequireAuth()enforces authentication for a specific route. Ifreq.auth/ctx.state.authis missing, it will perform on-demand introspection using the options previously provided viaexpressAuth()/koaAuth()(the helpers store the config internally) and reject the request if the token is invalid or missing.
Recommended usage for multi-file projects:
In your main entrypoint mount the parser once so it runs on every request:
In each route file, use the per-route enforcer where you need protection:
This pattern avoids re-creating auth middleware in every route file while ensuring per-route enforcement works.
Last updated