Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/altipla-consulting/sentry.js
Helper to connect Sentry to tRPC, Express and Astro.
https://github.com/altipla-consulting/sentry.js
Last synced: about 1 month ago
JSON representation
Helper to connect Sentry to tRPC, Express and Astro.
- Host: GitHub
- URL: https://github.com/altipla-consulting/sentry.js
- Owner: altipla-consulting
- License: mit
- Created: 2023-04-03T13:18:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-26T07:10:51.000Z (5 months ago)
- Last Synced: 2024-08-27T07:56:40.951Z (4 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@altipla/sentry
- Size: 134 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sentry.js
Helper to connect Sentry to tRPC, Express and Astro.
## Install
```sh
npm install @altipla/sentry
```## Usage
### Express
Add the the error handler after all the other routes.
```ts
import express from 'express'
import { expressErrorHandler } from '@altipla/sentry'let app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
})
// ...other routesapp.use(expressErrorHandler())
```### tRPC
Set `onError` option when creating the tRPC routers. For example with the Express connector:
```ts
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.
```ts
import type { MiddlewareHandler } from 'astro'
import { astroMiddleware } from '@altipla/sentry'
import { sequence } from 'astro:middleware'export const onRequest: MiddlewareHandler = sequence(
astroMiddleware,
// ... other middlewares
}
```