@basemaps/server 6.21.1 → 6.22.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.22.0](https://github.com/linz/basemaps/compare/v6.21.1...v6.22.0) (2022-03-20)
7
+
8
+
9
+ ### Features
10
+
11
+ * **server:** support loading config from dynamodb ([#2119](https://github.com/linz/basemaps/issues/2119)) ([e550505](https://github.com/linz/basemaps/commit/e550505193df3cf148313e364c7c0670e16756e2))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [6.21.1](https://github.com/linz/basemaps/compare/v6.21.0...v6.21.1) (2022-03-17)
7
18
 
8
19
  **Note:** Version bump only for package @basemaps/server
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ if (process.env.AWS_REGION == null) process.env.AWS_REGION = process.env.AWS_DEFAULT_REGION;
4
+
3
5
  import { BasemapsServerCommand } from '../build/cli.js';
4
6
  import Errors from '@oclif/errors/handle.js';
5
7
 
package/build/cli.d.ts CHANGED
@@ -1,14 +1,16 @@
1
- import { Command } from '@oclif/command';
1
+ import { Command, flags } from '@oclif/command';
2
2
  export declare class BasemapsServerCommand extends Command {
3
3
  static description: string;
4
4
  static flags: {
5
5
  verbose: import("@oclif/parser/lib/flags").IBooleanFlag<boolean>;
6
6
  port: import("@oclif/parser/lib/flags").IOptionFlag<number>;
7
+ dynamo: flags.IOptionFlag<string | undefined>;
7
8
  };
8
9
  static args: {
9
10
  name: string;
10
11
  required: boolean;
11
12
  }[];
13
+ loadFromPath(configPath: string, serverUrl: string): Promise<void>;
12
14
  run(): Promise<void>;
13
15
  }
14
16
  //# sourceMappingURL=cli.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAS,MAAM,gBAAgB,CAAC;AAkBhD,qBAAa,qBAAsB,SAAQ,OAAO;IAChD,MAAM,CAAC,WAAW,SAAuD;IACzE,MAAM,CAAC,KAAK;;;MAAwE;IAEpF,MAAM,CAAC,IAAI;;;QAA4C;IAEjD,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0D3B"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAkBhD,qBAAa,qBAAsB,SAAQ,OAAO;IAChD,MAAM,CAAC,WAAW,SAAuD;IACzE,MAAM,CAAC,KAAK;;;;MAIV;IAEF,MAAM,CAAC,IAAI;;;QAA6C;IAElD,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8ClE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA0B3B"}
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Configure the logging before importing everything
2
- import { ConfigPrefix, ConfigProviderMemory, parseRgba } from '@basemaps/config';
2
+ import { ConfigPrefix, ConfigProviderDynamo, ConfigProviderMemory, parseRgba } from '@basemaps/config';
3
3
  import { TileSetLocal } from '@basemaps/lambda-tiler/build/cli/tile.set.local.js';
4
4
  import { TileSets } from '@basemaps/lambda-tiler/build/tile.set.cache.js';
5
5
  import { Config, Env, LogConfig } from '@basemaps/shared';
@@ -20,19 +20,11 @@ const BaseProvider = {
20
20
  },
21
21
  };
22
22
  export class BasemapsServerCommand extends Command {
23
- async run() {
24
- var _a;
25
- const { args, flags } = this.parse(BasemapsServerCommand);
26
- if (flags.verbose)
27
- logger.level = 'debug';
28
- const ServerUrl = `http://localhost:${flags.port}`;
29
- // Force a default url base so WMTS requests know their relative url
30
- process.env[Env.PublicUrlBase] = (_a = process.env[Env.PublicUrlBase]) !== null && _a !== void 0 ? _a : `http://localhost:${flags.port}`;
31
- logger.info({ path: args.configPath }, 'Starting Server');
23
+ async loadFromPath(configPath, serverUrl) {
32
24
  const config = new ConfigProviderMemory();
33
25
  Config.setConfigProvider(config);
34
26
  const tifSets = new Map();
35
- for await (const file of fsa.listDetails(args.configPath)) {
27
+ for await (const file of fsa.listDetails(configPath)) {
36
28
  const lowerPath = file.path.toLowerCase();
37
29
  if (lowerPath.endsWith('.tiff') || lowerPath.endsWith('.tif')) {
38
30
  const tiffPath = dirname(file.path);
@@ -42,7 +34,7 @@ export class BasemapsServerCommand extends Command {
42
34
  const tsl = new TileSetLocal(tileSet, tiffPath);
43
35
  await tsl.load();
44
36
  TileSets.add(tsl, new Date('3000-01-01').getTime());
45
- const wmtsUrl = `${ServerUrl}/v1/tiles/${tileSet}/WMTSCapabilities.xml`;
37
+ const wmtsUrl = `${serverUrl}/v1/tiles/${tileSet}/WMTSCapabilities.xml`;
46
38
  logger.info({ tileSetId: tileSet, wmtsUrl }, 'TileSet:Loaded');
47
39
  if (!config.objects.has('pv_linz'))
48
40
  config.put(BaseProvider);
@@ -66,14 +58,40 @@ export class BasemapsServerCommand extends Command {
66
58
  const tileSet = Config.unprefix(ConfigPrefix.TileSet, jsonData.id);
67
59
  if (jsonData.name == null)
68
60
  jsonData.name = tileSet;
69
- const wmtsUrl = `${ServerUrl}/v1/tiles/${tileSet}/WMTSCapabilities.xml`;
61
+ const wmtsUrl = `${serverUrl}/v1/tiles/${tileSet}/WMTSCapabilities.xml`;
70
62
  logger.info({ tileSetId: jsonData.id, wmtsUrl }, 'TileSet:Loaded');
71
63
  }
64
+ }
65
+ async run() {
66
+ var _a;
67
+ const { args, flags } = this.parse(BasemapsServerCommand);
68
+ if (flags.verbose)
69
+ logger.level = 'debug';
70
+ if (args.configPath == null && flags.dynamo == null) {
71
+ }
72
+ const ServerUrl = `http://localhost:${flags.port}`;
73
+ if (args.configPath != null) {
74
+ logger.info({ path: args.configPath }, 'Starting Server');
75
+ await this.loadFromPath(args.configPath, ServerUrl);
76
+ }
77
+ else if (flags.dynamo != null) {
78
+ logger.info({ dynamo: flags.dynamo }, 'Starting Server');
79
+ Config.setConfigProvider(new ConfigProviderDynamo(flags.dynamo));
80
+ }
81
+ else {
82
+ throw new Error('Either a configuration path or dynamodb table name must be supplied');
83
+ }
84
+ // Force a default url base so WMTS requests know their relative url
85
+ process.env[Env.PublicUrlBase] = (_a = process.env[Env.PublicUrlBase]) !== null && _a !== void 0 ? _a : `http://localhost:${flags.port}`;
72
86
  BasemapsServer.listen(flags.port, () => {
73
87
  logger.info({ url: ServerUrl }, 'ServerStarted');
74
88
  });
75
89
  }
76
90
  }
77
91
  BasemapsServerCommand.description = 'Create a WMTS/XYZ Tile server for basemaps config';
78
- BasemapsServerCommand.flags = { verbose: flags.boolean(), port: flags.integer({ default: 5000 }) };
79
- BasemapsServerCommand.args = [{ name: 'configPath', required: true }];
92
+ BasemapsServerCommand.flags = {
93
+ verbose: flags.boolean(),
94
+ port: flags.integer({ default: 5000 }),
95
+ dynamo: flags.string({ description: 'Dynamodb table', required: false }),
96
+ };
97
+ BasemapsServerCommand.args = [{ name: 'configPath', required: false }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basemaps/server",
3
- "version": "6.21.1",
3
+ "version": "6.22.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/linz/basemaps.git",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@basemaps/config": "^6.21.1",
36
36
  "@basemaps/geo": "^6.21.1",
37
- "@basemaps/lambda-tiler": "^6.21.1",
38
- "@basemaps/shared": "^6.21.1",
37
+ "@basemaps/lambda-tiler": "^6.22.0",
38
+ "@basemaps/shared": "^6.22.0",
39
39
  "@linzjs/lambda": "^2.0.0",
40
40
  "@oclif/command": "^1.8.0",
41
41
  "express": "^4.17.1",
@@ -44,5 +44,5 @@
44
44
  "devDependencies": {
45
45
  "@types/express": "^4.17.13"
46
46
  },
47
- "gitHead": "69d69648ab7b37623ab14f70d29b449d14db5a7f"
47
+ "gitHead": "b85a4a628bcdfea657a37de97faa23dde5c34798"
48
48
  }