Framework integrations

One-line middleware for the popular web frameworks. Every helper captures the error, attaches the HTTP method + URL of this request, and re-raises so your framework's normal error handling still fires. Per-request context never touches the global scope, so concurrent requests don't leak each other's data.

Express (Node)

import express from "express";
import { init, expressErrorHandler } from "tinymonjs";

init({ dsn: process.env.TINYMON_DSN });

const app = express();
app.get("/boom", () => { throw new Error("boom"); });

// MUST be registered LAST, after all routes + other middleware.
app.use(expressErrorHandler());

Fastify (Node)

import Fastify from "fastify";
import { init, fastifyPlugin } from "tinymonjs";

init({ dsn: process.env.TINYMON_DSN });

const app = Fastify();
await app.register(fastifyPlugin);

app.get("/boom", async () => { throw new Error("boom"); });

The plugin tags itself with Fastify's skip-override symbol so it works without the fastify-plugin wrapper dependency.

Flask (WSGI)

import os
from flask import Flask
import tinymonpy
from tinymonpy.frameworks.wsgi import TinymonWSGI

tinymonpy.init(dsn=os.environ["TINYMON_DSN"])

app = Flask(__name__)
app.wsgi_app = TinymonWSGI(app.wsgi_app)

Django

For sync Django, wrap WSGI:

# wsgi.py
from django.core.wsgi import get_wsgi_application
import tinymonpy
from tinymonpy.frameworks.wsgi import TinymonWSGI

tinymonpy.init(dsn=os.environ["TINYMON_DSN"])
application = TinymonWSGI(get_wsgi_application())

For Django ASGI, use TinymonASGI in asgi.py the same way.

FastAPI / Starlette (ASGI)

from fastapi import FastAPI
import tinymonpy
from tinymonpy.frameworks.asgi import TinymonASGI

tinymonpy.init(dsn=os.environ["TINYMON_DSN"])
app = FastAPI()
app.add_middleware(TinymonASGI)

Rails / Sinatra / any Rack app

Rails auto-inserts the middleware via a Railtie when you require "tinymonrb" (loaded on boot via your Gemfile). Manual insert if you prefer:

# config/application.rb (Rails)
config.middleware.use Tinymon::Rack

# Sinatra or plain Rack:
use Tinymon::Rack

Concurrency note

Don't use setUser / setTag for per-request data on the server. Those write to a module-global scope and will race across concurrent requests. Use the framework helpers — they attach request context to this event only and never touch the global scope. If you need per-request user/tag context, call captureExceptionWithContext (JS), capture_exception_with_context (Python/Ruby) directly.

Your error response still fires

Every helper re-raises (or calls next(err)) after capturing, so:

tinymon reports the error — it doesn't hide it.