-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
43 lines (37 loc) · 1.08 KB
/
index.js
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
import 'dotenv/config'
import Fastify from 'fastify'
import cors from '@fastify/cors'
import swagger from '@fastify/swagger'
import swaggerUI from '@fastify/swagger-ui'
import psn from './routes/psn.js'
import configs from './routes/configs.js'
import redisClient from './redis.js'
await redisClient.connect()
const fastify = Fastify({
logger: true,
})
await fastify.register(cors, {})
await fastify.register(swagger, {
swagger: {
info: {
title: 'PS Trophy',
description: 'A wrapper of ps api',
version: '1.0.0',
},
externalDocs: {
url: 'https://github.com/ssshooter/ps-trophy',
description: 'Find more info here',
},
consumes: ['application/json'],
produces: ['application/json'],
},
})
await fastify.register(swaggerUI, {
routePrefix: '/doc',
})
fastify.get('/ping', async (_, reply) => {
reply.type('application/json').code(200).send({ hello: 'ps-trophy' })
})
fastify.register(configs, { prefix: '/configs' })
fastify.register(psn, { prefix: '/psn' })
await fastify.listen({ port: process.env.PORT || 2333, address: '0.0.0.0' })