Skip to content

Commit c6f9b2a

Browse files
committed
fixed version info so it is retrieved from package.json instead of config
1 parent 7bdb1c5 commit c6f9b2a

File tree

5 files changed

+60
-35
lines changed

5 files changed

+60
-35
lines changed

config/default.js

+21-16
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,36 @@
88

99
const path = require('path');
1010
const cwd = process.cwd();
11-
const host = 'http://localhost:3030';
1211

1312
module.exports = {
13+
14+
/* This is the internal URI info ***********************/
15+
16+
// The internal scheme is *always* 'http', so
17+
// no need to configure it
18+
/* scheme: 'http', */
19+
20+
// The internal host is *always* 'localhost' so
21+
// no need to configure it
22+
/* host: 'localhost', */
23+
24+
// The port can change depending on the server
25+
port: 3030,
26+
27+
loglevel: 'INFO',
1428

15-
// API info that is used in the /docs pages by hapi-swaggered
29+
// API info that is used in the /docs pages by hapi-swaggered.
30+
// Note: this info is supplemented with info from package.json
1631
info: {
1732
title: 'Zenodeo API documentation for BLR',
18-
description: '`nodejs` interface to the Zenodo/BLR community collection',
19-
version: '2.6.0',
2033
termsOfService: '/tos',
21-
contact: {
22-
name: 'Puneet Kishor',
23-
url: 'https://punkish.org/About',
24-
25-
},
26-
license: {
34+
license: {
2735
name: 'CC0 Public Domain Dedication',
2836
url: 'https://creativecommons.org/publicdomain/zero/1.0/legalcode'
2937
}
3038
},
3139

3240
'swaggered-scheme': [ 'http' ],
33-
34-
port: 3030,
35-
loglevel: 'INFO',
3641

3742
// all queries that take longer than the
3843
// following (in ms) are displayed in red
@@ -46,8 +51,9 @@ module.exports = {
4651
on: true
4752
},
4853

54+
// These are the external URIs
4955
uri: {
50-
zenodeo: `${host}/v1`,
56+
zenodeo: 'http://localhost:3030/v1',
5157
zenodo: 'https://zenodo.org/api'
5258
},
5359

@@ -68,11 +74,10 @@ module.exports = {
6874
},
6975

7076
uri: {
71-
zenodeo: `${host}/v2`,
77+
zenodeo: 'http://localhost:3030/v2',
7278
zenodo: 'https://zenodo.org/api'
7379
},
7480

75-
7681
dataDict: path.join(cwd, 'dataDictionary', 'data-dictionary.js'),
7782
schema: path.join(cwd, 'api', 'v2', 'schema.js')
7883

config/production.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515

1616
v1: {
1717
uri: {
18-
zenodeo: `${host}/v1`
18+
zenodeo: 'https://zenodeo.punkish.org/v1'
1919
}
2020
},
2121

@@ -25,7 +25,7 @@ module.exports = {
2525
},
2626

2727
uri: {
28-
zenodeo: `${host}/v2`
28+
zenodeo: 'https://zenodeo.punkish.org/v2'
2929
}
3030
},
3131

config/test.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,19 @@
77
*
88
**************************************************************/
99

10-
const host = 'http://z2.punkish.org';
11-
1210
module.exports = {
1311

1412
loglevel: 'ERROR',
1513

1614
v1: {
1715
uri: {
18-
zenodeo: `${host}/v1`
16+
zenodeo: 'http://z2.punkish.org/v1'
1917
}
2018
},
2119

2220
v2: {
23-
// cache: {
24-
// on: false
25-
// },
26-
2721
uri: {
28-
zenodeo: `${host}/v2`
22+
zenodeo: 'http://z2.punkish.org/v2'
2923
}
3024
}
3125
}

index.js

+21-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
// Start this program from the command line with `pm2`
5-
5+
//
66
// ~/Nodes/punkish$ NODE_ENV=production pm2 start index.js --name zenodeo
77
// ~/Nodes/punkish$ pm2 restart zenodeo
88

@@ -18,21 +18,21 @@ const config = require('config');
1818
const cacheName = config.get('v2.cache.name');
1919
const cachePath = config.get('v2.cache.path');
2020
const zendeoUri = config.get('v2.uri.zenodeo');
21+
22+
const Pack = require('./package');
2123
const info = config.get('info');
2224
const swaggeredScheme = config.get('swaggered-scheme');
2325
const port = config.get('port');
24-
25-
//const logger = require(config.get('logger'));
2626
const plog = require(config.get('plog'));
2727

2828
// Generate Swagger-compatible documentation for the app
29-
// The commented options below are listed for completion
30-
// sakes. We don't use them here.
29+
// The commented options below are listed for completeness
30+
// sakes. We just don't need them here.
3131
const swaggerOptions = {
3232

3333
/******** URLs and plugin **************/
3434
schemes: swaggeredScheme,
35-
//host: 'http://localhost:3030',,
35+
//host: 'http://localhost:3030',
3636
//auth: false,
3737
//cors: false
3838

@@ -41,7 +41,14 @@ const swaggerOptions = {
4141
//basePath: '/v2/',
4242
//pathPrefixSize: 2,
4343
//pathReplacements: [],
44-
info: info,
44+
info: {
45+
title: info.title,
46+
license: info.license,
47+
version: Pack.version,
48+
description: Pack.description,
49+
termsOfService: info.termsOfService,
50+
contact: Pack.author
51+
},
4552

4653
/******** UI **************/
4754
documentationPage: false,
@@ -52,7 +59,12 @@ const swaggerOptions = {
5259

5360
// Create the server. Everything begins here.
5461
const server = new Hapi.server({
62+
63+
// Get the value of port from the config settings
5564
port: port,
65+
66+
// Since this application *always* runs behind a proxy,
67+
// the value of host will *always* be 'localhost'
5668
host: 'localhost',
5769
routes: { cors: true },
5870
cache: [{
@@ -161,6 +173,7 @@ const start = async () => {
161173
if (tags.error) {
162174
plog.logger({
163175
host: server.info.uri,
176+
//host: host,
164177
start: '',
165178
end: '',
166179
status: 500,
@@ -176,6 +189,7 @@ const start = async () => {
176189

177190
plog.logger({
178191
host: request.info.host,
192+
//host: host,
179193
start: request.info.received,
180194
end: request.info.completed,
181195
status: request.response.statusCode,

package.json

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
{
22
"name": "zenodeo",
3-
"version": "2.6.0",
3+
"version": "2.6.1",
44
"description": "`nodejs` interface to the Zenodo/BLR community collection",
55
"main": "index.js",
66
"repository": "https://github.com/punkish/zenodeo",
7-
"author": "Puneet Kishor",
7+
"author": {
8+
"name": "Puneet Kishor",
9+
"email": "[email protected]",
10+
"url": "https://punkish.org"
11+
},
812
"license": "CC0-1.0",
13+
"homepage": "https://zenodeo.punkish.org",
14+
"bugs": {
15+
"url": "https://github.com/punkish/zenodeo/issues"
16+
},
17+
"engines": {
18+
"node": ">= 12.0.0",
19+
"npm": ">= 6.0.0"
20+
},
921
"dependencies": {
1022
"@hapi/boom": "^9.1.0",
1123
"@hapi/catbox": "^11.1.0",

0 commit comments

Comments
 (0)