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.
67 lines
1.1 KiB
67 lines
1.1 KiB
import fastify from 'fastify'
|
|
import dotenv from 'dotenv'
|
|
import path from 'path'
|
|
import { EventEmitter } from 'events'
|
|
import fastifyCookie from '@fastify/cookie'
|
|
|
|
// getting .env
|
|
dotenv.config({ path: path.join(path.resolve(), '/../../.env') })
|
|
|
|
// create server
|
|
const server = fastify()
|
|
|
|
server.register(fastifyCookie)
|
|
|
|
/**
|
|
* Add liquidjs
|
|
*
|
|
*
|
|
*/
|
|
|
|
import { Liquid } from 'liquidjs'
|
|
import view from '@fastify/view'
|
|
|
|
const engine = new Liquid({
|
|
root: path.join(path.resolve(), '/../frontend/views'),
|
|
extname: '.liquid',
|
|
})
|
|
|
|
server.register(view, {
|
|
engine: {
|
|
liquid: engine
|
|
}
|
|
})
|
|
|
|
/**
|
|
* Add plugins
|
|
*
|
|
*
|
|
*/
|
|
|
|
import jwtPlugin from './plugins/jwt.js'
|
|
|
|
server.register(jwtPlugin)
|
|
|
|
/**
|
|
* Add routes
|
|
*
|
|
*
|
|
*/
|
|
|
|
import authHttpApi from './http/api/auth.js'
|
|
import actionHttpApi from './http/api/action.js'
|
|
|
|
import indexHttp from './http/index.js'
|
|
import staticHttp from './http/static.js'
|
|
|
|
server
|
|
.register(authHttpApi, {
|
|
'prefix': '/api/auth/v1'
|
|
})
|
|
.register(actionHttpApi, {
|
|
'prefix': '/api/action/v1'
|
|
})
|
|
.register(indexHttp)
|
|
.register(staticHttp)
|
|
|
|
export default server |