blob: be6a3b77fd1c586d5f1efeb08ca548b6a0c7c394 [file] [log] [blame]
Arundathi Patil85db5b02019-01-17 14:10:08 +05301/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018-19 IBM Intellectual Property. All rights reserved.
5===================================================================
6
7Unless otherwise specified, all software contained herein is licensed
8under the Apache License, Version 2.0 (the License);
9you may not use this software except in compliance with the License.
10You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14Unless required by applicable law or agreed to in writing, software
15distributed under the License is distributed on an "AS IS" BASIS,
16WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17See the License for the specific language governing permissions and
18limitations under the License.
19============LICENSE_END============================================
20*/
21
22const application = require('./dist');
eeginuxb9ee8692019-07-04 15:01:39 +010023const fs = require('fs')
Arundathi Patil85db5b02019-01-17 14:10:08 +053024
25module.exports = application;
26
27if (require.main === module) {
eeginux1094dd52020-02-18 10:54:48 +000028
29 try {
30 var p12File = process.env.KEYSTORE || "aaf.p12"
31 var passwdFile = process.env.PASSPHRASE || ".enc"
32
33 var data = fs.readFileSync(passwdFile, 'utf8')
34 var elements = data.match(/cadi_keystore_password_p12=(.*)\n/)
35 var passphrase = elements[1]
36 var p12 = fs.readFileSync(p12File)
37 } catch(e){
38 console.error('Reading keystore error :', e)
39 process.exit(11)
40 }
41
Arundathi Patil85db5b02019-01-17 14:10:08 +053042 // Run the application
43 const config = {
44 rest: {
eeginuxb9ee8692019-07-04 15:01:39 +010045 protocol: 'https',
eeginux1094dd52020-02-18 10:54:48 +000046 pfx: p12,
47 passphrase: passphrase,
Arundathi Patil85db5b02019-01-17 14:10:08 +053048 port: +process.env.PORT || 3000,
49 host: process.env.HOST || 'localhost',
50 openApiSpec: {
51 // useful when used with OASGraph to locate your application
52 setServersFromRequest: true,
53 },
54 },
55 };
56 application.main(config).catch(err => {
57 console.error('Cannot start the application.', err);
58 process.exit(1);
59 });
60}