Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 169 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
"@types/aws-lambda": "^8.10.83",
"@types/geojson": "^7946.0.8",
"@types/node": "^20.10.4",
"@types/unzipper": "^0.10.11",
"@types/yazl": "^3.3.0",
"aws-cdk": "^2.1004.0",
"constructs": "^10.4.2",
"esbuild": "^0.19.9"
"esbuild": "^0.19.9",
"yazl": "^3.3.1"
Comment thread
Wentao-Kuang marked this conversation as resolved.
},
"scripts": {
"build": "tsc",
Expand All @@ -40,7 +43,7 @@
"@linzjs/geojson": "^6.9.1",
"@linzjs/lambda": "^4.1.0",
"aws-cdk-lib": "^2.184.1",
"fflate": "^0.8.1",
"stac-ts": "^1.0.3"
"stac-ts": "^1.0.3",
"unzipper": "^0.12.3"
}
}
33 changes: 33 additions & 0 deletions src/__test__/storage.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import assert from 'node:assert';
import { createHash } from 'node:crypto';
import { Readable } from 'node:stream';
import { describe, it } from 'node:test';

import { HashTransform } from '@chunkd/fs/build/src/hash.stream.js';
import type { LogType } from '@linzjs/lambda';
import { ZipFile } from 'yazl';

describe('StorageTest', () => {
it('should unzip geopackage file', async () => {
process.env['KX_API_KEY'] = 'test';
const { extractAndWritePackage } = await import('../storage.ts');

const zipFile = new ZipFile();
zipFile.addBuffer(Buffer.from('hello'), 'test.gpkg');
zipFile.end();

const stream = Readable.from(zipFile.outputStream);
const targetFileUri = new URL('file:///tmp/output.gpkg');
const ht = new HashTransform('sha256');
const datasetId = 0;
const log: Partial<LogType> = {
debug: () => {},
info: () => {},
};

await extractAndWritePackage(stream, targetFileUri, ht, datasetId, log as LogType);

const expectedHash = createHash('sha256').update('hello').digest('hex');
assert.strictEqual(ht.digestHex, expectedHash);
});
});
Loading
Loading