@basemaps/server 6.21.1 → 6.23.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 +27 -0
- package/bin/basemaps-server.js +2 -0
- package/build/cli.d.ts +5 -5
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +32 -15
- package/build/server.d.ts +2 -1
- package/build/server.d.ts.map +1 -1
- package/build/server.js +10 -8
- package/package.json +5 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.23.0](https://github.com/linz/basemaps/compare/v6.22.1...v6.23.0) (2022-04-04)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @basemaps/server
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [6.22.1](https://github.com/linz/basemaps/compare/v6.22.0...v6.22.1) (2022-03-23)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @basemaps/server
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# [6.22.0](https://github.com/linz/basemaps/compare/v6.21.1...v6.22.0) (2022-03-20)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **server:** support loading config from dynamodb ([#2119](https://github.com/linz/basemaps/issues/2119)) ([e550505](https://github.com/linz/basemaps/commit/e550505193df3cf148313e364c7c0670e16756e2))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [6.21.1](https://github.com/linz/basemaps/compare/v6.21.0...v6.21.1) (2022-03-17)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @basemaps/server
|
package/bin/basemaps-server.js
CHANGED
package/build/cli.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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>;
|
|
8
|
+
config: flags.IOptionFlag<string | undefined>;
|
|
7
9
|
};
|
|
8
|
-
static args:
|
|
9
|
-
|
|
10
|
-
required: boolean;
|
|
11
|
-
}[];
|
|
10
|
+
static args: never[];
|
|
11
|
+
loadFromPath(configPath: string, serverUrl: string): Promise<void>;
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=cli.d.ts.map
|
package/build/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,
|
|
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;;;;;MAKV;IAEF,MAAM,CAAC,IAAI,UAAM;IAEX,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8ClE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsB3B"}
|
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
|
|
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(
|
|
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 = `${
|
|
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,39 @@ 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 = `${
|
|
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 { flags } = this.parse(BasemapsServerCommand);
|
|
68
|
+
if (flags.verbose)
|
|
69
|
+
logger.level = 'debug';
|
|
70
|
+
const ServerUrl = `http://localhost:${flags.port}`;
|
|
71
|
+
if (flags.config != null) {
|
|
72
|
+
logger.info({ path: flags.config }, 'Starting Server');
|
|
73
|
+
await this.loadFromPath(flags.config, ServerUrl);
|
|
74
|
+
}
|
|
75
|
+
else if (flags.dynamo != null) {
|
|
76
|
+
logger.info({ dynamo: flags.dynamo }, 'Starting Server');
|
|
77
|
+
Config.setConfigProvider(new ConfigProviderDynamo(flags.dynamo));
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new Error('Either a configuration path or dynamodb table name must be supplied');
|
|
81
|
+
}
|
|
82
|
+
// Force a default url base so WMTS requests know their relative url
|
|
83
|
+
process.env[Env.PublicUrlBase] = (_a = process.env[Env.PublicUrlBase]) !== null && _a !== void 0 ? _a : `http://localhost:${flags.port}`;
|
|
72
84
|
BasemapsServer.listen(flags.port, () => {
|
|
73
85
|
logger.info({ url: ServerUrl }, 'ServerStarted');
|
|
74
86
|
});
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
BasemapsServerCommand.description = 'Create a WMTS/XYZ Tile server for basemaps config';
|
|
78
|
-
BasemapsServerCommand.flags = {
|
|
79
|
-
|
|
90
|
+
BasemapsServerCommand.flags = {
|
|
91
|
+
verbose: flags.boolean(),
|
|
92
|
+
port: flags.integer({ default: 5000 }),
|
|
93
|
+
dynamo: flags.string({ description: 'Dynamodb table', required: false }),
|
|
94
|
+
config: flags.string({ description: 'Configuration path', required: false }),
|
|
95
|
+
};
|
|
96
|
+
BasemapsServerCommand.args = [];
|
package/build/server.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const BasemapsServer: import("fastify").FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance> & PromiseLike<import("fastify").FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance>>;
|
|
2
3
|
//# sourceMappingURL=server.d.ts.map
|
package/build/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,cAAc,kVAAY,CAAC"}
|
package/build/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { handler } from '@basemaps/lambda-tiler';
|
|
2
|
-
import ulid from 'ulid';
|
|
3
|
-
import express from 'express';
|
|
4
2
|
import { lf } from '@linzjs/lambda';
|
|
5
|
-
|
|
3
|
+
import fastify from 'fastify';
|
|
4
|
+
import ulid from 'ulid';
|
|
5
|
+
export const BasemapsServer = fastify();
|
|
6
6
|
function isAlbResult(r) {
|
|
7
7
|
if (typeof r !== 'object')
|
|
8
8
|
return false;
|
|
@@ -15,25 +15,27 @@ BasemapsServer.get('/v1/*', async (req, res) => {
|
|
|
15
15
|
const event = {
|
|
16
16
|
httpMethod: 'GET',
|
|
17
17
|
requestContext: { elb: { targetGroupArn: 'arn:fake' } },
|
|
18
|
-
path: req.
|
|
18
|
+
path: req.url,
|
|
19
19
|
headers: req.headers,
|
|
20
20
|
queryStringParameters: req.query,
|
|
21
21
|
body: null,
|
|
22
22
|
isBase64Encoded: false,
|
|
23
23
|
};
|
|
24
|
-
if (req.query
|
|
25
|
-
req.query
|
|
24
|
+
if (req.query.api == null)
|
|
25
|
+
req.query.api = 'c' + instanceId;
|
|
26
26
|
handler(event, {}, (err, r) => {
|
|
27
27
|
var _a;
|
|
28
28
|
if (err || !isAlbResult(r)) {
|
|
29
29
|
lf.Logger.fatal({ err }, 'RequestFailed');
|
|
30
|
-
|
|
30
|
+
res.send(err);
|
|
31
|
+
return;
|
|
31
32
|
}
|
|
32
33
|
res.status(r.statusCode);
|
|
33
34
|
for (const [key, value] of Object.entries((_a = r.headers) !== null && _a !== void 0 ? _a : {}))
|
|
34
35
|
res.header(key, String(value));
|
|
35
36
|
if (r.body)
|
|
36
37
|
res.send(Buffer.from(r.body, r.isBase64Encoded ? 'base64' : 'utf8'));
|
|
37
|
-
|
|
38
|
+
else
|
|
39
|
+
res.send('Not found');
|
|
38
40
|
});
|
|
39
41
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.23.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -34,15 +34,12 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@basemaps/config": "^6.21.1",
|
|
36
36
|
"@basemaps/geo": "^6.21.1",
|
|
37
|
-
"@basemaps/lambda-tiler": "^6.
|
|
38
|
-
"@basemaps/shared": "^6.
|
|
37
|
+
"@basemaps/lambda-tiler": "^6.23.0",
|
|
38
|
+
"@basemaps/shared": "^6.23.0",
|
|
39
39
|
"@linzjs/lambda": "^2.0.0",
|
|
40
40
|
"@oclif/command": "^1.8.0",
|
|
41
|
-
"
|
|
41
|
+
"fastify": "^3.27.4",
|
|
42
42
|
"pretty-json-log": "^1.0.0"
|
|
43
43
|
},
|
|
44
|
-
"
|
|
45
|
-
"@types/express": "^4.17.13"
|
|
46
|
-
},
|
|
47
|
-
"gitHead": "69d69648ab7b37623ab14f70d29b449d14db5a7f"
|
|
44
|
+
"gitHead": "5c956ba1b1f87c1712fcc4f9d4afc20e7a427285"
|
|
48
45
|
}
|