cruxx commited on
Commit
59af96c
·
verified ·
1 Parent(s): 2532deb

Create app.js

Browse files
Files changed (1) hide show
  1. app.js +50 -0
app.js ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Elysia } from 'elysia'
2
+ import { autoload } from 'elysia-autoload'
3
+ import { staticPlugin } from '@elysiajs/static'
4
+ import { swagger } from '@elysiajs/swagger'
5
+ import { tmpdir } from 'node:os'
6
+ import logixlysia from 'logixlysia'
7
+
8
+ const optsElysia = {
9
+ serve: { maxRequestBodySize: Number.MAX_SAFE_INTEGER }
10
+ }
11
+
12
+ const optsLoad = { prefix: '/v1' }
13
+
14
+ const optsLog = {
15
+ ip: true,
16
+ startupMessageFormat: 'simple',
17
+ timestamp: { translateTime: '[HH:MM:ss]' }
18
+ }
19
+
20
+ const optsStatic = {
21
+ alwaysStatic: true,
22
+ assets: tmpdir(),
23
+ prefix: '/file'
24
+ }
25
+
26
+ const optsSwagger = {
27
+ documentation: {
28
+ info: {
29
+ title: 'Ella API Documentation',
30
+ version: '1.0.0'
31
+ },
32
+ // tags: [{ name: 'youtube' }]
33
+ },
34
+ exclude: [new RegExp(optsStatic.prefix)],
35
+ path: '/docs',
36
+ scalarConfig: { favicon: '/favicon.ico' }
37
+ }
38
+
39
+ export const app = new Elysia(optsElysia)
40
+ .use(logixlysia({ config: optsLog }))
41
+ .use(await autoload(optsLoad))
42
+ .use(staticPlugin(optsStatic))
43
+ .use(swagger(optsSwagger))
44
+ .get('/favicon.ico', () => Bun.file('favicon.ico'))
45
+ .get('/', ({ redirect }) => redirect(optsSwagger.path))
46
+
47
+ await app.modules
48
+ app.listen(Bun.env.PORT, () => (
49
+ console.log(app.routes.map((x) => x.path))
50
+ ))