All files / apps / api/src / app channel-routes.ts

100% Statements 6/6
100% Branches 0/0
100% Functions 2/2
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19              29x   29x   29x 13x     29x 23x    
import { CHANNEL_API, HTTP_STATUS } from '@chattra/shared'
import { Hono } from 'hono'
import { getActor } from '../server/auth/middleware'
import { browseChannels, createChannel } from '../server/channel/service'
import { validate, type AppEnv } from '../server/http'
 
// Channels (design 5.1). Origin, rate limit and token run in routes.ts.
export const channelRoutes = new Hono<AppEnv>()
 
const { create, browse } = CHANNEL_API
 
channelRoutes.on(create.method, create.path, validate('json', create.body), async (c) =>
  c.json(await createChannel(c.env, getActor(c), c.req.valid('json')), HTTP_STATUS.created),
)
 
channelRoutes.on(browse.method, browse.path, validate('query', browse.query), async (c) =>
  c.json(await browseChannels(c.env, getActor(c), c.req.valid('query'))),
)