Updated hono to be a peer dependency (#9)

* Updated hono to be a peer dependency

* update lockfile

* Added binding definitions
pull/31/head
Dane Wilson 2022-12-12 21:40:49 +00:00 committed by GitHub
parent 5f87be285c
commit 857700f6b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1120 additions and 1051 deletions

View File

@ -32,8 +32,10 @@
"registry": "https://registry.npmjs.org",
"access": "public"
},
"peerDependencies": {
"hono": "^2.2.5"
},
"dependencies": {
"hono": "^2.2.5",
"toucan-js": "^2.6.1"
},
"devDependencies": {
@ -50,6 +52,7 @@
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"hono": "^2.2.5",
"jest": "^28.1.2",
"jest-environment-miniflare": "^2.6.0",
"np": "^7.6.2",

View File

@ -5,6 +5,12 @@ declare module 'hono' {
interface ContextVariableMap {
sentry: Toucan
}
}
interface Bindings {
SENTRY_DSN?: string;
NEXT_PUBLIC_SENTRY_DSN?: string;
}
class MockContext implements ExecutionContext {
@ -29,7 +35,7 @@ export type Options = {
release?: string
}
export const sentry = (options?: Options, callback?: (sentry: Toucan) => void): Handler => {
export const sentry = (options?: Options, callback?: (sentry: Toucan) => void): Handler<string, { Bindings: Bindings }> => {
return async (c, next) => {
let hasExecutionContext = true
try {
@ -38,7 +44,7 @@ export const sentry = (options?: Options, callback?: (sentry: Toucan) => void):
hasExecutionContext = false
}
const sentry = new Toucan({
dsn: c.env.SENTRY_DSN || c.env.NEXT_PUBLIC_SENTRY_DSN,
dsn: c.env.SENTRY_DSN ?? c.env.NEXT_PUBLIC_SENTRY_DSN,
allowedHeaders: ['user-agent'],
allowedSearchParams: /(.*)/,
request: c.req,

2156
yarn.lock

File diff suppressed because it is too large Load Diff