You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
690 B
41 lines
690 B
import fastify from 'fastify'
|
|
import getOrCreateSqlite from './db/sqlite.js'
|
|
|
|
// get config
|
|
import config from './_config.js'
|
|
config()
|
|
|
|
// create server
|
|
const server = fastify()
|
|
|
|
// add rate limit
|
|
import rateLimit from '@fastify/rate-limit'
|
|
|
|
server.register(rateLimit, {
|
|
max: process.env.APP_RATE_LIMIT_MAX,
|
|
timeWindow: process.env.APP_RATE_LIMIT_TIMEWINDOW
|
|
})
|
|
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
|
|
server.decorate('db', () => {
|
|
return getOrCreateSqlite({ 'uri': process.env.APP_SQLITE_URI_MAIN, 'create': true, 'readwrite': true })
|
|
})
|
|
|
|
/**
|
|
* routing
|
|
*
|
|
*/
|
|
|
|
import flowHttp from './http/api/flow.js'
|
|
|
|
server
|
|
.register(flowHttp, {
|
|
'prefix': '/api/flow/v1'
|
|
})
|
|
|
|
export default server
|