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.
58 lines
1.0 KiB
58 lines
1.0 KiB
2 years ago
|
import fastify from 'fastify'
|
||
|
import dotenv from 'dotenv'
|
||
|
import path from 'path'
|
||
|
import { EventEmitter } from 'events'
|
||
|
|
||
|
// getting .env
|
||
|
dotenv.config({ path: path.join(path.resolve(), '/../../.env') })
|
||
|
|
||
|
// create server
|
||
|
const server = fastify()
|
||
|
|
||
|
/**
|
||
|
* 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 routes
|
||
|
*
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
import hubHttpApi from './http/api/hubs.js'
|
||
|
import filesHttpApi from './http/api/files.js'
|
||
|
|
||
|
import hubHttp from './http/hub.js'
|
||
|
import indexHttp from './http/index.js'
|
||
|
import staticHttp from './http/static.js'
|
||
|
|
||
|
server
|
||
|
.register(hubHttpApi, {
|
||
|
'prefix': '/api/hubs/v1'
|
||
|
})
|
||
|
.register(filesHttpApi, {
|
||
|
'prefix': '/api/files/v1'
|
||
|
})
|
||
|
.register(hubHttp, {
|
||
|
'prefix': '/hub'
|
||
|
})
|
||
|
.register(indexHttp)
|
||
|
.register(staticHttp)
|
||
|
|
||
|
export default server
|