chore: remove unused code
This commit is contained in:
parent
a9efaa712d
commit
2169d29c17
@ -1,55 +0,0 @@
|
|||||||
import { changelog, changelog_version, db } from '@boring.tools/database'
|
|
||||||
import { ChangelogByIdParams, ChangelogOutput } from '@boring.tools/schema'
|
|
||||||
import { createRoute } from '@hono/zod-openapi'
|
|
||||||
import { and, eq } from 'drizzle-orm'
|
|
||||||
import { HTTPException } from 'hono/http-exception'
|
|
||||||
|
|
||||||
export const route = createRoute({
|
|
||||||
method: 'get',
|
|
||||||
path: '/:id',
|
|
||||||
request: {
|
|
||||||
params: ChangelogByIdParams,
|
|
||||||
},
|
|
||||||
responses: {
|
|
||||||
200: {
|
|
||||||
content: {
|
|
||||||
'application/json': {
|
|
||||||
schema: ChangelogOutput,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
description: 'Return changelog by id',
|
|
||||||
},
|
|
||||||
400: {
|
|
||||||
description: 'Bad Request',
|
|
||||||
},
|
|
||||||
500: {
|
|
||||||
description: 'Internal Server Error',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export const func = async ({ id }: { id: string }) => {
|
|
||||||
const result = await db.query.changelog.findFirst({
|
|
||||||
where: and(eq(changelog.id, id)),
|
|
||||||
with: {
|
|
||||||
versions: {
|
|
||||||
where: eq(changelog_version.status, 'published'),
|
|
||||||
orderBy: (changelog_version, { desc }) => [
|
|
||||||
desc(changelog_version.createdAt),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
throw new HTTPException(404, { message: 'Not found' })
|
|
||||||
}
|
|
||||||
|
|
||||||
const { userId, createdAt, ...rest } = result
|
|
||||||
return rest
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
route,
|
|
||||||
func,
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
import { OpenAPIHono } from '@hono/zod-openapi'
|
|
||||||
import type { Variables } from '../..'
|
|
||||||
import { type ContextModule, captureSentry } from '../../utils/sentry'
|
|
||||||
import ById from './byId'
|
|
||||||
|
|
||||||
const app = new OpenAPIHono<{ Variables: Variables }>()
|
|
||||||
|
|
||||||
const module: ContextModule = {
|
|
||||||
name: 'changelog',
|
|
||||||
sub_module: 'public',
|
|
||||||
}
|
|
||||||
|
|
||||||
app.openapi(ById.route, async (c) => {
|
|
||||||
try {
|
|
||||||
const id = c.req.param('id')
|
|
||||||
const result = await ById.func({ id })
|
|
||||||
return c.json(result, 200)
|
|
||||||
} catch (error) {
|
|
||||||
return captureSentry({
|
|
||||||
c,
|
|
||||||
error,
|
|
||||||
module,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
export default app
|
|
@ -5,7 +5,6 @@ import { apiReference } from '@scalar/hono-api-reference'
|
|||||||
import { cors } from 'hono/cors'
|
import { cors } from 'hono/cors'
|
||||||
|
|
||||||
import changelog from './changelog'
|
import changelog from './changelog'
|
||||||
import changelogPublic from './changelog/public'
|
|
||||||
import version from './changelog/version'
|
import version from './changelog/version'
|
||||||
import user from './user'
|
import user from './user'
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ app.route('/v1/user', user)
|
|||||||
app.route('/v1/changelog', changelog)
|
app.route('/v1/changelog', changelog)
|
||||||
app.route('/v1/changelog/version', version)
|
app.route('/v1/changelog/version', version)
|
||||||
app.route('/v1/page', pageApi)
|
app.route('/v1/page', pageApi)
|
||||||
app.route('/v1/changelog/public', changelogPublic)
|
|
||||||
|
|
||||||
app.doc('/openapi.json', {
|
app.doc('/openapi.json', {
|
||||||
openapi: '3.0.0',
|
openapi: '3.0.0',
|
||||||
|
Loading…
Reference in New Issue
Block a user