chore: denoify

pull/31/head
Yusuke Wada 2022-12-13 07:50:21 +09:00
parent 29d9d29378
commit 47ca2acc65
2 changed files with 13 additions and 5 deletions

View File

@ -1,12 +1,17 @@
import type { Context, Handler } from 'https://raw.githubusercontent.com/honojs/hono/v2.2.5/deno_dist/mod.ts'
import type { Context, MiddlewareHandler } from 'https://raw.githubusercontent.com/honojs/hono/v2.6.1/deno_dist/mod.ts'
import Toucan from 'https://cdn.skypack.dev/toucan-js@2.6.1'
declare module 'https://raw.githubusercontent.com/honojs/hono/v2.2.5/deno_dist/mod.ts' {
declare module 'https://raw.githubusercontent.com/honojs/hono/v2.6.1/deno_dist/mod.ts' {
interface ContextVariableMap {
sentry: Toucan
}
}
interface Bindings {
SENTRY_DSN?: string
NEXT_PUBLIC_SENTRY_DSN?: string
}
class MockContext implements ExecutionContext {
passThroughOnException(): void {
throw new Error('Method not implemented.')
@ -29,7 +34,10 @@ export type Options = {
release?: string
}
export const sentry = (options?: Options, callback?: (sentry: Toucan) => void): Handler => {
export const sentry = (
options?: Options,
callback?: (sentry: Toucan) => void
): MiddlewareHandler<string, { Bindings: Bindings }> => {
return async (c, next) => {
let hasExecutionContext = true
try {
@ -38,7 +46,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,

View File

@ -1,2 +1,2 @@
export { assert, assertEquals } from 'https://deno.land/std@0.148.0/testing/asserts.ts'
export { Hono } from 'https://deno.land/x/hono@v2.2.5/mod.ts'
export { Hono } from 'https://raw.githubusercontent.com/honojs/hono/v2.6.1/deno_dist/mod.ts'