forked from danactive/history
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
70 lines (63 loc) · 2.03 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* global __dirname, require*/
const hapi = require('hapi');
const hapiReactViews = require('hapi-react-views');
const hapiSwagger = require('hapi-swagger');
const hoek = require('hoek');
const lout = require('lout');
const notifier = require('node-notifier');
const inert = require('inert');
const vision = require('vision');
require('tuxharness');
const config = require('./config.json');
const libAdmin = require('./plugins/admin/lib/index');
const viewAlbum = require('./plugins/album/lib/index');
const editAlbum = require('./plugins/editAlbum/lib/index');
const libHome = require('./plugins/home/lib/index');
const libRename = require('./plugins/rename/lib/index');
const libResize = require('./plugins/resize/lib/index');
const libRoutes = require('./src/js/route.js');
const libVideo = require('./plugins/video/lib/index');
const logMod = require('./plugins/log/lib');
const pkg = require('./package');
require('babel-core/register')({
presets: ['react', 'es2015'],
});
const port = config.port;
const log = logMod('server');
const server = new hapi.Server();
server.connection({ port });
server.register([
{ register: inert },
{ register: vision },
{ register: libRoutes },
{ register: libAdmin, routes: { prefix: '/admin' } },
{ register: viewAlbum, routes: { prefix: '/view' } },
{ register: editAlbum, routes: { prefix: '/edit' } },
{ register: libHome },
{ register: libRename, routes: { prefix: '/admin' } },
{ register: libResize, routes: { prefix: '/admin' } },
{ register: libVideo, routes: { prefix: '/view' } },
{
register: hapiSwagger,
options: { info: { title: 'history API', version: pkg.version } },
},
{ register: lout },
], (error) => {
hoek.assert(!error, error);
server.start();
log.operational(`Server running at ${server.info.uri}`);
notifier.notify({
title: 'Server event',
message: `Running at ${server.info.uri}`,
});
});
server.views({
defaultExtension: 'jsx',
engines: {
jsx: hapiReactViews,
},
isCached: true,
path: './',
partialsPath: './',
relativeTo: __dirname,
});