@basemaps/server 6.38.0 → 6.40.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 +28 -0
- package/README.md +13 -13
- package/bin/basemaps-server.cjs +186 -181
- package/build/bin.js +8 -1
- package/build/bin.js.map +1 -1
- package/build/cli.d.ts +17 -8
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +39 -36
- package/build/cli.js.map +1 -1
- package/build/config.d.ts +22 -0
- package/build/config.d.ts.map +1 -0
- package/build/config.js +52 -0
- package/build/config.js.map +1 -0
- package/build/server.d.ts +1 -6
- package/build/server.d.ts.map +1 -1
- package/build/server.js +7 -35
- package/build/server.js.map +1 -1
- package/package.json +9 -8
package/build/bin.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
Error.stackTraceLimit = 100;
|
|
2
|
+
import { LogConfig } from '@basemaps/shared';
|
|
3
|
+
import { run } from 'cmd-ts';
|
|
2
4
|
import { BasemapsServerCommand } from './cli.js';
|
|
3
|
-
|
|
5
|
+
run(BasemapsServerCommand, process.argv.slice(2)).catch((err) => {
|
|
6
|
+
const logger = LogConfig.get();
|
|
7
|
+
logger.fatal({ err }, 'Command:Failed');
|
|
8
|
+
// Give the logger some time to flush before exiting
|
|
9
|
+
setTimeout(() => process.exit(1), 25);
|
|
10
|
+
});
|
|
4
11
|
//# sourceMappingURL=bin.js.map
|
package/build/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC;AAE5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":"AAAA,KAAK,CAAC,eAAe,GAAG,GAAG,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAEjD,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC9D,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC;IAC/B,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAExC,oDAAoD;IACpD,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC"}
|
package/build/cli.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
1
|
+
export declare const BasemapsServerCommand: Partial<import("cmd-ts/dist/cjs/argparser.js").Register> & {
|
|
2
|
+
parse(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<{
|
|
3
|
+
config: string | undefined;
|
|
4
|
+
port: number | undefined;
|
|
5
|
+
verbose: boolean;
|
|
6
|
+
assets: string | undefined;
|
|
7
|
+
paths: string[];
|
|
8
|
+
}>>;
|
|
9
|
+
} & import("cmd-ts/dist/cjs/helpdoc.js").PrintHelp & import("cmd-ts/dist/cjs/helpdoc.js").ProvidesHelp & import("cmd-ts/dist/cjs/helpdoc.js").Named & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned> & import("cmd-ts/dist/cjs/argparser.js").Register & import("cmd-ts/dist/cjs/runner.js").Handling<{
|
|
10
|
+
config: string | undefined;
|
|
11
|
+
port: number | undefined;
|
|
12
|
+
verbose: boolean;
|
|
13
|
+
assets: string | undefined;
|
|
14
|
+
paths: string[];
|
|
15
|
+
}, Promise<void>> & {
|
|
16
|
+
run(context: import("cmd-ts/dist/cjs/argparser.js").ParseContext): Promise<import("cmd-ts/dist/cjs/argparser.js").ParsingResult<Promise<void>>>;
|
|
17
|
+
} & Partial<import("cmd-ts/dist/cjs/helpdoc.js").Versioned & import("cmd-ts/dist/cjs/helpdoc.js").Descriptive & import("cmd-ts/dist/cjs/helpdoc.js").Aliased>;
|
|
9
18
|
//# 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":"AASA,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;6JAyChC,CAAC"}
|
package/build/cli.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Env, LogConfig } from '@basemaps/shared';
|
|
2
|
+
import { CliInfo } from '@basemaps/shared/build/cli/info.js';
|
|
3
|
+
import { command, flag, number, option, optional, restPositionals, string } from 'cmd-ts';
|
|
3
4
|
import { createServer } from './server.js';
|
|
4
5
|
CliInfo.package = 'basemaps/server';
|
|
5
6
|
const DefaultPort = 5000;
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
description: '
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
export const BasemapsServerCommand = command({
|
|
8
|
+
name: 'basemaps-server',
|
|
9
|
+
version: CliInfo.version,
|
|
10
|
+
description: 'Create a basemaps server',
|
|
11
|
+
args: {
|
|
12
|
+
config: option({ type: optional(string), long: 'config', description: 'Configuration to use' }),
|
|
13
|
+
port: option({
|
|
14
|
+
type: optional(number),
|
|
15
|
+
long: 'port',
|
|
16
|
+
description: 'Port to use',
|
|
17
|
+
defaultValue: () => DefaultPort,
|
|
18
|
+
env: 'PORT',
|
|
19
|
+
}),
|
|
20
|
+
verbose: flag({ long: 'verbose', description: 'Enable verbose logging' }),
|
|
21
|
+
assets: option({
|
|
22
|
+
type: optional(string),
|
|
23
|
+
long: 'assets',
|
|
20
24
|
description: 'Where the assets (sprites, fonts) are located',
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
defaultValue: DefaultPort,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async onExecute() {
|
|
30
|
-
var _a, _b;
|
|
31
|
-
await super.onExecute();
|
|
25
|
+
}),
|
|
26
|
+
paths: restPositionals({ type: string, displayName: 'path', description: 'Path to imagery' }),
|
|
27
|
+
},
|
|
28
|
+
handler: async (args) => {
|
|
29
|
+
var _a;
|
|
32
30
|
const logger = LogConfig.get();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
if (args.verbose)
|
|
32
|
+
logger.level = 'debug';
|
|
33
|
+
if (args.paths.length === 0 && args.config == null) {
|
|
34
|
+
throw new Error('Either --config or paths must be used. see --help');
|
|
35
|
+
}
|
|
36
|
+
logger.info({ package: CliInfo, cli: 'server' }, 'Cli:Start');
|
|
37
|
+
const ServerUrl = (_a = Env.get(Env.PublicUrlBase)) !== null && _a !== void 0 ? _a : `http://localhost:${args.port}`;
|
|
38
38
|
// Force a default url base so WMTS requests know their relative url
|
|
39
39
|
process.env[Env.PublicUrlBase] = ServerUrl;
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const serverOptions = args.config
|
|
41
|
+
? { assets: args.assets, config: args.config }
|
|
42
|
+
: { assets: args.assets, paths: args.paths };
|
|
43
|
+
const server = await createServer(serverOptions, logger);
|
|
44
|
+
await server.listen({ port: args.port, host: '0.0.0.0' });
|
|
42
45
|
logger.info({ url: ServerUrl }, 'ServerStarted');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
46
|
+
},
|
|
47
|
+
});
|
|
45
48
|
//# sourceMappingURL=cli.js.map
|
package/build/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,CAAC,OAAO,GAAG,iBAAiB,CAAC;AAEpC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;IAC3C,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,OAAO,CAAC,OAAO;IACxB,WAAW,EAAE,0BAA0B;IACvC,IAAI,EAAE;QACJ,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;QAC/F,IAAI,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC;YACtB,IAAI,EAAE,MAAM;YACZ,WAAW,EAAE,aAAa;YAC1B,YAAY,EAA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M,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;QAE/C,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAEzD,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1D,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,eAAe,CAAC,CAAC;IACnD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BasemapsConfigProvider } from '@basemaps/config';
|
|
2
|
+
import { LogType } from '@basemaps/shared';
|
|
3
|
+
export type ServerOptions = ServerOptionsTiffs | ServerOptionsConfig;
|
|
4
|
+
/** Load configuration from folders */
|
|
5
|
+
export interface ServerOptionsTiffs {
|
|
6
|
+
assets?: string;
|
|
7
|
+
paths: string[];
|
|
8
|
+
}
|
|
9
|
+
/** Load configuration from a config file/dynamodb */
|
|
10
|
+
export interface ServerOptionsConfig {
|
|
11
|
+
assets?: string;
|
|
12
|
+
config: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Attempt to load a configuration file from a number of sources
|
|
16
|
+
*
|
|
17
|
+
* @param configPath Location to where the configuration is stored
|
|
18
|
+
* @param noConfig Whether to generate a config directly from the source imagery
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadConfig(opts: ServerOptions, logger: LogType): Promise<BasemapsConfigProvider>;
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAMvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAyB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAElE,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAErE,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,qDAAqD;AACrD,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA6CtG"}
|
package/build/config.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ConfigJson, ConfigPrefix, ConfigProviderDynamo, ConfigProviderMemory, } from '@basemaps/config';
|
|
2
|
+
import { initConfigFromPaths } from '@basemaps/config/build/json/tiff.config.js';
|
|
3
|
+
import { fsa, getDefaultConfig } from '@basemaps/shared';
|
|
4
|
+
/**
|
|
5
|
+
* Attempt to load a configuration file from a number of sources
|
|
6
|
+
*
|
|
7
|
+
* @param configPath Location to where the configuration is stored
|
|
8
|
+
* @param noConfig Whether to generate a config directly from the source imagery
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export async function loadConfig(opts, logger) {
|
|
12
|
+
// Load the config directly from the source tiff files
|
|
13
|
+
if ('paths' in opts) {
|
|
14
|
+
const mem = new ConfigProviderMemory();
|
|
15
|
+
const ret = await initConfigFromPaths(mem, opts.paths);
|
|
16
|
+
logger.info({ tileSet: ret.tileSet.name, layers: ret.tileSet.layers.length }, 'TileSet:Loaded');
|
|
17
|
+
for (const im of ret.imagery) {
|
|
18
|
+
logger.info({ imagery: im.uri, title: im.title, tileMatrix: im.tileMatrix, files: im.files.length }, 'Imagery:Loaded');
|
|
19
|
+
}
|
|
20
|
+
return mem;
|
|
21
|
+
}
|
|
22
|
+
const configPath = opts.config;
|
|
23
|
+
// Load config from dynamodb table
|
|
24
|
+
if (configPath.startsWith('dynamodb://')) {
|
|
25
|
+
const table = configPath.slice('dynamodb://'.length);
|
|
26
|
+
logger.info({ path: configPath, table, mode: 'dynamo' }, 'Starting Server');
|
|
27
|
+
return new ConfigProviderDynamo(table);
|
|
28
|
+
}
|
|
29
|
+
// Load a bundled config by loading it from the default dynamo reference
|
|
30
|
+
if (configPath.startsWith(ConfigPrefix.ConfigBundle)) {
|
|
31
|
+
const cb = await getDefaultConfig().ConfigBundle.get(configPath);
|
|
32
|
+
if (cb == null)
|
|
33
|
+
throw new Error(`Config bundle does not exist ${configPath}`);
|
|
34
|
+
const configJson = await fsa.readJson(cb.path);
|
|
35
|
+
const mem = ConfigProviderMemory.fromJson(configJson);
|
|
36
|
+
mem.createVirtualTileSets();
|
|
37
|
+
return mem;
|
|
38
|
+
}
|
|
39
|
+
// Read a bundled config directly from a JSON file.
|
|
40
|
+
if (configPath.endsWith('.json') || configPath.endsWith('.json.gz')) {
|
|
41
|
+
logger.info({ path: configPath, mode: 'config:bundle' }, 'Starting Server');
|
|
42
|
+
const configJson = await fsa.readJson(configPath);
|
|
43
|
+
const mem = ConfigProviderMemory.fromJson(configJson);
|
|
44
|
+
mem.createVirtualTileSets();
|
|
45
|
+
return mem;
|
|
46
|
+
}
|
|
47
|
+
const mem = await ConfigJson.fromPath(configPath, logger);
|
|
48
|
+
logger.info({ path: configPath, mode: 'config:json' }, 'Starting Server');
|
|
49
|
+
mem.createVirtualTileSets();
|
|
50
|
+
return mem;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4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ogType } from '@basemaps/shared';
|
|
2
2
|
import { FastifyInstance } from 'fastify';
|
|
3
|
-
|
|
4
|
-
/** Path to assets */
|
|
5
|
-
assets?: string;
|
|
6
|
-
/** Path to configuration or a dynamdb table */
|
|
7
|
-
config: string;
|
|
8
|
-
}
|
|
3
|
+
import { ServerOptions } from './config.js';
|
|
9
4
|
export declare function createServer(opts: ServerOptions, logger: LogType): Promise<FastifyInstance>;
|
|
10
5
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,OAAO,EAAoB,MAAM,kBAAkB,CAAC;AAKpF,OAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKnD,OAAO,EAAc,aAAa,EAAE,MAAM,aAAa,CAAC;AAiBxD,wBAAsB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC,CAsDjG"}
|
package/build/server.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ConfigJson, ConfigPrefix, ConfigProviderDynamo, ConfigProviderMemory } from '@basemaps/config';
|
|
2
1
|
import { handler } from '@basemaps/lambda-tiler';
|
|
3
2
|
import { fsa, getDefaultConfig, setDefaultConfig } from '@basemaps/shared';
|
|
4
3
|
import formBodyPlugin from '@fastify/formbody';
|
|
@@ -9,6 +8,7 @@ import { createRequire } from 'module';
|
|
|
9
8
|
import path from 'path';
|
|
10
9
|
import ulid from 'ulid';
|
|
11
10
|
import { URL } from 'url';
|
|
11
|
+
import { loadConfig } from './config.js';
|
|
12
12
|
const instanceId = ulid.ulid();
|
|
13
13
|
function getLandingLocation() {
|
|
14
14
|
try {
|
|
@@ -25,38 +25,10 @@ function getLandingLocation() {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
export async function createServer(opts, logger) {
|
|
28
|
-
const BasemapsServer = fastify();
|
|
28
|
+
const BasemapsServer = fastify({});
|
|
29
29
|
BasemapsServer.register(formBodyPlugin);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const table = opts.config.slice('dynamodb://'.length);
|
|
33
|
-
logger.info({ path: opts.config, table, mode: 'dynamo' }, 'Starting Server');
|
|
34
|
-
setDefaultConfig(new ConfigProviderDynamo(table));
|
|
35
|
-
}
|
|
36
|
-
else if (opts.config.startsWith(ConfigPrefix.ConfigBundle)) {
|
|
37
|
-
// Load Bundled config by dynamo refference
|
|
38
|
-
const cb = await getDefaultConfig().ConfigBundle.get(opts.config);
|
|
39
|
-
if (cb == null)
|
|
40
|
-
throw new Error(`Config bunble not exists for ${opts.config}`);
|
|
41
|
-
const configJson = await fsa.readJson(cb.path);
|
|
42
|
-
const mem = ConfigProviderMemory.fromJson(configJson);
|
|
43
|
-
mem.createVirtualTileSets();
|
|
44
|
-
setDefaultConfig(mem);
|
|
45
|
-
}
|
|
46
|
-
else if (opts.config.endsWith('.json') || opts.config.endsWith('.json.gz')) {
|
|
47
|
-
// Bundled config
|
|
48
|
-
logger.info({ path: opts.config, mode: 'config:bundle' }, 'Starting Server');
|
|
49
|
-
const configJson = await fsa.readJson(opts.config);
|
|
50
|
-
const mem = ConfigProviderMemory.fromJson(configJson);
|
|
51
|
-
mem.createVirtualTileSets();
|
|
52
|
-
setDefaultConfig(mem);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const mem = await ConfigJson.fromPath(opts.config, logger);
|
|
56
|
-
logger.info({ path: opts.config, mode: 'config' }, 'Starting Server');
|
|
57
|
-
mem.createVirtualTileSets();
|
|
58
|
-
setDefaultConfig(mem);
|
|
59
|
-
}
|
|
30
|
+
const cfg = await loadConfig(opts, logger);
|
|
31
|
+
setDefaultConfig(cfg);
|
|
60
32
|
if (opts.assets) {
|
|
61
33
|
const isExists = await fsa.exists(opts.assets);
|
|
62
34
|
if (!isExists)
|
|
@@ -75,13 +47,13 @@ export async function createServer(opts, logger) {
|
|
|
75
47
|
}
|
|
76
48
|
BasemapsServer.all('/v1/*', (req, res) => {
|
|
77
49
|
const url = new URL(`${req.protocol}://${req.hostname}${req.url}`);
|
|
78
|
-
if (
|
|
79
|
-
|
|
50
|
+
if (!url.searchParams.has('api'))
|
|
51
|
+
url.searchParams.set('api', 'd' + instanceId);
|
|
80
52
|
const request = new LambdaUrlRequest({
|
|
81
53
|
requestContext: { http: { method: req.method.toUpperCase() } },
|
|
82
54
|
headers: req.headers,
|
|
83
55
|
rawPath: url.pathname,
|
|
84
|
-
rawQueryString:
|
|
56
|
+
rawQueryString: url.searchParams.toString(),
|
|
85
57
|
isBase64Encoded: false,
|
|
86
58
|
}, {}, logger);
|
|
87
59
|
handler.router
|
package/build/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAW,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,cAAc,MAAM,mBAAmB,CAAC;AAC/C,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAY,MAAM,gBAAgB,CAAC;AAE5D,OAAO,OAA4B,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1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CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE;gBAAE,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YAC/E,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACX,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,eAAe,CAAC,CAAC;YAC/C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basemaps/server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.40.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/linz/basemaps.git",
|
|
@@ -44,21 +44,22 @@
|
|
|
44
44
|
"bin/"
|
|
45
45
|
],
|
|
46
46
|
"optionalDependencies": {
|
|
47
|
-
"@basemaps/landing": "^6.
|
|
47
|
+
"@basemaps/landing": "^6.40.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"sharp": "^0.30.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@basemaps/config": "^6.
|
|
54
|
-
"@basemaps/geo": "^6.
|
|
55
|
-
"@basemaps/lambda-tiler": "^6.
|
|
56
|
-
"@basemaps/landing": "^6.
|
|
57
|
-
"@basemaps/shared": "^6.
|
|
53
|
+
"@basemaps/config": "^6.40.0",
|
|
54
|
+
"@basemaps/geo": "^6.40.0",
|
|
55
|
+
"@basemaps/lambda-tiler": "^6.40.0",
|
|
56
|
+
"@basemaps/landing": "^6.39.0",
|
|
57
|
+
"@basemaps/shared": "^6.40.0",
|
|
58
58
|
"@fastify/formbody": "^7.0.1",
|
|
59
59
|
"@fastify/static": "^6.5.0",
|
|
60
|
+
"cmd-ts": "^0.12.1",
|
|
60
61
|
"fastify": "^4.9.2",
|
|
61
62
|
"pretty-json-log": "^1.0.0"
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "029c1e511531064dbf87b2b5204a50fe840daa79"
|
|
64
65
|
}
|