Skip to content

Commit

Permalink
fixed version info so it is retrieved from package.json instead of co…
Browse files Browse the repository at this point in the history
…nfig
  • Loading branch information
punkish committed May 2, 2020
1 parent 7bdb1c5 commit c6f9b2a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 35 deletions.
37 changes: 21 additions & 16 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'
},
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
Expand All @@ -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'
},

Expand All @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {

v1: {
uri: {
zenodeo: `${host}/v1`
zenodeo: 'https://zenodeo.punkish.org/v1'
}
},

Expand All @@ -25,7 +25,7 @@ module.exports = {
},

uri: {
zenodeo: `${host}/v2`
zenodeo: 'https://zenodeo.punkish.org/v2'
}
},

Expand Down
10 changes: 2 additions & 8 deletions config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}
}
28 changes: 21 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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,
Expand All @@ -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: [{
Expand Down Expand Up @@ -161,6 +173,7 @@ const start = async () => {
if (tags.error) {
plog.logger({
host: server.info.uri,
//host: host,
start: '',
end: '',
status: 500,
Expand All @@ -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,
Expand Down
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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",
Expand Down

0 comments on commit c6f9b2a

Please sign in to comment.