File size: 1,177 Bytes
59af96c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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'
		},
		// tags: [{ name: 'youtube' }]
	},
	exclude: [new RegExp(optsStatic.prefix)],
	path: '/docs',
	scalarConfig: { favicon: '/favicon.ico' }
}

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))
))