@sassoftware/viya-serverjs 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/iService.js CHANGED
@@ -196,7 +196,7 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
196
196
  });
197
197
  }
198
198
  }
199
- hapiServer.log('Plugin', process.env.PLUGIN);
199
+ console.log('Plugin', process.env.PLUGIN);
200
200
 
201
201
  if (process.env.PLUGIN === 'hapi-swagger' && serverMode ==='api') {
202
202
  let swaggerOptions = {
@@ -259,27 +259,25 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
259
259
 
260
260
  async function getCertificates () {
261
261
 
262
- let tls = {};
263
- debug2('TLS_CRT', process.env.TLS_CRT != null);
264
- debug2('TLS_CREATE', process.env.TLS_CREATE != null);
265
- if (process.env.TLS_CRT != null && process.env.TLS_CRT.length > 0) {
266
- if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
267
- console.log('TLS_CRT and TLS_KEY exist');
268
- tls.cert = fs.readFileSync(process.env.TLS_CRT);
269
- tls.key = fs.readFileSync(process.env.TLS_KEY);
262
+ let options = null;
263
+ let tlsdir = process.env.SSLCERT;
264
+ if (tlsdir != null && tlsdir.trim().length > 0) {
265
+ console.log('ssl CERTIFICATES', tlsdir);
266
+ if (fs.existsSync(`${tlsdir}/key.pem`) === true) {
267
+ options = {};
268
+ options.key = fs.readFileSync(`${tlsdir}/key.pem`, { encoding: 'utf8' });
269
+ options.cert = fs.readFileSync(`${tlsdir}/crt.pem`, { encoding: 'utf8' });
270
+ if (fs.existsSync(`${tlsdir}/ca.pem`) === true) {
271
+ options.ca = fs.readFileSync(`${tlsdir}/ca.pem`, { encoding: 'utf8' });
272
+ }
273
+ options.rejectUnauthorized= true;
270
274
  }
271
-
272
- }
273
- if (tls.cert == null && process.env.TLS_CREATE != null) {
274
- /* unsigned certificate */
275
- console.log('Creating selfsigned certificate');
276
- debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
277
- tls = await getTls();
275
+ } else {
276
+ console.log('No SSL certificates found, generating self-signed certificates');
277
+ options = await getTls();
278
+ options.rejectUnauthorized= false;
278
279
  }
279
- if (Object.keys(tls).length === 0){
280
- console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
281
- }
282
- return tls;
280
+ return options;
283
281
  }
284
282
 
285
283
  async function getTls () {
@@ -66,17 +66,6 @@ module.exports = function setDefaultRoutes(server, options) {
66
66
  : null;
67
67
 
68
68
  let defaultTable = [
69
- {
70
- method: ["GET"],
71
- path: `/health`,
72
- options: {
73
- auth: false,
74
- handler: async (req, h) => {
75
- return h.response({ x: 1 }).code(200);
76
- },
77
- },
78
- },
79
-
80
69
  {
81
70
  method: ["GET"],
82
71
  path: `${appName}/logon`,