-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
44 lines (39 loc) · 1.38 KB
/
server.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
44
require('dotenv').config({})
// const Server = require('../core-server')
const Server = require('rohmanwebid-core-server')
const helpers = require('./handler/helpers')
const PluginAdapter = require('./handler/plugins/adapter')
const { routes, controllers, middlewares, globalMiddlewares } = require('./handler')
const configs = require('./config')
const { AppHost, AppPort } = configs
const mongodbModels = require('./handler/models/mongodb')
const mysqlModels = require('./handler/models/mysql')
const pluginObject = new PluginAdapter(configs)
.setModel('mongodb', mongodbModels)
.setModel('redis')
.setModel('mysql', mysqlModels)
const createServer = async () => {
try {
const HttpServer = new Server({})
HttpServer.setObject('routes', routes)
HttpServer.setObject('controllers', controllers)
HttpServer.setObject('globalMiddlewares', globalMiddlewares)
HttpServer.setObject('middlewares', middlewares)
HttpServer.setObject('config', configs)
HttpServer.setObject('plugins', await pluginObject.setup() )
HttpServer.setObject('helpers', helpers)
HttpServer.start({
port: AppPort,
host: AppHost
}, (msg) => {
console.log(msg)
})
} catch (err) {
throw err
}
}
createServer()
.catch(err => {
console.log(err)
process.exit(0)
})