|
import { Elysia } from 'elysia' |
|
import { autoload } from 'elysia-autoload' |
|
import { staticPlugin } from '@elysiajs/static' |
|
import { swagger } from '@elysiajs/swagger' |
|
import { tmpdir } from 'node:os' |
|
import logixlysia from 'logixlysia' |
|
|
|
const optsElysia = { |
|
serve: { maxRequestBodySize: Number.MAX_SAFE_INTEGER } |
|
} |
|
|
|
const optsLoad = { prefix: '/v1' } |
|
|
|
const optsLog = { |
|
ip: true, |
|
startupMessageFormat: 'simple', |
|
timestamp: { translateTime: '[HH:MM:ss]' } |
|
} |
|
|
|
const optsStatic = { |
|
alwaysStatic: true, |
|
assets: tmpdir(), |
|
prefix: '/file' |
|
} |
|
|
|
const optsSwagger = { |
|
documentation: { |
|
info: { |
|
title: 'Ella API Documentation', |
|
version: '1.0.0' |
|
} |
|
}, |
|
exclude: [new RegExp(optsStatic.prefix)], |
|
path: '/docs', |
|
provider: 'swagger-ui' |
|
} |
|
|
|
export const app = new Elysia(optsElysia) |
|
.use(logixlysia({ config: optsLog })) |
|
.use(await autoload(optsLoad)) |
|
.use(staticPlugin(optsStatic)) |
|
.use(swagger(optsSwagger)) |
|
.get('/favicon.ico', () => Bun.file('favicon.ico')) |
|
.get('/', ({ redirect }) => redirect(optsSwagger.path)) |
|
|
|
await app.modules |
|
app.listen(Bun.env.PORT, () => ( |
|
console.log(app.routes.map((x) => x.path)) |
|
)) |