@basemaps/lambda-tiler 6.29.0 → 6.32.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 +63 -0
- package/build/__tests__/config.data.d.ts +11 -0
- package/build/__tests__/config.data.d.ts.map +1 -0
- package/build/__tests__/config.data.js +112 -0
- package/build/__tests__/config.data.js.map +1 -0
- package/build/__tests__/index.test.js +5 -14
- package/build/__tests__/index.test.js.map +1 -0
- package/build/__tests__/tile.style.json.test.js +1 -0
- package/build/__tests__/tile.style.json.test.js.map +1 -0
- package/build/__tests__/wmts.capability.test.d.ts +1 -1
- package/build/__tests__/wmts.capability.test.d.ts.map +1 -1
- package/build/__tests__/wmts.capability.test.js +286 -125
- package/build/__tests__/wmts.capability.test.js.map +1 -0
- package/build/__tests__/xyz.util.d.ts +7 -11
- package/build/__tests__/xyz.util.d.ts.map +1 -1
- package/build/__tests__/xyz.util.js +14 -42
- package/build/__tests__/xyz.util.js.map +1 -0
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +68 -41
- package/build/index.js.map +1 -0
- package/build/routes/__tests__/attribution.test.js +351 -399
- package/build/routes/__tests__/attribution.test.js.map +1 -0
- package/build/routes/__tests__/fonts.test.js +17 -3
- package/build/routes/__tests__/fonts.test.js.map +1 -0
- package/build/routes/__tests__/health.test.js +17 -13
- package/build/routes/__tests__/health.test.js.map +1 -0
- package/build/routes/__tests__/imagery.test.js +1 -0
- package/build/routes/__tests__/imagery.test.js.map +1 -0
- package/build/routes/__tests__/memory.fs.js +1 -0
- package/build/routes/__tests__/memory.fs.js.map +1 -0
- package/build/routes/__tests__/sprites.test.js +7 -0
- package/build/routes/__tests__/sprites.test.js.map +1 -0
- package/build/routes/__tests__/tile.json.test.d.ts +2 -0
- package/build/routes/__tests__/tile.json.test.d.ts.map +1 -0
- package/build/routes/__tests__/tile.json.test.js +124 -0
- package/build/routes/__tests__/tile.json.test.js.map +1 -0
- package/build/routes/__tests__/tile.style.json.test.d.ts +2 -0
- package/build/routes/__tests__/tile.style.json.test.d.ts.map +1 -0
- package/build/routes/__tests__/tile.style.json.test.js +95 -0
- package/build/routes/__tests__/tile.style.json.test.js.map +1 -0
- package/build/routes/__tests__/wmts.test.js +37 -27
- package/build/routes/__tests__/wmts.test.js.map +1 -0
- package/build/{__tests__ → routes/__tests__}/xyz.test.d.ts +0 -0
- package/build/routes/__tests__/xyz.test.d.ts.map +1 -0
- package/build/routes/__tests__/xyz.test.js +99 -0
- package/build/routes/__tests__/xyz.test.js.map +1 -0
- package/build/routes/attribution.d.ts +7 -5
- package/build/routes/attribution.d.ts.map +1 -1
- package/build/routes/attribution.js +50 -91
- package/build/routes/attribution.js.map +1 -0
- package/build/routes/fonts.d.ts +1 -1
- package/build/routes/fonts.d.ts.map +1 -1
- package/build/routes/fonts.js +33 -10
- package/build/routes/fonts.js.map +1 -0
- package/build/routes/health.d.ts +3 -3
- package/build/routes/health.d.ts.map +1 -1
- package/build/routes/health.js +16 -13
- package/build/routes/health.js.map +1 -0
- package/build/routes/imagery.d.ts +8 -1
- package/build/routes/imagery.d.ts.map +1 -1
- package/build/routes/imagery.js +17 -17
- package/build/routes/imagery.js.map +1 -0
- package/build/routes/ping.d.ts +3 -0
- package/build/routes/ping.d.ts.map +1 -0
- package/build/routes/ping.js +7 -0
- package/build/routes/ping.js.map +1 -0
- package/build/routes/sprites.d.ts.map +1 -1
- package/build/routes/sprites.js +22 -22
- package/build/routes/sprites.js.map +1 -0
- package/build/routes/tile.json.d.ts +7 -1
- package/build/routes/tile.json.d.ts.map +1 -1
- package/build/routes/tile.json.js +19 -22
- package/build/routes/tile.json.js.map +1 -0
- package/build/routes/tile.style.json.d.ts +6 -1
- package/build/routes/tile.style.json.d.ts.map +1 -1
- package/build/routes/tile.style.json.js +11 -13
- package/build/routes/tile.style.json.js.map +1 -0
- package/build/routes/tile.wmts.d.ts +9 -3
- package/build/routes/tile.wmts.d.ts.map +1 -1
- package/build/routes/tile.wmts.js +37 -50
- package/build/routes/tile.wmts.js.map +1 -0
- package/build/routes/tile.xyz.d.ts +14 -4
- package/build/routes/tile.xyz.d.ts.map +1 -1
- package/build/routes/tile.xyz.js +22 -17
- package/build/routes/tile.xyz.js.map +1 -0
- package/build/routes/tile.xyz.raster.d.ts +11 -0
- package/build/routes/tile.xyz.raster.d.ts.map +1 -0
- package/build/routes/tile.xyz.raster.js +90 -0
- package/build/routes/tile.xyz.raster.js.map +1 -0
- package/build/routes/tile.xyz.vector.d.ts +8 -0
- package/build/routes/tile.xyz.vector.d.ts.map +1 -0
- package/build/routes/tile.xyz.vector.js +46 -0
- package/build/routes/tile.xyz.vector.js.map +1 -0
- package/build/routes/version.d.ts +3 -0
- package/build/routes/version.d.ts.map +1 -0
- package/build/routes/version.js +9 -0
- package/build/routes/version.js.map +1 -0
- package/build/util/__test__/validate.test.d.ts +2 -0
- package/build/util/__test__/validate.test.d.ts.map +1 -0
- package/build/util/__test__/validate.test.js +66 -0
- package/build/util/__test__/validate.test.js.map +1 -0
- package/build/util/cotar.serve.d.ts +20 -0
- package/build/util/cotar.serve.d.ts.map +1 -0
- package/build/util/cotar.serve.js +41 -0
- package/build/util/cotar.serve.js.map +1 -0
- package/build/util/etag.d.ts +6 -0
- package/build/util/etag.d.ts.map +1 -0
- package/build/util/etag.js +20 -0
- package/build/util/etag.js.map +1 -0
- package/build/util/response.d.ts +4 -0
- package/build/util/response.d.ts.map +1 -0
- package/build/util/response.js +4 -0
- package/build/util/response.js.map +1 -0
- package/build/util/source.cache.d.ts +28 -0
- package/build/util/source.cache.d.ts.map +1 -0
- package/build/util/source.cache.js +53 -0
- package/build/util/source.cache.js.map +1 -0
- package/build/{source.tracer.d.ts → util/source.tracer.d.ts} +1 -0
- package/build/util/source.tracer.d.ts.map +1 -0
- package/build/{source.tracer.js → util/source.tracer.js} +4 -0
- package/build/util/source.tracer.js.map +1 -0
- package/build/util/swapping.lru.d.ts +21 -0
- package/build/util/swapping.lru.d.ts.map +1 -0
- package/build/util/swapping.lru.js +56 -0
- package/build/util/swapping.lru.js.map +1 -0
- package/build/util/validate.d.ts +46 -0
- package/build/util/validate.d.ts.map +1 -0
- package/build/util/validate.js +107 -0
- package/build/util/validate.js.map +1 -0
- package/build/wmts.capability.d.ts +27 -13
- package/build/wmts.capability.d.ts.map +1 -1
- package/build/wmts.capability.js +156 -55
- package/build/wmts.capability.js.map +1 -0
- package/dist/index.js +89 -73
- package/dist/node_modules/.package-lock.json +1 -1
- package/dist/package-lock.json +2 -2
- package/dist/package.json +1 -1
- package/package.json +10 -10
- package/src/__tests__/config.data.ts +120 -0
- package/src/__tests__/index.test.ts +4 -20
- package/src/__tests__/wmts.capability.test.ts +312 -139
- package/src/__tests__/xyz.util.ts +17 -45
- package/src/index.ts +75 -41
- package/src/routes/__tests__/attribution.test.ts +356 -403
- package/src/routes/__tests__/fonts.test.ts +18 -3
- package/src/routes/__tests__/health.test.ts +17 -13
- package/src/routes/__tests__/sprites.test.ts +6 -1
- package/src/routes/__tests__/tile.json.test.ts +145 -0
- package/src/routes/__tests__/tile.style.json.test.ts +105 -0
- package/src/routes/__tests__/wmts.test.ts +44 -34
- package/src/routes/__tests__/xyz.test.ts +119 -0
- package/src/routes/attribution.ts +59 -111
- package/src/routes/fonts.ts +32 -10
- package/src/routes/health.ts +17 -16
- package/src/routes/imagery.ts +18 -15
- package/src/routes/ping.ts +8 -0
- package/src/routes/sprites.ts +20 -22
- package/src/routes/tile.json.ts +24 -19
- package/src/routes/tile.style.json.ts +15 -12
- package/src/routes/tile.wmts.ts +41 -44
- package/src/routes/tile.xyz.raster.ts +106 -0
- package/src/routes/tile.xyz.ts +31 -16
- package/src/routes/tile.xyz.vector.ts +47 -0
- package/src/routes/version.ts +8 -0
- package/src/util/__test__/validate.test.ts +74 -0
- package/src/util/cotar.serve.ts +46 -0
- package/src/util/etag.ts +20 -0
- package/src/util/response.ts +4 -0
- package/src/util/source.cache.ts +71 -0
- package/src/{source.tracer.ts → util/source.tracer.ts} +4 -0
- package/src/util/swapping.lru.ts +63 -0
- package/src/util/validate.ts +126 -0
- package/src/wmts.capability.ts +170 -68
- package/tsconfig.tsbuildinfo +1 -1
- package/build/__tests__/route.test.d.ts +0 -2
- package/build/__tests__/route.test.d.ts.map +0 -1
- package/build/__tests__/route.test.js +0 -20
- package/build/__tests__/tiff.cache.test.d.ts +0 -2
- package/build/__tests__/tiff.cache.test.d.ts.map +0 -1
- package/build/__tests__/tiff.cache.test.js +0 -58
- package/build/__tests__/tile.cache.key.test.d.ts +0 -2
- package/build/__tests__/tile.cache.key.test.d.ts.map +0 -1
- package/build/__tests__/tile.cache.key.test.js +0 -48
- package/build/__tests__/tile.set.cache.test.d.ts +0 -2
- package/build/__tests__/tile.set.cache.test.d.ts.map +0 -1
- package/build/__tests__/tile.set.cache.test.js +0 -123
- package/build/__tests__/tile.set.test.d.ts +0 -2
- package/build/__tests__/tile.set.test.d.ts.map +0 -1
- package/build/__tests__/tile.set.test.js +0 -11
- package/build/__tests__/xyz.test.d.ts.map +0 -1
- package/build/__tests__/xyz.test.js +0 -306
- package/build/api.key.d.ts +0 -2
- package/build/api.key.d.ts.map +0 -1
- package/build/api.key.js +0 -23
- package/build/cli/dump.d.ts +0 -2
- package/build/cli/dump.d.ts.map +0 -1
- package/build/cli/dump.js +0 -47
- package/build/cli/tile.set.local.d.ts +0 -12
- package/build/cli/tile.set.local.d.ts.map +0 -1
- package/build/cli/tile.set.local.js +0 -39
- package/build/router.d.ts +0 -15
- package/build/router.d.ts.map +0 -1
- package/build/router.js +0 -49
- package/build/routes/api.d.ts +0 -5
- package/build/routes/api.d.ts.map +0 -1
- package/build/routes/api.js +0 -16
- package/build/routes/esri/rest.d.ts +0 -10
- package/build/routes/esri/rest.d.ts.map +0 -1
- package/build/routes/esri/rest.js +0 -87
- package/build/routes/response.d.ts +0 -4
- package/build/routes/response.d.ts.map +0 -1
- package/build/routes/response.js +0 -3
- package/build/routes/tile.d.ts +0 -3
- package/build/routes/tile.d.ts.map +0 -1
- package/build/routes/tile.etag.d.ts +0 -11
- package/build/routes/tile.etag.d.ts.map +0 -1
- package/build/routes/tile.etag.js +0 -29
- package/build/routes/tile.js +0 -27
- package/build/source.tracer.d.ts.map +0 -1
- package/build/tiff.cache.d.ts +0 -17
- package/build/tiff.cache.d.ts.map +0 -1
- package/build/tiff.cache.js +0 -45
- package/build/tile.set.cache.d.ts +0 -21
- package/build/tile.set.cache.d.ts.map +0 -1
- package/build/tile.set.cache.js +0 -100
- package/build/tile.set.d.ts +0 -4
- package/build/tile.set.d.ts.map +0 -1
- package/build/tile.set.js +0 -1
- package/build/tile.set.raster.d.ts +0 -49
- package/build/tile.set.raster.d.ts.map +0 -1
- package/build/tile.set.raster.js +0 -186
- package/build/tile.set.vector.d.ts +0 -25
- package/build/tile.set.vector.d.ts.map +0 -1
- package/build/tile.set.vector.js +0 -71
- package/build/validate.d.ts +0 -16
- package/build/validate.d.ts.map +0 -1
- package/build/validate.js +0 -31
- package/src/__tests__/route.test.ts +0 -24
- package/src/__tests__/tiff.cache.test.ts +0 -73
- package/src/__tests__/tile.cache.key.test.ts +0 -56
- package/src/__tests__/tile.set.cache.test.ts +0 -146
- package/src/__tests__/tile.set.test.ts +0 -12
- package/src/__tests__/xyz.test.ts +0 -362
- package/src/api.key.ts +0 -23
- package/src/cli/dump.ts +0 -61
- package/src/cli/tile.set.local.ts +0 -51
- package/src/router.ts +0 -58
- package/src/routes/api.ts +0 -19
- package/src/routes/esri/rest.ts +0 -90
- package/src/routes/response.ts +0 -4
- package/src/routes/tile.etag.ts +0 -36
- package/src/routes/tile.ts +0 -23
- package/src/tiff.cache.ts +0 -51
- package/src/tile.set.cache.ts +0 -111
- package/src/tile.set.raster.ts +0 -228
- package/src/tile.set.ts +0 -4
- package/src/tile.set.vector.ts +0 -79
- package/src/validate.ts +0 -32
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000Tms } from '@basemaps/geo';
|
|
2
|
-
import o from 'ospec';
|
|
3
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
4
|
-
o.spec('tile.set', () => {
|
|
5
|
-
o('extent', () => {
|
|
6
|
-
o(new TileSetRaster('google', GoogleTms).extent.toBbox()).deepEquals([
|
|
7
|
-
-20037508.3427892, -20037508.3427892, 20037508.3427892, 20037508.3427892,
|
|
8
|
-
]);
|
|
9
|
-
o(new TileSetRaster('nztm', Nztm2000Tms).extent.toBbox()).deepEquals([274000, 3087000, 3327000, 7173000]);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xyz.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/xyz.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { GoogleTms, Nztm2000QuadTms, TileMatrixSets } from '@basemaps/geo';
|
|
2
|
-
import { Config, Env, LogConfig, VNodeParser } from '@basemaps/shared';
|
|
3
|
-
import { round } from '@basemaps/test/build/rounding.js';
|
|
4
|
-
import o from 'ospec';
|
|
5
|
-
import sinon from 'sinon';
|
|
6
|
-
import { handleRequest } from '../index.js';
|
|
7
|
-
import { TileEtag } from '../routes/tile.etag.js';
|
|
8
|
-
import { TileSets } from '../tile.set.cache.js';
|
|
9
|
-
import { TileComposer } from '../tile.set.raster.js';
|
|
10
|
-
import { FakeTileSet, FakeTileSetVector, mockRequest, Provider } from './xyz.util.js';
|
|
11
|
-
const sandbox = sinon.createSandbox();
|
|
12
|
-
const TileSetNames = ['aerial', 'aerial@head', 'aerial@beta', '01E7PJFR9AMQFJ05X9G7FQ3XMW'];
|
|
13
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
14
|
-
o.spec('LambdaXyz', () => {
|
|
15
|
-
const host = 'https://tiles.test';
|
|
16
|
-
const origPublicUrlBase = process.env[Env.PublicUrlBase];
|
|
17
|
-
/** Generate mock ALBEvent */
|
|
18
|
-
let rasterMock = o.spy();
|
|
19
|
-
const generateMock = o.spy(() => 'foo');
|
|
20
|
-
const rasterMockBuffer = Buffer.from([1]);
|
|
21
|
-
const origTileEtag = TileEtag.generate;
|
|
22
|
-
const origCompose = TileComposer.compose;
|
|
23
|
-
const apiKey = 'd01f7w7rnhdzg0p7fyrc9v9ard1';
|
|
24
|
-
const apiKeyHeader = { 'x-linz-api-key': 'd01f7w7rnhdzg0p7fyrc9v9ard1' };
|
|
25
|
-
o.beforeEach(() => {
|
|
26
|
-
process.env[Env.PublicUrlBase] = host;
|
|
27
|
-
LogConfig.disable();
|
|
28
|
-
// tileMock = o.spy(() => tileMockData) as any;
|
|
29
|
-
rasterMock = o.spy(() => {
|
|
30
|
-
return {
|
|
31
|
-
buffer: rasterMockBuffer,
|
|
32
|
-
};
|
|
33
|
-
});
|
|
34
|
-
TileEtag.generate = generateMock;
|
|
35
|
-
TileComposer.compose = rasterMock;
|
|
36
|
-
const allMatrix = [...TileMatrixSets.All.values()];
|
|
37
|
-
for (const tileSetName of TileSetNames) {
|
|
38
|
-
for (const tileMatrix of allMatrix) {
|
|
39
|
-
const tileSet = new FakeTileSet(tileSetName, tileMatrix);
|
|
40
|
-
TileSets.add(tileSet);
|
|
41
|
-
tileSet.getTiffsForTile = () => [];
|
|
42
|
-
tileSet.initTiffs = async () => [];
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
TileSets.add(new FakeTileSetVector('topographic', GoogleTms));
|
|
46
|
-
Config.Provider.get = async () => Provider;
|
|
47
|
-
});
|
|
48
|
-
o.afterEach(() => {
|
|
49
|
-
TileSets.cache.clear();
|
|
50
|
-
TileComposer.compose = origCompose;
|
|
51
|
-
TileEtag.generate = origTileEtag;
|
|
52
|
-
process.env[Env.PublicUrlBase] = origPublicUrlBase;
|
|
53
|
-
sandbox.restore();
|
|
54
|
-
});
|
|
55
|
-
o('should export handler', async () => {
|
|
56
|
-
const base = await import('../index.js');
|
|
57
|
-
o(typeof base.handler).equals('function');
|
|
58
|
-
});
|
|
59
|
-
TileSetNames.forEach((tileSetName) => {
|
|
60
|
-
o(`should generate a tile 0,0,0 for ${tileSetName}.png`, async () => {
|
|
61
|
-
o.timeout(200);
|
|
62
|
-
const request = mockRequest(`/v1/tiles/${tileSetName}/global-mercator/0/0/0.png`, 'get', apiKeyHeader);
|
|
63
|
-
const res = await handleRequest(request);
|
|
64
|
-
o(res.status).equals(200);
|
|
65
|
-
o(res.header('content-type')).equals('image/png');
|
|
66
|
-
o(res.header('eTaG')).equals('foo');
|
|
67
|
-
o(res.body).equals(rasterMockBuffer.toString('base64'));
|
|
68
|
-
// Validate the session information has been set correctly
|
|
69
|
-
o(request.logContext['tileSet']).equals(tileSetName);
|
|
70
|
-
o(request.logContext['xyz']).deepEquals({ x: 0, y: 0, z: 0 });
|
|
71
|
-
o(round(request.logContext['location'])).deepEquals({ lat: 0, lon: 0 });
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
o('should generate a tile 0,0,0 for webp', async () => {
|
|
75
|
-
const request = mockRequest('/v1/tiles/aerial/3857/0/0/0.webp', 'get', apiKeyHeader);
|
|
76
|
-
const res = await handleRequest(request);
|
|
77
|
-
o(res.status).equals(200);
|
|
78
|
-
o(res.header('content-type')).equals('image/webp');
|
|
79
|
-
o(res.header('eTaG')).equals('foo');
|
|
80
|
-
o(res.body).equals(rasterMockBuffer.toString('base64'));
|
|
81
|
-
// Validate the session information has been set correctly
|
|
82
|
-
o(request.logContext['xyz']).deepEquals({ x: 0, y: 0, z: 0 });
|
|
83
|
-
o(round(request.logContext['location'])).deepEquals({ lat: 0, lon: 0 });
|
|
84
|
-
});
|
|
85
|
-
['png', 'webp', 'jpeg'].forEach((fmt) => {
|
|
86
|
-
o(`should 200 with empty ${fmt} if a tile is out of bounds`, async () => {
|
|
87
|
-
// tiler.tile = async () => [];
|
|
88
|
-
const res = await handleRequest(mockRequest(`/v1/tiles/aerial/global-mercator/0/0/0.${fmt}`, 'get', apiKeyHeader));
|
|
89
|
-
o(res.status).equals(200);
|
|
90
|
-
o(res.header('content-type')).equals(`image/${fmt}`);
|
|
91
|
-
o(rasterMock.calls.length).equals(1);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
o('should 304 if a tile is not modified', async () => {
|
|
95
|
-
const key = 'foo';
|
|
96
|
-
const request = mockRequest('/v1/tiles/aerial/global-mercator/0/0/0.png', 'get', {
|
|
97
|
-
'if-none-match': key,
|
|
98
|
-
...apiKeyHeader,
|
|
99
|
-
});
|
|
100
|
-
const res = await handleRequest(request);
|
|
101
|
-
o(res.status).equals(304);
|
|
102
|
-
o(res.header('eTaG')).equals(undefined);
|
|
103
|
-
o(rasterMock.calls.length).equals(0);
|
|
104
|
-
o(request.logContext['cache']).deepEquals({ key, match: key, hit: true });
|
|
105
|
-
});
|
|
106
|
-
o('should 404 if a tile is outside of the range', async () => {
|
|
107
|
-
try {
|
|
108
|
-
const res = await handleRequest(mockRequest('/v1/tiles/aerial/global-mercator/25/0/0.png', 'get', apiKeyHeader));
|
|
109
|
-
o(res.status).equals(404);
|
|
110
|
-
}
|
|
111
|
-
catch (e) {
|
|
112
|
-
o(e.status).equals(404);
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
const res = await handleRequest(mockRequest('/v1/tiles/aerial/2193/17/0/0.png', 'get', apiKeyHeader));
|
|
116
|
-
o(res.status).equals(404);
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
o(e.status).equals(404);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
o.spec('WMTSCapabilities', () => {
|
|
123
|
-
o('should 304 if a xml is not modified', async () => {
|
|
124
|
-
delete process.env[Env.PublicUrlBase];
|
|
125
|
-
o.timeout(1000);
|
|
126
|
-
const key = 'NuirTK8fozzCJV1iG1FznmdHhKvk6WaWuDhhEA1d40c=';
|
|
127
|
-
const request = mockRequest('/v1/tiles/WMTSCapabilities.xml', 'get', {
|
|
128
|
-
'if-none-match': key,
|
|
129
|
-
...apiKeyHeader,
|
|
130
|
-
});
|
|
131
|
-
const res = await handleRequest(request);
|
|
132
|
-
if (res.status === 200) {
|
|
133
|
-
o(res.header('eTaG')).equals(key); // this line is useful for discovering the new etag
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
o(res.status).equals(304);
|
|
137
|
-
o(rasterMock.calls.length).equals(0);
|
|
138
|
-
o(request.logContext['cache']).deepEquals({ key, match: key, hit: true });
|
|
139
|
-
});
|
|
140
|
-
o('should serve WMTSCapabilities for tile_set', async () => {
|
|
141
|
-
var _a;
|
|
142
|
-
const request = mockRequest('/v1/tiles/aerial@beta/WMTSCapabilities.xml', 'get', apiKeyHeader);
|
|
143
|
-
const res = await handleRequest(request);
|
|
144
|
-
o(res.status).equals(200);
|
|
145
|
-
o(res.header('content-type')).equals('text/xml');
|
|
146
|
-
o(res.header('cache-control')).equals('max-age=0');
|
|
147
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
148
|
-
o(body.slice(0, 100)).equals('<?xml version="1.0"?>\n' + '<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.op');
|
|
149
|
-
const vdom = await VNodeParser.parse(body);
|
|
150
|
-
const url = vdom.tags('ResourceURL').next().value;
|
|
151
|
-
o(url === null || url === void 0 ? void 0 : url.toString()).equals('<ResourceURL format="image/jpeg" resourceType="tile" ' +
|
|
152
|
-
`template="https://tiles.test/v1/tiles/aerial@beta/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.jpeg?api=${apiKey}" />`);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
o.spec('tileJson', () => {
|
|
156
|
-
o('should 404 if invalid url is given', async () => {
|
|
157
|
-
const request = mockRequest('/v1/tiles/tile.json', 'get', apiKeyHeader);
|
|
158
|
-
const res = await handleRequest(request);
|
|
159
|
-
o(res.status).equals(404);
|
|
160
|
-
});
|
|
161
|
-
o('should serve tile json for tile_set', async () => {
|
|
162
|
-
var _a;
|
|
163
|
-
const request = mockRequest('/v1/tiles/aerial/NZTM2000Quad/tile.json', 'get', apiKeyHeader);
|
|
164
|
-
const res = await handleRequest(request);
|
|
165
|
-
o(res.status).equals(200);
|
|
166
|
-
o(res.header('cache-control')).equals('no-store');
|
|
167
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
168
|
-
o(JSON.parse(body)).deepEquals({
|
|
169
|
-
tiles: [`https://tiles.test/v1/tiles/aerial/NZTM2000Quad/{z}/{x}/{y}.webp?api=${apiKey}`],
|
|
170
|
-
tilejson: '3.0.0',
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
o('should serve vector tiles', async () => {
|
|
174
|
-
var _a;
|
|
175
|
-
const request = mockRequest('/v1/tiles/topographic/WebMercatorQuad/tile.json', 'get', apiKeyHeader);
|
|
176
|
-
const res = await handleRequest(request);
|
|
177
|
-
o(res.status).equals(200);
|
|
178
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
179
|
-
o(JSON.parse(body)).deepEquals({
|
|
180
|
-
tiles: [`https://tiles.test/v1/tiles/topographic/EPSG:3857/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
181
|
-
tilejson: '3.0.0',
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
o('should serve vector tiles with min/max zoom', async () => {
|
|
185
|
-
var _a;
|
|
186
|
-
const fakeTileSet = new FakeTileSetVector('fake-vector', GoogleTms);
|
|
187
|
-
fakeTileSet.tileSet.maxZoom = 15;
|
|
188
|
-
fakeTileSet.tileSet.minZoom = 3;
|
|
189
|
-
TileSets.add(fakeTileSet);
|
|
190
|
-
const request = mockRequest('/v1/tiles/fake-vector/WebMercatorQuad/tile.json', 'get', apiKeyHeader);
|
|
191
|
-
const res = await handleRequest(request);
|
|
192
|
-
o(res.status).equals(200);
|
|
193
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
194
|
-
o(JSON.parse(body)).deepEquals({
|
|
195
|
-
tiles: [`https://tiles.test/v1/tiles/fake-vector/EPSG:3857/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
196
|
-
maxzoom: 15,
|
|
197
|
-
minzoom: 3,
|
|
198
|
-
tilejson: '3.0.0',
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
o('should serve convert zoom to tile matrix', async () => {
|
|
202
|
-
var _a;
|
|
203
|
-
const fakeTileSet = new FakeTileSetVector('fake-vector', Nztm2000QuadTms);
|
|
204
|
-
fakeTileSet.tileSet.maxZoom = 15;
|
|
205
|
-
fakeTileSet.tileSet.minZoom = 1;
|
|
206
|
-
TileSets.add(fakeTileSet);
|
|
207
|
-
const request = mockRequest('/v1/tiles/fake-vector/NZTM2000Quad/tile.json', 'get', apiKeyHeader);
|
|
208
|
-
const res = await handleRequest(request);
|
|
209
|
-
o(res.status).equals(200);
|
|
210
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
211
|
-
o(JSON.parse(body)).deepEquals({
|
|
212
|
-
tiles: [`https://tiles.test/v1/tiles/fake-vector/NZTM2000Quad/{z}/{x}/{y}.pbf?api=${apiKey}`],
|
|
213
|
-
maxzoom: 13,
|
|
214
|
-
minzoom: 0,
|
|
215
|
-
tilejson: '3.0.0',
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
o.spec('styleJson', () => {
|
|
220
|
-
o('should not found style json', async () => {
|
|
221
|
-
const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
|
|
222
|
-
sandbox.stub(Config.Style, 'get').resolves(null);
|
|
223
|
-
const res = await handleRequest(request);
|
|
224
|
-
o(res.status).equals(404);
|
|
225
|
-
});
|
|
226
|
-
o('should serve style json', async () => {
|
|
227
|
-
var _a;
|
|
228
|
-
const request = mockRequest('/v1/tiles/topographic/Google/style/topographic.json', 'get', apiKeyHeader);
|
|
229
|
-
const fakeStyle = {
|
|
230
|
-
version: 8,
|
|
231
|
-
id: 'test',
|
|
232
|
-
name: 'topographic',
|
|
233
|
-
sources: {
|
|
234
|
-
basemaps_vector: {
|
|
235
|
-
type: 'vector',
|
|
236
|
-
url: `/vector`,
|
|
237
|
-
},
|
|
238
|
-
basemaps_raster: {
|
|
239
|
-
type: 'raster',
|
|
240
|
-
tiles: [`/raster`],
|
|
241
|
-
},
|
|
242
|
-
basemaps_raster_encode: {
|
|
243
|
-
type: 'raster',
|
|
244
|
-
tiles: [`/raster/{z}/{x}/{y}.webp`], // Shouldn't encode the {}
|
|
245
|
-
},
|
|
246
|
-
test_vector: {
|
|
247
|
-
type: 'vector',
|
|
248
|
-
url: 'vector.url.co.nz',
|
|
249
|
-
},
|
|
250
|
-
test_raster: {
|
|
251
|
-
type: 'raster',
|
|
252
|
-
tiles: ['raster.url.co.nz'],
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
layers: [
|
|
256
|
-
{
|
|
257
|
-
layout: {
|
|
258
|
-
visibility: 'visible',
|
|
259
|
-
},
|
|
260
|
-
paint: {
|
|
261
|
-
'background-color': 'rgba(206, 229, 242, 1)',
|
|
262
|
-
},
|
|
263
|
-
id: 'Background',
|
|
264
|
-
type: 'background',
|
|
265
|
-
minzoom: 0,
|
|
266
|
-
},
|
|
267
|
-
],
|
|
268
|
-
glyphs: '/glyphs',
|
|
269
|
-
sprite: '/sprite',
|
|
270
|
-
metadata: { id: 'test' },
|
|
271
|
-
};
|
|
272
|
-
const fakeRecord = {
|
|
273
|
-
id: 'st_topographic_production',
|
|
274
|
-
name: 'topographic',
|
|
275
|
-
style: fakeStyle,
|
|
276
|
-
};
|
|
277
|
-
sandbox.stub(Config.Style, 'get').resolves(fakeRecord);
|
|
278
|
-
const res = await handleRequest(request);
|
|
279
|
-
o(res.status).equals(200);
|
|
280
|
-
o(res.header('content-type')).equals('application/json');
|
|
281
|
-
o(res.header('cache-control')).equals('no-store');
|
|
282
|
-
const body = Buffer.from((_a = res.body) !== null && _a !== void 0 ? _a : '', 'base64').toString();
|
|
283
|
-
fakeStyle.sources.basemaps_vector = {
|
|
284
|
-
type: 'vector',
|
|
285
|
-
url: `${host}/vector?api=${apiKey}`,
|
|
286
|
-
};
|
|
287
|
-
fakeStyle.sources.basemaps_raster = {
|
|
288
|
-
type: 'raster',
|
|
289
|
-
tiles: [`${host}/raster?api=${apiKey}`],
|
|
290
|
-
};
|
|
291
|
-
fakeStyle.sources.basemaps_raster_encode = {
|
|
292
|
-
type: 'raster',
|
|
293
|
-
tiles: [`${host}/raster/{z}/{x}/{y}.webp?api=${apiKey}`],
|
|
294
|
-
};
|
|
295
|
-
fakeStyle.sprite = `${host}/sprite`;
|
|
296
|
-
fakeStyle.glyphs = `${host}/glyphs`;
|
|
297
|
-
o(JSON.parse(body)).deepEquals(fakeStyle);
|
|
298
|
-
});
|
|
299
|
-
});
|
|
300
|
-
['/favicon.ico', '/index.html', '/foo/bar'].forEach((path) => {
|
|
301
|
-
o('should error on invalid paths: ' + path, async () => {
|
|
302
|
-
const res = await handleRequest(mockRequest(path, 'get', apiKeyHeader));
|
|
303
|
-
o(res.status).equals(404);
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
});
|
package/build/api.key.d.ts
DELETED
package/build/api.key.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.key.d.ts","sourceRoot":"","sources":["../src/api.key.ts"],"names":[],"mappings":"AAMA,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAgB7D"}
|
package/build/api.key.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as ulid from 'ulid';
|
|
2
|
-
const OneHourMs = 60 * 60 * 1000;
|
|
3
|
-
const OneDayMs = 24 * OneHourMs;
|
|
4
|
-
const MaxApiAgeMs = 91 * OneDayMs;
|
|
5
|
-
export function isValidApiKey(apiKey) {
|
|
6
|
-
if (apiKey == null)
|
|
7
|
-
return false;
|
|
8
|
-
if (!apiKey.startsWith('c') && !apiKey.startsWith('d'))
|
|
9
|
-
return false;
|
|
10
|
-
const ulidId = apiKey.slice(1).toUpperCase();
|
|
11
|
-
try {
|
|
12
|
-
const ulidTime = ulid.decodeTime(ulidId);
|
|
13
|
-
if (apiKey.startsWith('d'))
|
|
14
|
-
return true;
|
|
15
|
-
if (Date.now() - ulidTime > MaxApiAgeMs) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
catch (e) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
}
|
package/build/cli/dump.d.ts
DELETED
package/build/cli/dump.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../../src/cli/dump.ts"],"names":[],"mappings":""}
|
package/build/cli/dump.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Nztm2000Tms, ImageFormat } from '@basemaps/geo';
|
|
2
|
-
import { LogConfig } from '@basemaps/shared';
|
|
3
|
-
import { LambdaAlbRequest } from '@linzjs/lambda';
|
|
4
|
-
import { promises as fs } from 'fs';
|
|
5
|
-
import { tileXyz } from '../routes/tile.xyz.js';
|
|
6
|
-
import { TileSets } from '../tile.set.cache.js';
|
|
7
|
-
import { TileSetLocal } from './tile.set.local.js';
|
|
8
|
-
const xyz = { x: 0, y: 0, z: 0 };
|
|
9
|
-
const tileMatrix = Nztm2000Tms;
|
|
10
|
-
const tileSetName = 'aerial';
|
|
11
|
-
const ext = ImageFormat.Png;
|
|
12
|
-
/** Load a tileset form a file path otherwise default to the hard coded one from AWS */
|
|
13
|
-
async function getTileSet(filePath) {
|
|
14
|
-
if (filePath != null) {
|
|
15
|
-
const tileSet = new TileSetLocal('local', filePath);
|
|
16
|
-
await tileSet.load();
|
|
17
|
-
TileSets.add(tileSet);
|
|
18
|
-
return tileSet;
|
|
19
|
-
}
|
|
20
|
-
const tileSet = await TileSets.get(tileSetName, tileMatrix);
|
|
21
|
-
if (tileSet == null)
|
|
22
|
-
throw new Error('Missing');
|
|
23
|
-
return tileSet;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Utility to render a single tile then save it as a png
|
|
27
|
-
*/
|
|
28
|
-
async function main() {
|
|
29
|
-
var _a;
|
|
30
|
-
const logger = LogConfig.get();
|
|
31
|
-
const filePath = process.argv[2];
|
|
32
|
-
const tileSet = await getTileSet(filePath);
|
|
33
|
-
logger.info({ ...xyz, projection: tileMatrix.projection.code, tileMatrix: tileMatrix.identifier }, 'RenderTile');
|
|
34
|
-
const ctx = new LambdaAlbRequest({
|
|
35
|
-
httpMethod: 'get',
|
|
36
|
-
path: `/v1/tiles/${tileSet.fullName}/${tileMatrix.identifier}/${xyz.z}/${xyz.x}/${xyz.y}.${ext}`,
|
|
37
|
-
}, {}, logger);
|
|
38
|
-
const tileData = await tileXyz(ctx);
|
|
39
|
-
const headers = {};
|
|
40
|
-
for (const [key, value] of tileData.headers)
|
|
41
|
-
headers[key] = value;
|
|
42
|
-
logger.info({ ...tileData, _body: (_a = tileData.body) === null || _a === void 0 ? void 0 : _a.length, headers }, 'Done');
|
|
43
|
-
if (tileData._body != null) {
|
|
44
|
-
await fs.writeFile(`output_${xyz.x}_${xyz.y}_z${xyz.z}.${ext}`, tileData._body);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
main().catch(console.error);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CogTiff } from '@cogeotiff/core';
|
|
2
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
3
|
-
export declare class TileSetLocal extends TileSetRaster {
|
|
4
|
-
tiffs: CogTiff[];
|
|
5
|
-
filePath: string;
|
|
6
|
-
tileSet: any;
|
|
7
|
-
constructor(name: string, path: string);
|
|
8
|
-
setTitle(name: string): void;
|
|
9
|
-
load(): Promise<boolean>;
|
|
10
|
-
getTiffsForTile(): CogTiff[];
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=tile.set.local.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tile.set.local.d.ts","sourceRoot":"","sources":["../../src/cli/tile.set.local.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAc,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAMtD,qBAAa,YAAa,SAAQ,aAAa;IAC7C,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,MAAa;gBAER,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQtC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAItB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB9B,eAAe,IAAI,OAAO,EAAE;CAG7B"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Epsg, GoogleTms, TileMatrixSets } from '@basemaps/geo';
|
|
2
|
-
import { fsa, LogConfig } from '@basemaps/shared';
|
|
3
|
-
import { CogTiff, TiffTagGeo } from '@cogeotiff/core';
|
|
4
|
-
import { TileSetRaster } from '../tile.set.raster.js';
|
|
5
|
-
function isTiff(fileName) {
|
|
6
|
-
return fileName.toLowerCase().endsWith('.tif') || fileName.toLowerCase().endsWith('.tiff');
|
|
7
|
-
}
|
|
8
|
-
export class TileSetLocal extends TileSetRaster {
|
|
9
|
-
constructor(name, path) {
|
|
10
|
-
super(name, GoogleTms);
|
|
11
|
-
this.tileSet = {};
|
|
12
|
-
this.filePath = path;
|
|
13
|
-
this.tileSet.name = name;
|
|
14
|
-
this.tileSet.title = name;
|
|
15
|
-
this.tileSet.projection = GoogleTms.projection.code;
|
|
16
|
-
}
|
|
17
|
-
setTitle(name) {
|
|
18
|
-
this.tileSet.title = name;
|
|
19
|
-
}
|
|
20
|
-
async load() {
|
|
21
|
-
if (this.tiffs != null)
|
|
22
|
-
return true;
|
|
23
|
-
const fileList = isTiff(this.filePath) ? [this.filePath] : await fsa.toArray(fsa.list(this.filePath));
|
|
24
|
-
const files = fileList.filter(isTiff);
|
|
25
|
-
if (files.length === 0)
|
|
26
|
-
throw new Error(`No tiff files found in ${this.filePath}`);
|
|
27
|
-
this.tiffs = files.map((filePath) => new CogTiff(fsa.source(filePath)));
|
|
28
|
-
// Read in the projection information
|
|
29
|
-
const [firstTiff] = this.tiffs;
|
|
30
|
-
await firstTiff.init(true);
|
|
31
|
-
const projection = Epsg.get(firstTiff.getImage(0).valueGeo(TiffTagGeo.ProjectedCSTypeGeoKey));
|
|
32
|
-
this.tileMatrix = TileMatrixSets.get(projection);
|
|
33
|
-
LogConfig.get().info({ path: this.filePath, count: this.tiffs.length, tileMatrix: this.tileMatrix.identifier }, 'LoadedTiffs');
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
getTiffsForTile() {
|
|
37
|
-
return this.tiffs;
|
|
38
|
-
}
|
|
39
|
-
}
|
package/build/router.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
|
-
export declare type ReqCallback = (req: LambdaHttpRequest) => Promise<LambdaHttpResponse>;
|
|
3
|
-
export interface ActionData {
|
|
4
|
-
version: string;
|
|
5
|
-
name: string;
|
|
6
|
-
rest: string[];
|
|
7
|
-
}
|
|
8
|
-
export declare class Router {
|
|
9
|
-
static action(req: LambdaHttpRequest): ActionData;
|
|
10
|
-
static apiKey(req: LambdaHttpRequest): string | undefined;
|
|
11
|
-
private handlers;
|
|
12
|
-
handle(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
|
|
13
|
-
get(path: string, handler: ReqCallback): void;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=router.d.ts.map
|
package/build/router.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,oBAAY,WAAW,GAAG,CAAC,GAAG,EAAE,iBAAiB,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,qBAAa,MAAM;IACjB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAiB,GAAG,UAAU;IASjD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS;IASzD,OAAO,CAAC,QAAQ,CAAmC;IAE7C,MAAM,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAqBjE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;CAI9C"}
|
package/build/router.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Const } from '@basemaps/shared';
|
|
2
|
-
import { HttpHeader, LambdaHttpResponse } from '@linzjs/lambda';
|
|
3
|
-
export class Router {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.handlers = {};
|
|
6
|
-
}
|
|
7
|
-
static action(req) {
|
|
8
|
-
const path = req.path;
|
|
9
|
-
const [version, name, ...rest] = (path[0] === '/' ? path.slice(1) : path)
|
|
10
|
-
.split('/')
|
|
11
|
-
.map((c) => decodeURIComponent(c));
|
|
12
|
-
if (name == null)
|
|
13
|
-
return { version: 'v1', name: version, rest: [] };
|
|
14
|
-
return { version, name: name, rest };
|
|
15
|
-
}
|
|
16
|
-
static apiKey(req) {
|
|
17
|
-
var _a;
|
|
18
|
-
const apiKey = (_a = req.query.get(Const.ApiKey.QueryString)) !== null && _a !== void 0 ? _a : req.header('X-LINZ-Api-Key');
|
|
19
|
-
if (apiKey != null && !Array.isArray(apiKey)) {
|
|
20
|
-
req.set(Const.ApiKey.QueryString, this.apiKey);
|
|
21
|
-
return apiKey;
|
|
22
|
-
}
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
async handle(req) {
|
|
26
|
-
// Allow cross origin requests
|
|
27
|
-
if (req.method === 'options') {
|
|
28
|
-
return new LambdaHttpResponse(200, 'Options', {
|
|
29
|
-
[HttpHeader.Cors]: '*',
|
|
30
|
-
'Access-Control-Allow-Credentials': 'false',
|
|
31
|
-
'Access-Control-Allow-Methods': 'OPTIONS,GET,PUT,POST,DELETE',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (req.method !== 'GET')
|
|
35
|
-
return new LambdaHttpResponse(405, 'Method not allowed');
|
|
36
|
-
const action = Router.action(req);
|
|
37
|
-
const handler = action.version === 'v1' ? this.handlers[action.name] : null;
|
|
38
|
-
if (handler == null)
|
|
39
|
-
return new LambdaHttpResponse(404, 'Not Found');
|
|
40
|
-
const response = await handler(req);
|
|
41
|
-
response.header(HttpHeader.Cors, '*');
|
|
42
|
-
return response;
|
|
43
|
-
}
|
|
44
|
-
get(path, handler) {
|
|
45
|
-
if (this.handlers[path] != null)
|
|
46
|
-
throw new Error(path + ' already registered');
|
|
47
|
-
this.handlers[path] = handler;
|
|
48
|
-
}
|
|
49
|
-
}
|
package/build/routes/api.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { LambdaHttpResponse } from '@linzjs/lambda';
|
|
2
|
-
export declare function Health(): Promise<LambdaHttpResponse>;
|
|
3
|
-
export declare function Ping(): Promise<LambdaHttpResponse>;
|
|
4
|
-
export declare function Version(): Promise<LambdaHttpResponse>;
|
|
5
|
-
//# sourceMappingURL=api.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/routes/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAc,MAAM,gBAAgB,CAAC;AAKhE,wBAAsB,MAAM,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAE1D;AAED,wBAAsB,IAAI,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAExD;AAED,wBAAsB,OAAO,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAK3D"}
|
package/build/routes/api.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { LambdaHttpResponse, HttpHeader } from '@linzjs/lambda';
|
|
2
|
-
const OkResponse = new LambdaHttpResponse(200, 'ok');
|
|
3
|
-
OkResponse.header(HttpHeader.CacheControl, 'no-store');
|
|
4
|
-
export async function Health() {
|
|
5
|
-
return OkResponse;
|
|
6
|
-
}
|
|
7
|
-
export async function Ping() {
|
|
8
|
-
return OkResponse;
|
|
9
|
-
}
|
|
10
|
-
export async function Version() {
|
|
11
|
-
var _a;
|
|
12
|
-
const response = new LambdaHttpResponse(200, 'ok');
|
|
13
|
-
response.header(HttpHeader.CacheControl, 'no-store');
|
|
14
|
-
response.json({ version: (_a = process.env.GIT_VERSION) !== null && _a !== void 0 ? _a : 'dev', hash: process.env.GIT_HASH });
|
|
15
|
-
return response;
|
|
16
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TileMatrixSet } from '@basemaps/geo';
|
|
2
|
-
import { LambdaHttpRequest, LambdaHttpResponse } from '@linzjs/lambda';
|
|
3
|
-
export declare function vectorTileServer(req: LambdaHttpRequest, layerId: string, tms: TileMatrixSet): Promise<LambdaHttpResponse>;
|
|
4
|
-
/**
|
|
5
|
-
* /v1/esri/services/:layerId/VectorTileServer
|
|
6
|
-
*
|
|
7
|
-
* @example http://localhost:5000/v1/esri/services/topographic/VectorTileServer
|
|
8
|
-
*/
|
|
9
|
-
export declare function Esri(req: LambdaHttpRequest): Promise<LambdaHttpResponse>;
|
|
10
|
-
//# sourceMappingURL=rest.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../../../src/routes/esri/rest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAKvE,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,aAAa,GACjB,OAAO,CAAC,kBAAkB,CAAC,CAiD7B;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAsB9E"}
|