0.2.6 • Published 10 months ago

@altipla/sentry v0.2.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

sentry.js

Helper to connect Sentry to tRPC, Express and Astro.

Install

npm install @altipla/sentry

Usage

Express

Add the the error handler after all the other routes.

import express from 'express'
import { expressErrorHandler } from '@altipla/sentry'

let app = express()

app.get('/', (req, res) => {
  res.send('Hello World!')
})
// ...other routes

app.use(expressErrorHandler())

tRPC

Set onError option when creating the tRPC routers. For example with the Express connector:

import express from 'express'
import { initTRPC } from '@trpc/server'
import * as trpcExpress from '@trpc/server/adapters/express'
import { trpcOnError } from '@altipla/sentry'

let app = express()

app.use(
  '/trpc',
  trpcExpress.createExpressMiddleware({
    router,
    context,
    onError: trpcOnError,
  }),
)

Astro

Add the integration to the chain of server middlewares.

import type { MiddlewareHandler } from 'astro'
import { astroMiddleware } from '@altipla/sentry'
import { sequence } from 'astro:middleware'

export const onRequest: MiddlewareHandler = sequence(
  astroMiddleware,
  // ... other middlewares
}
0.2.6

10 months ago

0.2.1

1 year ago

0.2.0

1 year ago

0.2.3

1 year ago

0.2.2

1 year ago

0.2.5

11 months ago

0.2.4

1 year ago

0.1.1

2 years ago

0.1.0

2 years ago