@basemaps/server 6.9.1 → 6.10.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 +17 -0
- package/bin/basemaps-server.js +8 -0
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +20 -24
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -5
- package/build/server.js +14 -18
- package/package.json +13 -9
- package/bin/basemaps-server +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,23 @@
|
|
|
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.10.0](https://github.com/linz/basemaps/compare/v6.9.1...v6.10.0) (2021-09-22)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **lambda-tiler:** move to NZTM2000Quad for health check endpoint ([#1867](https://github.com/linz/basemaps/issues/1867)) ([d4613f0](https://github.com/linz/basemaps/commit/d4613f04f1081f785831488ea53bc8d8da7aae70))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* replace s3fs with chunkd/fs ([#1859](https://github.com/linz/basemaps/issues/1859)) ([9b6f2d3](https://github.com/linz/basemaps/commit/9b6f2d3609c336f96c2ae32246f241cb396e71c8))
|
|
17
|
+
* switch to esm modules ([#1857](https://github.com/linz/basemaps/issues/1857)) ([75bdff8](https://github.com/linz/basemaps/commit/75bdff8da35104f10f6b6ecf58a2c6006245af6e))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
6
23
|
## [6.9.1](https://github.com/linz/basemaps/compare/v6.9.0...v6.9.1) (2021-09-09)
|
|
7
24
|
|
|
8
25
|
**Note:** Version bump only for package @basemaps/server
|
package/build/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAS,MAAM,gBAAgB,CAAC;AAShD,qBAAa,qBAAsB,SAAQ,OAAO;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAS,MAAM,gBAAgB,CAAC;AAShD,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;CAuC3B"}
|
package/build/cli.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const pretty_json_log_1 = require("pretty-json-log");
|
|
9
|
-
const config_2 = require("@basemaps/config");
|
|
10
|
-
const server_1 = require("./server");
|
|
1
|
+
import { ConfigProviderMemory, parseRgba } from '@basemaps/config';
|
|
2
|
+
import { Config, Env, LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { fsa } from '@linzjs/s3fs';
|
|
4
|
+
import { Command, flags } from '@oclif/command';
|
|
5
|
+
import { PrettyTransform } from 'pretty-json-log';
|
|
6
|
+
import { ConfigPrefix } from '@basemaps/config';
|
|
7
|
+
import { BasemapsServer } from './server.js';
|
|
11
8
|
if (process.stdout.isTTY)
|
|
12
|
-
|
|
13
|
-
const logger =
|
|
14
|
-
class BasemapsServerCommand extends
|
|
9
|
+
LogConfig.setOutputStream(PrettyTransform.stream());
|
|
10
|
+
const logger = LogConfig.get();
|
|
11
|
+
export class BasemapsServerCommand extends Command {
|
|
15
12
|
async run() {
|
|
16
13
|
var _a;
|
|
17
14
|
const { args, flags } = this.parse(BasemapsServerCommand);
|
|
@@ -19,15 +16,15 @@ class BasemapsServerCommand extends command_1.Command {
|
|
|
19
16
|
logger.level = 'debug';
|
|
20
17
|
const ServerUrl = `http://localhost:${flags.port}`;
|
|
21
18
|
// Force a default url base so WMTS requests know their relative url
|
|
22
|
-
process.env[
|
|
19
|
+
process.env[Env.PublicUrlBase] = (_a = process.env[Env.PublicUrlBase]) !== null && _a !== void 0 ? _a : `http://localhost:${flags.port}`;
|
|
23
20
|
logger.info({ path: args.configPath }, 'Starting Server');
|
|
24
|
-
const config = new
|
|
25
|
-
|
|
26
|
-
for await (const file of
|
|
21
|
+
const config = new ConfigProviderMemory();
|
|
22
|
+
Config.setConfigProvider(config);
|
|
23
|
+
for await (const file of fsa.listDetails(args.configPath)) {
|
|
27
24
|
if (!file.path.endsWith('.json'))
|
|
28
25
|
continue;
|
|
29
26
|
logger.trace({ path: file.path, size: file.size }, 'Config:Load');
|
|
30
|
-
const jsonData = await
|
|
27
|
+
const jsonData = await fsa.read(file.path).then((c) => JSON.parse(c.toString()));
|
|
31
28
|
if (jsonData.id == null) {
|
|
32
29
|
logger.warn({ path: file.path }, 'Config:Invalid Missing "id"');
|
|
33
30
|
continue;
|
|
@@ -36,22 +33,21 @@ class BasemapsServerCommand extends command_1.Command {
|
|
|
36
33
|
jsonData.updatedAt = Date.now();
|
|
37
34
|
// TODO we should really use something like zod to validate this
|
|
38
35
|
config.put(jsonData);
|
|
39
|
-
if (!
|
|
36
|
+
if (!Config.TileSet.is(jsonData) || !Config.isTileSetRaster(jsonData))
|
|
40
37
|
continue;
|
|
41
38
|
if (typeof jsonData.background === 'string')
|
|
42
|
-
jsonData.background =
|
|
43
|
-
const tileSet =
|
|
39
|
+
jsonData.background = parseRgba(jsonData.background);
|
|
40
|
+
const tileSet = Config.unprefix(ConfigPrefix.TileSet, jsonData.id);
|
|
44
41
|
if (jsonData.name == null)
|
|
45
42
|
jsonData.name = tileSet;
|
|
46
43
|
const wmtsUrl = `${ServerUrl}/v1/tiles/${tileSet}/WMTSCapabilities.xml`;
|
|
47
44
|
logger.info({ tileSetId: jsonData.id, wmtsUrl }, 'TileSet:Loaded');
|
|
48
45
|
}
|
|
49
|
-
|
|
46
|
+
BasemapsServer.listen(flags.port, () => {
|
|
50
47
|
logger.info({ url: ServerUrl }, 'ServerStarted');
|
|
51
48
|
});
|
|
52
49
|
}
|
|
53
50
|
}
|
|
54
|
-
exports.BasemapsServerCommand = BasemapsServerCommand;
|
|
55
51
|
BasemapsServerCommand.description = 'Create a WMTS/XYZ Tile server for basemaps config';
|
|
56
|
-
BasemapsServerCommand.flags = { verbose:
|
|
52
|
+
BasemapsServerCommand.flags = { verbose: flags.boolean(), port: flags.integer({ default: 5000 }) };
|
|
57
53
|
BasemapsServerCommand.args = [{ name: 'configPath', required: true }];
|
package/build/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BasemapsServer } from './server';
|
|
1
|
+
export { BasemapsServer } from './server.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BasemapsServer = void 0;
|
|
4
|
-
var server_1 = require("./server");
|
|
5
|
-
Object.defineProperty(exports, "BasemapsServer", { enumerable: true, get: function () { return server_1.BasemapsServer; } });
|
|
1
|
+
export { BasemapsServer } from './server.js';
|
package/build/server.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const express_1 = tslib_1.__importDefault(require("express"));
|
|
9
|
-
const shared_1 = require("@basemaps/shared");
|
|
10
|
-
exports.BasemapsServer = express_1.default();
|
|
11
|
-
exports.BasemapsServer.get('/v1/*', async (req, res) => {
|
|
1
|
+
import { HttpHeader, HttpHeaderRequestId, LambdaAlbRequest } from '@linzjs/lambda';
|
|
2
|
+
import { handleRequest } from '@basemaps/lambda-tiler';
|
|
3
|
+
import * as ulid from 'ulid';
|
|
4
|
+
import express from 'express';
|
|
5
|
+
import { LogConfig } from '@basemaps/shared';
|
|
6
|
+
export const BasemapsServer = express();
|
|
7
|
+
BasemapsServer.get('/v1/*', async (req, res) => {
|
|
12
8
|
const startTime = Date.now();
|
|
13
9
|
const requestId = ulid.ulid();
|
|
14
|
-
const logger =
|
|
15
|
-
const ctx = new
|
|
10
|
+
const logger = LogConfig.get().child({ id: requestId });
|
|
11
|
+
const ctx = new LambdaAlbRequest({
|
|
16
12
|
httpMethod: 'get',
|
|
17
13
|
path: req.path,
|
|
18
14
|
queryStringParameters: req.query,
|
|
19
15
|
}, {}, logger);
|
|
20
|
-
if (ctx.header(
|
|
21
|
-
ctx.headers.set(
|
|
16
|
+
if (ctx.header(HttpHeaderRequestId.RequestId) == null) {
|
|
17
|
+
ctx.headers.set(HttpHeaderRequestId.RequestId, 'c' + requestId);
|
|
22
18
|
}
|
|
23
|
-
const ifNoneMatch = req.header(
|
|
19
|
+
const ifNoneMatch = req.header(HttpHeader.IfNoneMatch);
|
|
24
20
|
if (ifNoneMatch != null && !Array.isArray(ifNoneMatch)) {
|
|
25
|
-
ctx.headers.set(
|
|
21
|
+
ctx.headers.set(HttpHeader.IfNoneMatch.toLowerCase(), ifNoneMatch);
|
|
26
22
|
}
|
|
27
23
|
try {
|
|
28
|
-
const data = await
|
|
24
|
+
const data = await handleRequest(ctx);
|
|
29
25
|
res.status(data.status);
|
|
30
26
|
if (data.headers) {
|
|
31
27
|
for (const [header, value] of data.headers) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
"url": "https://linz.govt.nz",
|
|
12
12
|
"organization": true
|
|
13
13
|
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
17
|
+
},
|
|
14
18
|
"license": "MIT",
|
|
15
19
|
"main": "./build/index.js",
|
|
16
20
|
"types": "./build/index.d.ts",
|
|
@@ -21,24 +25,24 @@
|
|
|
21
25
|
"access": "public"
|
|
22
26
|
},
|
|
23
27
|
"bin": {
|
|
24
|
-
"basemaps-server": "./bin/basemaps-server"
|
|
28
|
+
"basemaps-server": "./bin/basemaps-server.js"
|
|
25
29
|
},
|
|
26
30
|
"files": [
|
|
27
31
|
"build/",
|
|
28
32
|
"bin/"
|
|
29
33
|
],
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@basemaps/config": "^6.
|
|
32
|
-
"@basemaps/geo": "^6.
|
|
33
|
-
"@basemaps/lambda-tiler": "^6.
|
|
34
|
-
"@basemaps/shared": "^6.
|
|
35
|
-
"@linzjs/lambda": "^
|
|
35
|
+
"@basemaps/config": "^6.10.0",
|
|
36
|
+
"@basemaps/geo": "^6.10.0",
|
|
37
|
+
"@basemaps/lambda-tiler": "^6.10.0",
|
|
38
|
+
"@basemaps/shared": "^6.10.0",
|
|
39
|
+
"@linzjs/lambda": "^2.0.0",
|
|
36
40
|
"@oclif/command": "^1.8.0",
|
|
37
41
|
"express": "^4.17.1",
|
|
38
|
-
"pretty-json-log": "^0.
|
|
42
|
+
"pretty-json-log": "^1.0.0"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"@types/express": "^4.17.13"
|
|
42
46
|
},
|
|
43
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "c88706ff58f4dfe83bf2b757d1483194accdb4c9"
|
|
44
48
|
}
|