@mountainpass/addressr 1.1.2 → 1.1.4

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.
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  // Use Node 16 or above to run this script.
3
4
  // `node build.js` will run this script.
4
5
  //
5
6
  // This script will call various NPM commands to build the application
6
7
  // using the Docker images as per the settings below
8
+
7
9
  // Overall
8
10
  // Node 16 on CI server (GitHub Actions) calls this script
9
11
  // This script calls NPM commands.
@@ -24,49 +26,45 @@ actions:
24
26
  "use strict";
25
27
 
26
28
  var _dagger = require("@dagger.io/dagger");
27
-
28
29
  var _envPaths = require("env-paths");
29
-
30
30
  var _envPaths2 = _interopRequireDefault(_envPaths);
31
-
32
31
  var _fs = require("fs");
33
-
34
32
  var _fs2 = _interopRequireDefault(_fs);
35
-
36
33
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
-
38
34
  const cacheDir = `${(0, _envPaths2.default)("", {
39
35
  suffix: ""
40
36
  }).cache}/dagger`;
41
37
  const binLocation = `${cacheDir}/dagger-0.3.9`;
42
-
43
38
  if (!process.env._EXPERIMENTAL_DAGGER_CLI_BIN && _fs2.default.existsSync(binLocation)) {
44
39
  process.env._EXPERIMENTAL_DAGGER_CLI_BIN = binLocation;
45
40
  console.log(`using already downloaded '${binLocation}'`);
46
41
  }
47
-
48
42
  console.log('connecting...');
49
43
  (0, _dagger.connect)(async client => {
50
- console.log('\t...connected'); // get reference to the local project
51
-
44
+ console.log('\t...connected');
45
+ // get reference to the local project
52
46
  client.log;
53
47
  const workspace = client.host().directory("."); //, { exclude: ["node_modules/"] })
54
- // get Node image
55
48
 
49
+ // get Node image
56
50
  const node = client.container().from("node:14.21.2").withMountedDirectory("/workspace", workspace).withWorkdir("/workspace");
57
51
  console.log(await node.withExec(["npm", "--version"]).stdout());
58
- const installed = node; // .withExec(["npm", "install"])
52
+ const installed = node;
53
+ // .withExec(["npm", "install"])
54
+
59
55
  // const exitCode = await installed.exitCode()
60
56
  // console.log({ exitCode });
61
57
  // const stdout = await installed.stdout()
62
58
  // const stderr = await installed.stderr()
63
59
  // const version = await node.withExec(["node", "-v"]).stdout()
60
+
64
61
  // print output
65
62
  // console.log("Hello from Dagger and Node " + version)
66
63
 
67
64
  await installed.withExec(["npm", "run", "genversion"]).file('version.js').export('dagger-version.js');
68
65
  console.log(stdout);
69
66
  console.error(stderr);
67
+
70
68
  /*
71
69
  npm run genversion
72
70
  npm run check-licenses
@@ -74,7 +72,8 @@ console.log('connecting...');
74
72
  npm run cover:rest:nogeo
75
73
  */
76
74
 
77
- installed.withExec(["npm", "run", "build"]); // await runner.exitCode()
75
+ installed.withExec(["npm", "run", "build"]);
76
+ // await runner.exitCode()
78
77
  // .directory("node_modules/")
79
78
  // .export("./dagger_node_modules")
80
79
  });
@@ -7,17 +7,11 @@ exports.ELASTIC_PORT = undefined;
7
7
  exports.dropIndex = dropIndex;
8
8
  exports.initIndex = initIndex;
9
9
  exports.esConnect = esConnect;
10
-
11
10
  var _debug = require("debug");
12
-
13
11
  var _debug2 = _interopRequireDefault(_debug);
14
-
15
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
-
17
13
  const waitPort = require('wait-port');
18
-
19
14
  const elasticsearch = require('@opensearch-project/opensearch');
20
-
21
15
  const logger = (0, _debug2.default)('api');
22
16
  const error = (0, _debug2.default)('error');
23
17
  const ES_INDEX_NAME = process.env.ES_INDEX_NAME || 'addressr';
@@ -26,13 +20,11 @@ const ELASTIC_HOST = process.env.ELASTIC_HOST || '127.0.0.1';
26
20
  const ELASTIC_USERNAME = process.env.ELASTIC_USERNAME || undefined;
27
21
  const ELASTIC_PASSWORD = process.env.ELASTIC_PASSWORD || undefined;
28
22
  const ELASTIC_PROTOCOL = process.env.ELASTIC_PROTOCOL || 'http';
29
-
30
23
  async function dropIndex(esClient) {
31
24
  // eslint-disable-next-line security/detect-non-literal-fs-filename
32
25
  let exists = await esClient.indices.exists({
33
26
  index: ES_INDEX_NAME
34
27
  });
35
-
36
28
  if (exists.body) {
37
29
  const deleteIndexResult = await esClient.indices.delete({
38
30
  index: ES_INDEX_NAME
@@ -41,22 +33,19 @@ async function dropIndex(esClient) {
41
33
  deleteIndexResult
42
34
  });
43
35
  }
44
-
45
- logger('checking if index exists'); // eslint-disable-next-line security/detect-non-literal-fs-filename
46
-
36
+ logger('checking if index exists');
37
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
47
38
  exists = await esClient.indices.exists({
48
39
  index: ES_INDEX_NAME
49
40
  });
50
41
  logger('index exists:', exists);
51
42
  }
52
-
53
43
  async function initIndex(esClient, clear, synonyms) {
54
44
  if (clear) {
55
45
  await dropIndex(esClient);
56
46
  }
57
-
58
- logger('checking if index exists'); // eslint-disable-next-line security/detect-non-literal-fs-filename
59
-
47
+ logger('checking if index exists');
48
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
60
49
  const exists = await esClient.indices.exists({
61
50
  index: ES_INDEX_NAME
62
51
  });
@@ -111,8 +100,8 @@ async function initIndex(esClient, clear, synonyms) {
111
100
  raw: {
112
101
  type: 'keyword'
113
102
  }
114
- } // fielddata: true
115
-
103
+ }
104
+ // fielddata: true
116
105
  },
117
106
  ssla: {
118
107
  type: 'text',
@@ -129,7 +118,6 @@ async function initIndex(esClient, clear, synonyms) {
129
118
  }
130
119
  }
131
120
  };
132
-
133
121
  if (!exists.body) {
134
122
  logger(`creating index: ${ES_INDEX_NAME}`);
135
123
  const indexCreateResult = await esClient.indices.create({
@@ -160,8 +148,8 @@ async function initIndex(esClient, clear, synonyms) {
160
148
  });
161
149
  logger({
162
150
  indexPutMappingResult
163
- }); // eslint-disable-next-line security/detect-non-literal-fs-filename
164
-
151
+ });
152
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
165
153
  const indexOpenResult = await esClient.indices.open({
166
154
  index: ES_INDEX_NAME
167
155
  });
@@ -175,20 +163,17 @@ async function initIndex(esClient, clear, synonyms) {
175
163
  refreshResult
176
164
  });
177
165
  }
178
-
179
166
  const indexGetResult = await esClient.indices.get({
180
167
  index: ES_INDEX_NAME,
181
168
  includeDefaults: true
182
169
  });
183
170
  logger(`indexGetResult:\n${JSON.stringify(indexGetResult, undefined, 2)}`);
184
171
  }
185
-
186
172
  async function esConnect(esport = ELASTIC_PORT, eshost = ELASTIC_HOST, interval = 1000, timeout = 0) {
187
173
  // we keep trying to connect, no matter what
188
174
  // eslint-disable-next-line no-constant-condition
189
175
  while (true) {
190
176
  logger(`trying to reach elastic search on ${eshost}:${esport}...`);
191
-
192
177
  try {
193
178
  const open = await waitPort({
194
179
  host: eshost,
@@ -196,21 +181,23 @@ async function esConnect(esport = ELASTIC_PORT, eshost = ELASTIC_HOST, interval
196
181
  interval,
197
182
  timeout
198
183
  });
199
-
200
184
  if (open) {
201
- logger(`...${eshost}:${esport} is reachable`); // eslint-disable-next-line no-constant-condition
185
+ logger(`...${eshost}:${esport} is reachable`);
202
186
 
187
+ // eslint-disable-next-line no-constant-condition
203
188
  while (true) {
204
189
  try {
205
190
  const node = ELASTIC_USERNAME ? `${ELASTIC_PROTOCOL}://${ELASTIC_USERNAME}:${ELASTIC_PASSWORD}@${eshost}:${esport}` : `${ELASTIC_PROTOCOL}://${eshost}:${esport}`;
206
191
  const esClientOptions = {
207
- node // ...(ELASTIC_USERNAME &&
192
+ node
193
+ // ...(ELASTIC_USERNAME &&
208
194
  // ELASTIC_PASSWORD && {
209
195
  // cloud: {
210
196
  // username: ELASTIC_USERNAME,
211
197
  // password: ELASTIC_PASSWORD
212
198
  // }
213
199
  // })
200
+
214
201
  // host: [
215
202
  // {
216
203
  // host: eshost,
@@ -223,7 +210,6 @@ async function esConnect(esport = ELASTIC_PORT, eshost = ELASTIC_HOST, interval
223
210
  // },
224
211
  // ],
225
212
  // log: 'info',
226
-
227
213
  };
228
214
  const esClient = new elasticsearch.Client(esClientOptions);
229
215
  logger(`connecting elastic search client on ${eshost}:${esport}...`);
@@ -5,19 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getAddress = getAddress;
7
7
  exports.getAddresses = getAddresses;
8
-
9
8
  var _debug = require("debug");
10
-
11
9
  var _debug2 = _interopRequireDefault(_debug);
12
-
13
10
  var _addressService = require("../service/address-service");
14
-
15
11
  var _writer = require("../utils/writer.js");
16
-
17
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
-
19
13
  var logger = (0, _debug2.default)('api');
20
-
21
14
  function getAddress(request, response) {
22
15
  logger('IN getAddress');
23
16
  var addressId = request.swagger.params['addressId'].value;
@@ -30,11 +23,9 @@ function getAddress(request, response) {
30
23
  response.setHeader('link', addressResponse.link.toString());
31
24
  (0, _writer.writeJson)(response, addressResponse.json);
32
25
  }
33
-
34
26
  return;
35
27
  });
36
28
  }
37
-
38
29
  function getAddresses(request, response) {
39
30
  var q = request.swagger.params['q'].value;
40
31
  var p = request.swagger.params['p'].value;
@@ -49,7 +40,6 @@ function getAddresses(request, response) {
49
40
  response.setHeader('link-template', addressesResponse.linkTemplate.toString());
50
41
  (0, _writer.writeJson)(response, addressesResponse.json);
51
42
  }
52
-
53
43
  return;
54
44
  });
55
45
  }
@@ -4,13 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getApiRoot = getApiRoot;
7
-
8
7
  var _DefaultService = require("../service/DefaultService");
9
-
10
8
  var _writer = require("../utils/writer.js");
11
-
12
9
  // import debug from 'debug';
10
+
13
11
  // var logger = debug('api');
12
+
14
13
  function getApiRoot(request, res) {
15
14
  (0, _DefaultService.getApiRoot)().then(function (response) {
16
15
  res.setHeader('link', response.link.toString());
@@ -2,11 +2,8 @@
2
2
  "use strict";
3
3
 
4
4
  const fs = require('fs');
5
-
6
5
  const packageJson = require('../package.json');
7
-
8
6
  const shell = require('shelljs');
9
-
10
7
  const {
11
8
  zip
12
9
  } = require('zip-a-folder');
@@ -30,8 +27,6 @@ TODO: Apparently if you include a node_modules folder in the deployment, AWS wil
30
27
  instead of doing an npm install. This could be even faster, but we haven't tried it yet.
31
28
  See https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-dependencies.html#nodejs-platform-nodemodules
32
29
  **/
33
-
34
-
35
30
  function createPackageJson(context, filepath) {
36
31
  const {
37
32
  name,
@@ -70,12 +65,10 @@ function createPackageJson(context, filepath) {
70
65
  };
71
66
  fs.writeFileSync(filepath, JSON.stringify(newPackageJson, null, 2));
72
67
  }
73
-
74
68
  async function createDeploymentArchive(deploymentDir) {
75
69
  shell.mkdir('-p', deploymentDir);
76
70
  createPackageJson(packageJson, `${deploymentDir}/package.json`);
77
71
  const archiveName = packageJson.name.replace('@', '').replace('/', '-');
78
72
  await zip(`${deploymentDir}/`, `${archiveName}-deployment-${packageJson.version}.zip`);
79
73
  }
80
-
81
74
  createDeploymentArchive('./deployment');
package/lib/loader.js CHANGED
@@ -1,24 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _debug = require("debug");
4
-
5
4
  var _debug2 = _interopRequireDefault(_debug);
6
-
7
5
  var _elasticsearch = require("./client/elasticsearch");
8
-
9
6
  var _addressService = require("./service/address-service");
10
-
11
7
  var _printVersion = require("./service/printVersion");
12
-
13
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
9
  const logger = (0, _debug2.default)('api');
16
10
  const error = (0, _debug2.default)('error');
17
-
18
11
  if (process.env.DEBUG == undefined) {
19
12
  _debug2.default.enable('api,error');
20
13
  }
21
-
22
14
  const start = process.hrtime();
23
15
  (0, _elasticsearch.esConnect)().then(() => {
24
16
  logger('es client connected');
package/lib/server.js CHANGED
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _debug = require("debug");
4
-
5
4
  var _debug2 = _interopRequireDefault(_debug);
6
-
7
5
  var _elasticsearch = require("./client/elasticsearch");
8
-
9
6
  var _printVersion = require("./service/printVersion");
10
-
11
7
  var _swagger = require("./swagger");
12
-
13
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
-
15
9
  const logger = (0, _debug2.default)('api');
16
10
  (0, _swagger.startServer)().then(() => {
17
11
  logger('connecting es client');
@@ -4,34 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getApiRoot = getApiRoot;
7
-
8
7
  var _debug = require("debug");
9
-
10
8
  var _debug2 = _interopRequireDefault(_debug);
11
-
12
9
  var _httpLinkHeader = require("http-link-header");
13
-
14
10
  var _httpLinkHeader2 = _interopRequireDefault(_httpLinkHeader);
15
-
16
11
  var _setLinkOptions = require("./setLinkOptions");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  var logger = (0, _debug2.default)('api');
14
+
21
15
  /**
22
16
  * API Root
23
17
  * returns a list of available APIs within the `Link` headers
24
18
  *
25
19
  * returns Root
26
20
  **/
27
-
28
21
  async function getApiRoot() {
29
22
  const paths = Object.keys(global.swaggerDoc.paths).filter(p => global.swaggerDoc.paths[p].get !== undefined && global.swaggerDoc.paths[p].get['x-root-rel'] !== undefined);
30
23
  const link = new _httpLinkHeader2.default();
31
24
  paths.forEach(p => {
32
25
  const op = global.swaggerDoc.paths[p].get;
33
-
34
- if (op.parameters && op.parameters.find(parameter => parameter.required === true)) {// skip
26
+ if (op.parameters && op.parameters.find(parameter => parameter.required === true)) {
27
+ // skip
35
28
  } else {
36
29
  link.set({
37
30
  rel: op['x-root-rel'],