mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-09 23:21:30 -07:00
almost into a room
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import { Hono } from 'hono'
|
||||
import { useWorkersLogger } from 'workers-tagged-logger'
|
||||
|
||||
import { withNotFound, withOnError } from '@repo/hono-helpers'
|
||||
|
||||
import type { App } from './context'
|
||||
|
||||
/**
|
||||
* Ported from the C# `ClubsController`. The only endpoint always returned
|
||||
* `Results.NotFound()` in the source — no DB binding involved.
|
||||
*/
|
||||
const app = new Hono<App>()
|
||||
.use(
|
||||
'*',
|
||||
// middleware
|
||||
(c, next) =>
|
||||
useWorkersLogger(c.env.NAME, {
|
||||
environment: c.env.ENVIRONMENT,
|
||||
release: c.env.SENTRY_RELEASE,
|
||||
})(c, next)
|
||||
)
|
||||
|
||||
.onError(withOnError())
|
||||
.notFound(withNotFound())
|
||||
|
||||
// No club home yet — the C# source returns NotFound here unconditionally.
|
||||
.get('/club/home/me', (c) => c.notFound())
|
||||
|
||||
export default app
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { HonoApp } from '@repo/hono-helpers'
|
||||
import type { SharedHonoEnv, SharedHonoVariables } from '@repo/hono-helpers/src/types'
|
||||
|
||||
export type Env = SharedHonoEnv & {
|
||||
// add additional Bindings here
|
||||
}
|
||||
|
||||
/** Variables can be extended */
|
||||
export type Variables = SharedHonoVariables
|
||||
|
||||
export interface App extends HonoApp {
|
||||
Bindings: Env
|
||||
Variables: Variables
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { exports } from 'cloudflare:workers'
|
||||
import { describe, expect, test } from 'vitest'
|
||||
|
||||
import '../../clubs.app'
|
||||
|
||||
const ORIGIN = 'https://clubs.rec.djdevin.net'
|
||||
|
||||
describe('clubs endpoints', () => {
|
||||
test('GET /club/home/me returns 404', async () => {
|
||||
const res = await exports.default.fetch(`${ORIGIN}/club/home/me`)
|
||||
expect(res.status).toBe(404)
|
||||
})
|
||||
|
||||
test('unknown routes 404', async () => {
|
||||
const res = await exports.default.fetch(`${ORIGIN}/nope`)
|
||||
expect(res.status).toBe(404)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user