diff --git a/config/default.js b/config/default.js index 06335a5..7555300 100644 --- a/config/default.js +++ b/config/default.js @@ -8,31 +8,36 @@ const path = require('path'); const cwd = process.cwd(); -const host = 'http://localhost:3030'; module.exports = { + + /* This is the internal URI info ***********************/ + + // The internal scheme is *always* 'http', so + // no need to configure it + /* scheme: 'http', */ + + // The internal host is *always* 'localhost' so + // no need to configure it + /* host: 'localhost', */ + + // The port can change depending on the server + port: 3030, + + loglevel: 'INFO', - // API info that is used in the /docs pages by hapi-swaggered + // API info that is used in the /docs pages by hapi-swaggered. + // Note: this info is supplemented with info from package.json info: { title: 'Zenodeo API documentation for BLR', - description: '`nodejs` interface to the Zenodo/BLR community collection', - version: '2.6.0', termsOfService: '/tos', - contact: { - name: 'Puneet Kishor', - url: 'https://punkish.org/About', - email: 'punkish@plazi.org' - }, - license: { + license: { name: 'CC0 Public Domain Dedication', url: 'https://creativecommons.org/publicdomain/zero/1.0/legalcode' } }, 'swaggered-scheme': [ 'http' ], - - port: 3030, - loglevel: 'INFO', // all queries that take longer than the // following (in ms) are displayed in red @@ -46,8 +51,9 @@ module.exports = { on: true }, + // These are the external URIs uri: { - zenodeo: `${host}/v1`, + zenodeo: 'http://localhost:3030/v1', zenodo: 'https://zenodo.org/api' }, @@ -68,11 +74,10 @@ module.exports = { }, uri: { - zenodeo: `${host}/v2`, + zenodeo: 'http://localhost:3030/v2', zenodo: 'https://zenodo.org/api' }, - dataDict: path.join(cwd, 'dataDictionary', 'data-dictionary.js'), schema: path.join(cwd, 'api', 'v2', 'schema.js') diff --git a/config/production.js b/config/production.js index 457c80c..4c0b1fe 100644 --- a/config/production.js +++ b/config/production.js @@ -15,7 +15,7 @@ module.exports = { v1: { uri: { - zenodeo: `${host}/v1` + zenodeo: 'https://zenodeo.punkish.org/v1' } }, @@ -25,7 +25,7 @@ module.exports = { }, uri: { - zenodeo: `${host}/v2` + zenodeo: 'https://zenodeo.punkish.org/v2' } }, diff --git a/config/test.js b/config/test.js index cfeff19..0652183 100644 --- a/config/test.js +++ b/config/test.js @@ -7,25 +7,19 @@ * **************************************************************/ -const host = 'http://z2.punkish.org'; - module.exports = { loglevel: 'ERROR', v1: { uri: { - zenodeo: `${host}/v1` + zenodeo: 'http://z2.punkish.org/v1' } }, v2: { - // cache: { - // on: false - // }, - uri: { - zenodeo: `${host}/v2` + zenodeo: 'http://z2.punkish.org/v2' } } } \ No newline at end of file diff --git a/index.js b/index.js index 91d2ab4..da46da0 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ // Start this program from the command line with `pm2` - +// // ~/Nodes/punkish$ NODE_ENV=production pm2 start index.js --name zenodeo // ~/Nodes/punkish$ pm2 restart zenodeo @@ -18,21 +18,21 @@ const config = require('config'); const cacheName = config.get('v2.cache.name'); const cachePath = config.get('v2.cache.path'); const zendeoUri = config.get('v2.uri.zenodeo'); + +const Pack = require('./package'); const info = config.get('info'); const swaggeredScheme = config.get('swaggered-scheme'); const port = config.get('port'); - -//const logger = require(config.get('logger')); const plog = require(config.get('plog')); // Generate Swagger-compatible documentation for the app -// The commented options below are listed for completion -// sakes. We don't use them here. +// The commented options below are listed for completeness +// sakes. We just don't need them here. const swaggerOptions = { /******** URLs and plugin **************/ schemes: swaggeredScheme, - //host: 'http://localhost:3030',, + //host: 'http://localhost:3030', //auth: false, //cors: false @@ -41,7 +41,14 @@ const swaggerOptions = { //basePath: '/v2/', //pathPrefixSize: 2, //pathReplacements: [], - info: info, + info: { + title: info.title, + license: info.license, + version: Pack.version, + description: Pack.description, + termsOfService: info.termsOfService, + contact: Pack.author + }, /******** UI **************/ documentationPage: false, @@ -52,7 +59,12 @@ const swaggerOptions = { // Create the server. Everything begins here. const server = new Hapi.server({ + + // Get the value of port from the config settings port: port, + + // Since this application *always* runs behind a proxy, + // the value of host will *always* be 'localhost' host: 'localhost', routes: { cors: true }, cache: [{ @@ -161,6 +173,7 @@ const start = async () => { if (tags.error) { plog.logger({ host: server.info.uri, + //host: host, start: '', end: '', status: 500, @@ -176,6 +189,7 @@ const start = async () => { plog.logger({ host: request.info.host, + //host: host, start: request.info.received, end: request.info.completed, status: request.response.statusCode, diff --git a/package.json b/package.json index 057574f..ef41352 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,23 @@ { "name": "zenodeo", - "version": "2.6.0", + "version": "2.6.1", "description": "`nodejs` interface to the Zenodo/BLR community collection", "main": "index.js", "repository": "https://github.com/punkish/zenodeo", - "author": "Puneet Kishor", + "author": { + "name": "Puneet Kishor", + "email": "punk.kish@gmail.com", + "url": "https://punkish.org" + }, "license": "CC0-1.0", + "homepage": "https://zenodeo.punkish.org", + "bugs": { + "url": "https://github.com/punkish/zenodeo/issues" + }, + "engines": { + "node": ">= 12.0.0", + "npm": ">= 6.0.0" + }, "dependencies": { "@hapi/boom": "^9.1.0", "@hapi/catbox": "^11.1.0",