-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
56 lines (47 loc) · 1.86 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
45
46
47
48
49
50
51
52
53
54
55
56
// As early as possible in your application, require and configure dotenv.
// https://www.npmjs.com/package/dotenv#usage
import * as dotenv from 'dotenv';
dotenv.config();
import * as Hapi from '@hapi/hapi';
import buildManifest from './build/manifest.js';
import githubRoutes from './build/routes/github.js';
import buildRoutesManifest from './build/routes/manifest.js';
import scalingoRoutes from './build/routes/scalingo.js';
import { commonConfig } from './common/config.js';
import * as preResponseHandler from './common/pre-response-handler.js';
import { registerSlashCommands } from './common/register-slash-commands.js';
import commonRoutesIndex from './common/routes/index.js';
import { config } from './config.js';
import * as runDeployConfiguration from './run/deploy-configuration.js';
import runManifest from './run/manifest.js';
import runRoutesApplication from './run/routes/applications.js';
import deploySitesRoutes from './run/routes/deploy-sites.js';
import runRoutesManifest from './run/routes/manifest.js';
import runGitHubRoutes from './run/routes/github.js';
const manifests = [runManifest, buildManifest];
const setupErrorHandling = function (server) {
server.ext('onPreResponse', preResponseHandler.handleErrors);
};
const server = Hapi.server({
port: config.port,
});
setupErrorHandling(server);
server.route(githubRoutes);
server.route(commonRoutesIndex);
server.route(runRoutesManifest);
server.route(buildRoutesManifest);
server.route(runRoutesApplication);
server.route(scalingoRoutes);
server.route(deploySitesRoutes);
server.route(runGitHubRoutes);
registerSlashCommands(runDeployConfiguration.deployConfiguration, runManifest);
manifests.forEach((manifest) => {
const routes = manifest.getHapiRoutes().map((route) => {
return {
...route,
config: commonConfig.slackConfig,
};
});
server.route(routes);
});
export default server;