Initial commit

This commit is contained in:
Jose Selesan
2026-04-08 22:53:11 -03:00
commit 9ae270609d
179 changed files with 28096 additions and 0 deletions

48
apps/backend/src/app.ts Normal file
View File

@@ -0,0 +1,48 @@
import { Hono } from 'hono'
import { cors } from 'hono/cors'
import { logger } from '@/lib/logger'
import type { AppEnv } from '@/types/hono'
import { requestId } from 'hono/request-id'
export function createApp() {
const app = new Hono<AppEnv>()
const allowedOrigins = (
Bun.env.CORS_ORIGIN ??
'http://localhost:5173,http://127.0.0.1:5173'
)
.split(',')
.map((value) => value.trim())
.filter(Boolean)
app.use(
'*',
cors({
origin: (origin) => {
if (!origin) return allowedOrigins[0] ?? ''
return allowedOrigins.includes(origin) ? origin : ''
},
allowHeaders: ['Authorization', 'Content-Type'],
allowMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
}),
)
app.use('*', async (c, next) => {
const start = performance.now()
await next()
const durationMs = Number((performance.now() - start).toFixed(1))
logger.info(
{
method: c.req.method,
path: c.req.path,
status: c.res.status,
durationMs,
requestId
},
'http_request',
)
})
return app
}