chiitiler 1.12.2 → 1.12.3

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.
@@ -0,0 +1,27 @@
1
+ import { GetObjectCommand } from '@aws-sdk/client-s3';
2
+ import { getS3Client } from '../s3.js';
3
+ async function getS3Source(uri) {
4
+ const s3Client = getS3Client({
5
+ region: process.env.CHIITILER_S3_REGION ?? 'us-east1',
6
+ endpoint: process.env.CHIITILER_S3_ENDPOINT ?? null,
7
+ });
8
+ const bucket = uri.replace('s3://', '').split('/')[0];
9
+ const key = uri.replace(`s3://${bucket}/`, '');
10
+ const cmd = new GetObjectCommand({
11
+ Bucket: bucket,
12
+ Key: key,
13
+ });
14
+ try {
15
+ const obj = await s3Client.send(cmd);
16
+ if (obj.Body === undefined)
17
+ return null;
18
+ const buf = Buffer.from(await obj.Body.transformToByteArray());
19
+ return buf;
20
+ }
21
+ catch (e) {
22
+ if (e.name !== 'NoSuchKey')
23
+ console.log(e);
24
+ return null;
25
+ }
26
+ }
27
+ export { getS3Source };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chiitiler",
4
- "version": "1.12.2",
4
+ "version": "1.12.3",
5
5
  "description": "Tiny map rendering server for MapLibre Style Spec",
6
6
  "main": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -15,7 +15,8 @@
15
15
  "test:unit": "vitest src",
16
16
  "test:coverage": "vitest src --coverage --coverage.provider=v8",
17
17
  "test:integration": "vitest tests/integration.test.ts",
18
- "test:benchmark": "vitest bench"
18
+ "test:benchmark": "vitest bench",
19
+ "prepare": "npm run build"
19
20
  },
20
21
  "keywords": [],
21
22
  "author": "Kanahiro Iguchi",
@@ -50,4 +51,4 @@
50
51
  "pmtiles": "^3.0.5",
51
52
  "sharp": "^0.32.5"
52
53
  }
53
- }
54
+ }