@basemaps/server 6.27.0 → 6.29.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 +39 -0
- package/README.md +38 -6
- package/bin/basemaps-server.cjs +840 -0
- package/build/cli.d.ts +11 -12
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +86 -43
- package/build/server.d.ts.map +1 -1
- package/build/server.js +15 -2
- package/package.json +26 -10
- package/bin/basemaps-server.js +0 -11
package/build/cli.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
import { LogType } from '@basemaps/shared';
|
|
2
|
+
import { BaseCommandLine } from '@basemaps/shared/build/cli/base.js';
|
|
3
|
+
export declare class BasemapsServerCommand extends BaseCommandLine {
|
|
4
|
+
config: import("@rushstack/ts-command-line").CommandLineStringParameter;
|
|
5
|
+
ignoreConfig: import("@rushstack/ts-command-line").CommandLineFlagParameter;
|
|
6
|
+
bundle: import("@rushstack/ts-command-line").CommandLineStringParameter;
|
|
7
|
+
assets: import("@rushstack/ts-command-line").CommandLineStringParameter;
|
|
8
|
+
port: import("@rushstack/ts-command-line").CommandLineIntegerParameter;
|
|
9
|
+
constructor();
|
|
11
10
|
static args: never[];
|
|
12
|
-
loadTiffs(tiffPath: string, serverUrl: string): Promise<void>;
|
|
13
|
-
|
|
11
|
+
loadTiffs(tiffPath: string, serverUrl: string, logger: LogType): Promise<void>;
|
|
12
|
+
onExecute(): Promise<void>;
|
|
14
13
|
}
|
|
15
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":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAsC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAW,MAAM,oCAAoC,CAAC;AAoB9E,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,MAAM,kEAIH;IACH,YAAY,gEAGT;IACH,MAAM,kEAIH;IACH,MAAM,kEAIH;IACH,IAAI,mEAKD;;IASH,MAAM,CAAC,IAAI,UAAM;IAEX,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B9E,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAwDjC"}
|
package/build/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ConfigJson, ConfigProviderDynamo, ConfigProviderMemory } from '@basemaps/config';
|
|
2
2
|
import { TileSetLocal } from '@basemaps/lambda-tiler/build/cli/tile.set.local.js';
|
|
3
3
|
import { TileSets } from '@basemaps/lambda-tiler/build/tile.set.cache.js';
|
|
4
|
-
import { Config, Env, fsa, LogConfig } from '@basemaps/shared';
|
|
5
|
-
import {
|
|
4
|
+
import { Config, Const, Env, fsa, LogConfig } from '@basemaps/shared';
|
|
5
|
+
import { BaseCommandLine, CliInfo } from '@basemaps/shared/build/cli/base.js';
|
|
6
6
|
import { basename, dirname } from 'path';
|
|
7
7
|
import { createServer } from './server.js';
|
|
8
|
-
|
|
8
|
+
CliInfo.package = 'basemaps/server';
|
|
9
9
|
const BaseProvider = {
|
|
10
10
|
id: 'pv_linz',
|
|
11
11
|
version: 1,
|
|
@@ -17,8 +17,40 @@ const BaseProvider = {
|
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
const DefaultPort = 5000;
|
|
21
|
+
export class BasemapsServerCommand extends BaseCommandLine {
|
|
22
|
+
constructor() {
|
|
23
|
+
super({
|
|
24
|
+
toolFilename: 'bms',
|
|
25
|
+
toolDescription: 'Create a WMTS/XYZ Tile server from basemaps config',
|
|
26
|
+
});
|
|
27
|
+
this.config = this.defineStringParameter({
|
|
28
|
+
argumentName: 'CONFIG',
|
|
29
|
+
parameterLongName: '--config',
|
|
30
|
+
description: 'Configuration source to use',
|
|
31
|
+
});
|
|
32
|
+
this.ignoreConfig = this.defineFlagParameter({
|
|
33
|
+
parameterLongName: '--no-config',
|
|
34
|
+
description: 'Assume no config and just load tiffs from the configuration path',
|
|
35
|
+
});
|
|
36
|
+
this.bundle = this.defineStringParameter({
|
|
37
|
+
argumentName: 'BUNDLE',
|
|
38
|
+
parameterLongName: '--bundle',
|
|
39
|
+
description: 'Compile the configuration into a bundle and output path',
|
|
40
|
+
});
|
|
41
|
+
this.assets = this.defineStringParameter({
|
|
42
|
+
argumentName: 'ASSETS',
|
|
43
|
+
parameterLongName: '--assets',
|
|
44
|
+
description: 'Where the assets (sprites, fonts) are located',
|
|
45
|
+
});
|
|
46
|
+
this.port = this.defineIntegerParameter({
|
|
47
|
+
argumentName: 'PORT',
|
|
48
|
+
parameterLongName: '--port',
|
|
49
|
+
description: 'port to use',
|
|
50
|
+
defaultValue: DefaultPort,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
async loadTiffs(tiffPath, serverUrl, logger) {
|
|
22
54
|
const config = new ConfigProviderMemory();
|
|
23
55
|
Config.setConfigProvider(config);
|
|
24
56
|
const tifSets = new Map();
|
|
@@ -40,51 +72,62 @@ export class BasemapsServerCommand extends Command {
|
|
|
40
72
|
}
|
|
41
73
|
}
|
|
42
74
|
}
|
|
43
|
-
async
|
|
44
|
-
var _a;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const cj = await ConfigJson.fromPath(flags.config, logger);
|
|
59
|
-
Config.setConfigProvider(cj.mem);
|
|
60
|
-
}
|
|
75
|
+
async onExecute() {
|
|
76
|
+
var _a, _b;
|
|
77
|
+
await super.onExecute();
|
|
78
|
+
const logger = LogConfig.get();
|
|
79
|
+
logger.level = 'debug';
|
|
80
|
+
const config = (_a = this.config.value) !== null && _a !== void 0 ? _a : 'dynamodb://' + Const.TileMetadata.TableName;
|
|
81
|
+
const port = this.port.value;
|
|
82
|
+
const ServerUrl = (_b = Env.get(Env.PublicUrlBase)) !== null && _b !== void 0 ? _b : `http://localhost:${port}`;
|
|
83
|
+
// Force a default url base so WMTS requests know their relative url
|
|
84
|
+
process.env[Env.PublicUrlBase] = ServerUrl;
|
|
85
|
+
if (config.startsWith('dynamodb://')) {
|
|
86
|
+
// Load config from dynamodb table
|
|
87
|
+
const table = config.slice('dynamodb://'.length);
|
|
88
|
+
logger.info({ path: config, table, mode: 'dynamo' }, 'Starting Server');
|
|
89
|
+
Config.setConfigProvider(new ConfigProviderDynamo(table));
|
|
61
90
|
}
|
|
62
|
-
else if (
|
|
63
|
-
//
|
|
64
|
-
logger.info({
|
|
65
|
-
|
|
91
|
+
else if (config.endsWith('.json')) {
|
|
92
|
+
// Bundled config
|
|
93
|
+
logger.info({ path: config, mode: 'config' }, 'Starting Server');
|
|
94
|
+
const configJson = await fsa.read(config);
|
|
95
|
+
const mem = ConfigProviderMemory.fromJson(JSON.parse(configJson.toString()));
|
|
96
|
+
Config.setConfigProvider(mem);
|
|
66
97
|
}
|
|
67
|
-
else if (
|
|
68
|
-
//
|
|
69
|
-
logger.info({ path:
|
|
70
|
-
await this.loadTiffs(
|
|
98
|
+
else if (this.ignoreConfig.value) {
|
|
99
|
+
// Load config directly from tiff files
|
|
100
|
+
logger.info({ path: config, mode: 'tiffs' }, 'Starting Server');
|
|
101
|
+
await this.loadTiffs(config, ServerUrl, logger);
|
|
71
102
|
}
|
|
72
103
|
else {
|
|
73
|
-
|
|
104
|
+
const mem = await ConfigJson.fromPath(config, logger);
|
|
105
|
+
const bundlePath = this.bundle.value;
|
|
106
|
+
if (bundlePath) {
|
|
107
|
+
await fsa.writeJson(bundlePath, mem.toJson());
|
|
108
|
+
logger.info({ path: bundlePath }, 'ConfigBundled');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
// Assume the folder is a collection of config files
|
|
112
|
+
logger.info({ path: config, mode: 'config' }, 'Starting Server');
|
|
113
|
+
mem.createVirtualTileSets();
|
|
114
|
+
Config.setConfigProvider(mem);
|
|
74
115
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
116
|
+
if (this.assets.value) {
|
|
117
|
+
const isExists = await fsa.exists(this.assets.value);
|
|
118
|
+
if (!isExists)
|
|
119
|
+
throw new Error('--asset path is missing');
|
|
120
|
+
process.env[Env.AssetLocation] = this.assets.value;
|
|
121
|
+
}
|
|
122
|
+
if (this.bundle.value != null) {
|
|
123
|
+
throw new Error('--bundle path provided without providing a configuration path');
|
|
124
|
+
}
|
|
125
|
+
createServer(logger).listen(port !== null && port !== void 0 ? port : DefaultPort, '0.0.0.0', () => {
|
|
78
126
|
logger.info({ url: ServerUrl }, 'ServerStarted');
|
|
79
127
|
});
|
|
80
128
|
}
|
|
81
129
|
}
|
|
82
|
-
BasemapsServerCommand.description = 'Create a WMTS/XYZ Tile server for basemaps config';
|
|
83
|
-
BasemapsServerCommand.flags = {
|
|
84
|
-
verbose: flags.boolean(),
|
|
85
|
-
port: flags.integer({ default: 5000 }),
|
|
86
|
-
dynamo: flags.string({ description: 'Dynamodb table', required: false }),
|
|
87
|
-
config: flags.string({ description: 'Configuration path', required: false }),
|
|
88
|
-
files: flags.string({ description: 'Use folders of tiffs as the configuration', required: false }),
|
|
89
|
-
};
|
|
90
130
|
BasemapsServerCommand.args = [];
|
|
131
|
+
new BasemapsServerCommand().executeWithoutErrorHandling().catch((c) => {
|
|
132
|
+
console.error(c);
|
|
133
|
+
});
|
package/build/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,OAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAI3C,OAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA2BnD,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,eAAe,CAwC7D"}
|
package/build/server.js
CHANGED
|
@@ -14,10 +14,23 @@ function isAlbResult(r) {
|
|
|
14
14
|
return 'statusCode' in r;
|
|
15
15
|
}
|
|
16
16
|
const instanceId = ulid.ulid();
|
|
17
|
+
function getLandingLocation() {
|
|
18
|
+
try {
|
|
19
|
+
if (typeof require !== 'undefined' && typeof require.resolve === 'function') {
|
|
20
|
+
return require.resolve('@basemaps/landing/dist');
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
const require = createRequire(import.meta.url);
|
|
24
|
+
return require.resolve('@basemaps/landing/dist');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
17
31
|
export function createServer(logger) {
|
|
18
32
|
const BasemapsServer = fastify();
|
|
19
|
-
const
|
|
20
|
-
const landingLocation = require.resolve('@basemaps/landing');
|
|
33
|
+
const landingLocation = getLandingLocation();
|
|
21
34
|
if (landingLocation == null) {
|
|
22
35
|
logger.warn('Server:Landing:Failed');
|
|
23
36
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.29.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -19,29 +19,45 @@
|
|
|
19
19
|
"main": "./build/index.js",
|
|
20
20
|
"types": "./build/index.d.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"test": "ospec --globs 'build/**/*.test.js'"
|
|
22
|
+
"test": "ospec --globs 'build/**/*.test.js'",
|
|
23
|
+
"bundle": "../../scripts/bundle.js package.json"
|
|
23
24
|
},
|
|
24
25
|
"publishConfig": {
|
|
25
26
|
"access": "public"
|
|
26
27
|
},
|
|
27
28
|
"bin": {
|
|
28
|
-
"basemaps-server": "./bin/basemaps-server.
|
|
29
|
+
"basemaps-server": "./bin/basemaps-server.cjs"
|
|
29
30
|
},
|
|
31
|
+
"bundle": [
|
|
32
|
+
{
|
|
33
|
+
"entry": "src/cli.ts",
|
|
34
|
+
"outfile": "bin/basemaps-server.cjs",
|
|
35
|
+
"executable": true,
|
|
36
|
+
"external": [
|
|
37
|
+
"pino-pretty",
|
|
38
|
+
"sharp"
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
],
|
|
30
42
|
"files": [
|
|
31
43
|
"build/",
|
|
32
44
|
"bin/"
|
|
33
45
|
],
|
|
46
|
+
"optionalDependencies": {
|
|
47
|
+
"@basemaps/landing": "^6.29.0"
|
|
48
|
+
},
|
|
34
49
|
"dependencies": {
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
50
|
+
"sharp": "^0.30.7"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@basemaps/config": "^6.29.0",
|
|
54
|
+
"@basemaps/geo": "^6.28.1",
|
|
55
|
+
"@basemaps/lambda-tiler": "^6.29.0",
|
|
38
56
|
"@basemaps/landing": "^6.27.0",
|
|
39
|
-
"@basemaps/shared": "^6.
|
|
57
|
+
"@basemaps/shared": "^6.29.0",
|
|
40
58
|
"@fastify/static": "^5.0.2",
|
|
41
|
-
"@linzjs/lambda": "^3.0.1",
|
|
42
|
-
"@oclif/command": "^1.8.0",
|
|
43
59
|
"fastify": "^3.27.4",
|
|
44
60
|
"pretty-json-log": "^1.0.0"
|
|
45
61
|
},
|
|
46
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "9097d2f045d734d0d5acd968f026fe29ab6afcda"
|
|
47
63
|
}
|
package/bin/basemaps-server.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
if (process.env.AWS_REGION == null) process.env.AWS_REGION = process.env.AWS_DEFAULT_REGION;
|
|
4
|
-
|
|
5
|
-
import { BasemapsServerCommand } from '../build/cli.js';
|
|
6
|
-
import Errors from '@oclif/errors/handle.js';
|
|
7
|
-
|
|
8
|
-
BasemapsServerCommand.run(void 0, import.meta.url).catch((error) => {
|
|
9
|
-
if (error.oclif) return Errors(error);
|
|
10
|
-
console.log(error);
|
|
11
|
-
});
|