mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
remove datacollection endpoint
This commit is contained in:
@@ -1,14 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import { Hono } from 'hono'
|
||||
import { useWorkersLogger } from 'workers-tagged-logger'
|
||||
|
||||
import { withNotFound, withOnError } from '@repo/hono-helpers'
|
||||
|
||||
import type { App } from './context'
|
||||
|
||||
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())
|
||||
|
||||
.get('/', (c) => c.json({ service: 'datacollection', status: 'ok' }))
|
||||
|
||||
// Telemetry sink. The client POSTs analytics events here; we accept and ack
|
||||
// with an empty JSON object (no persistence — no binding yet).
|
||||
.post('/data/event', (c) => c.json({}))
|
||||
|
||||
// Periodic session heartbeat. Same deal — accept and ack with `{}`.
|
||||
.post('/data/heartbeat', (c) => c.json({}))
|
||||
|
||||
// Analytics identify call (player/device identification). Accept and ack.
|
||||
.post('/identify', (c) => c.json({}))
|
||||
|
||||
// Generic analytics HTTP API sink. Accept and ack.
|
||||
.post('/httpapi', (c) => c.json({}))
|
||||
|
||||
export default app
|
||||
@@ -1,33 +0,0 @@
|
||||
import { SELF } from 'cloudflare:test'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import '../../datacollection.app'
|
||||
|
||||
const ORIGIN = 'https://example.com'
|
||||
|
||||
describe('datacollection endpoints', () => {
|
||||
it('GET / reports service status', async () => {
|
||||
const res = await SELF.fetch(`${ORIGIN}/`)
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({ service: 'datacollection', status: 'ok' })
|
||||
})
|
||||
|
||||
it('POST /data/event accepts an event and returns 200', async () => {
|
||||
const res = await SELF.fetch(`${ORIGIN}/data/event`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: 'app_start', properties: { foo: 'bar' } }),
|
||||
})
|
||||
expect(res.status).toBe(200)
|
||||
})
|
||||
|
||||
it('POST /data/event accepts an empty body', async () => {
|
||||
const res = await SELF.fetch(`${ORIGIN}/data/event`, { method: 'POST' })
|
||||
expect(res.status).toBe(200)
|
||||
})
|
||||
|
||||
it('POST /data/heartbeat returns 200', async () => {
|
||||
const res = await SELF.fetch(`${ORIGIN}/data/heartbeat`, { method: 'POST' })
|
||||
expect(res.status).toBe(200)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user