diff --git a/.github/workflows/test.benchmark.yml b/.github/workflows/test.benchmark.yml deleted file mode 100644 index 45b1fcf..0000000 --- a/.github/workflows/test.benchmark.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: test:benchmark - -on: - workflow_dispatch: - -jobs: - benchmark: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '20' - cache: npm - cache-dependency-path: package-lock.json - - - name: start server - run: docker compose up -d - - - name: run test - run: | - npm ci - npm run test:benchmark diff --git a/package.json b/package.json index aa67f8f..6c943db 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "name": "chiitiler", - "version": "1.12.7", + "version": "1.13.0", "description": "Tiny map rendering server for MapLibre Style Spec", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/index.test.ts b/src/index.test.ts new file mode 100644 index 0000000..e8a1010 --- /dev/null +++ b/src/index.test.ts @@ -0,0 +1,25 @@ +import { describe, it, expect } from 'vitest'; + +import { + getRenderedBboxBuffer, + getRenderedBboxStream, + getRenderedTileBuffer, + getRenderedTileStream, + ChiitilerCache, +} from './index.js'; + +describe('library mode', () => { + // testing actual behavior of rendering methods is difficult... + it('members are exported', async () => { + expect(getRenderedBboxBuffer).toBeDefined(); + expect(getRenderedBboxStream).toBeDefined(); + expect(getRenderedTileBuffer).toBeDefined(); + expect(getRenderedTileStream).toBeDefined(); + + // actual behaviors are tested in cache module + expect(ChiitilerCache.fileCache).toBeDefined(); + expect(ChiitilerCache.memoryCache).toBeDefined(); + expect(ChiitilerCache.noneCache).toBeDefined(); + expect(ChiitilerCache.s3Cache).toBeDefined(); + }); +}); diff --git a/src/server/index.test.ts b/src/server/index.test.ts index b51f1bd..330f8f2 100644 --- a/src/server/index.test.ts +++ b/src/server/index.test.ts @@ -11,6 +11,7 @@ describe('initServer', () => { port: 8989, cache: cache.noneCache(), debug: false, + stream: false, }); const res = await app.request('/health'); expect(res.status).toBe(200); @@ -28,6 +29,7 @@ describe('initServer', () => { port: 8989, cache: cache.noneCache(), debug: true, + stream: false, }); const res = await app.request('/health'); expect(res.status).toBe(200); @@ -45,6 +47,7 @@ describe('initServer', () => { port: 8989, cache: cache.noneCache(), debug: false, + stream: false, }); const res = await app.request('/tiles/0/0/0.png'); @@ -71,6 +74,7 @@ describe('initServer', () => { port: 8989, cache: cache.noneCache(), debug: false, + stream: false, }); const res = await app.request('/clip.png?bbox=0,1,2,3'); diff --git a/src/server/index.ts b/src/server/index.ts index a2455d5..dfaa249 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -113,6 +113,8 @@ function initServer(options: InitServerOptions): InitializedServer { const quality = Number(c.req.query('quality') ?? 100); const margin = Number(c.req.query('margin') ?? 0); + c.header('Content-Type', `image/${ext}`); + try { const sharp = await getRenderedTile({ stylejson: style, @@ -162,6 +164,8 @@ function initServer(options: InitServerOptions): InitializedServer { const quality = Number(c.req.query('quality') ?? 100); const size = Number(c.req.query('size') ?? 1024); + c.header('Content-Type', `image/${ext}`); + try { const sharp = await getRenderedBbox({ stylejson: url, @@ -209,6 +213,8 @@ function initServer(options: InitServerOptions): InitializedServer { const quality = Number(c.req.query('quality') ?? 100); const size = Number(c.req.query('size') ?? 1024); + c.header('Content-Type', `image/${ext}`); + try { const sharp = await getRenderedBbox({ stylejson: style,