Updated hono to be a peer dependency (#9)
* Updated hono to be a peer dependency * update lockfile * Added binding definitionspull/31/head
parent
5f87be285c
commit
857700f6b7
|
@ -32,8 +32,10 @@
|
||||||
"registry": "https://registry.npmjs.org",
|
"registry": "https://registry.npmjs.org",
|
||||||
"access": "public"
|
"access": "public"
|
||||||
},
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"hono": "^2.2.5"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hono": "^2.2.5",
|
|
||||||
"toucan-js": "^2.6.1"
|
"toucan-js": "^2.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -50,6 +52,7 @@
|
||||||
"eslint-plugin-flowtype": "^8.0.3",
|
"eslint-plugin-flowtype": "^8.0.3",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"hono": "^2.2.5",
|
||||||
"jest": "^28.1.2",
|
"jest": "^28.1.2",
|
||||||
"jest-environment-miniflare": "^2.6.0",
|
"jest-environment-miniflare": "^2.6.0",
|
||||||
"np": "^7.6.2",
|
"np": "^7.6.2",
|
||||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -5,6 +5,12 @@ declare module 'hono' {
|
||||||
interface ContextVariableMap {
|
interface ContextVariableMap {
|
||||||
sentry: Toucan
|
sentry: Toucan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Bindings {
|
||||||
|
SENTRY_DSN?: string;
|
||||||
|
NEXT_PUBLIC_SENTRY_DSN?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
class MockContext implements ExecutionContext {
|
class MockContext implements ExecutionContext {
|
||||||
|
@ -29,7 +35,7 @@ export type Options = {
|
||||||
release?: string
|
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) => {
|
return async (c, next) => {
|
||||||
let hasExecutionContext = true
|
let hasExecutionContext = true
|
||||||
try {
|
try {
|
||||||
|
@ -38,7 +44,7 @@ export const sentry = (options?: Options, callback?: (sentry: Toucan) => void):
|
||||||
hasExecutionContext = false
|
hasExecutionContext = false
|
||||||
}
|
}
|
||||||
const sentry = new Toucan({
|
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'],
|
allowedHeaders: ['user-agent'],
|
||||||
allowedSearchParams: /(.*)/,
|
allowedSearchParams: /(.*)/,
|
||||||
request: c.req,
|
request: c.req,
|
||||||
|
|
Loading…
Reference in New Issue