import { swaggerUI } from '@hono/swagger-ui'
import { OpenAPIHono } from '@hono/zod-openapi'
import { handle } from 'hono/aws-lambda'
import { compress } from 'hono/compress'
import { logger } from 'hono/logger'
import { appRoute } from './app'
import { concreteRecord } from './concrete-record'
import { mould } from './mould'
import { project } from './project'
import { vehicle } from './vehicle'
const app = new OpenAPIHono()
app.use('*', logger())
app.use('*', compress())
app.use('*', async (c, next) => {
await next()
if (!c.res.headers.get('cache-control')) {
c.header('cache-control', 'no-store, max-age=0, must-revalidate, no-cache')
}
})
app.openAPIRegistry.registerComponent('securitySchemes', 'Bearer', {
type: 'http',
scheme: 'bearer',
})
app.get('/', async (c) => {
return c.json({
message: 'Hello, world!',
})
})
/** Swagger Documentation */
app.doc('/doc', () => ({
openapi: '3.0.0',
info: {
title: 'Extrudakerb API',
version: '0.0.1',
},
}))
// Use the middleware to serve Swagger UI at /ui
app.get(
'/ui',
swaggerUI({
url: '/doc',
}),
)
/** End Swagger Documentation */
export const routes = app
.route('/app', appRoute)
.route('/mould', mould)
.route('/project', project)
.route('/vehicle', vehicle)
.route('/concreteRecord', concreteRecord)
export const handler = handle(app)