@mapwhit/tileserver 3.7.2 → 4.0.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/bin/tileserver +1 -1
- package/index.js +8 -5
- package/lib/env.js +3 -0
- package/lib/server.js +10 -15
- package/lib/tiles.js +9 -13
- package/lib/utils.js +2 -7
- package/package.json +3 -2
package/bin/tileserver
CHANGED
package/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import ms from 'ms';
|
|
2
|
+
import rc from 'rc';
|
|
3
|
+
import makeServer from './lib/server';
|
|
4
|
+
import packageJSON from './package.json' with { type: 'json' };
|
|
5
|
+
|
|
6
|
+
const { name, version } = packageJSON;
|
|
7
|
+
|
|
8
|
+
const config = rc('tiles', {
|
|
3
9
|
port: process.env.PORT || 5080,
|
|
4
10
|
bind: process.env.BIND
|
|
5
11
|
// max-age: // 'max-age for Cache-Control header: "5d", "3h", "1y" etc.'
|
|
6
12
|
});
|
|
7
13
|
|
|
8
|
-
const { name, version } = require('./package.json');
|
|
9
|
-
const makeServer = require('./lib/server');
|
|
10
|
-
|
|
11
14
|
function startServer() {
|
|
12
15
|
config.cacheControl = cacheControl(config['max-age']);
|
|
13
16
|
|
package/lib/env.js
ADDED
package/lib/server.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
Math.max(4, require('node:os').cpus().length * 1.5)
|
|
3
|
-
);
|
|
1
|
+
import './env.js';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import connect from '@pirxpilot/connect';
|
|
6
|
+
import Router from '@pirxpilot/router';
|
|
7
|
+
import timings from 'server-timings';
|
|
8
|
+
import tiles from './tiles.js';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
module.exports = makeServer;
|
|
14
|
-
|
|
15
|
-
function makeServer(config, callback = () => {}) {
|
|
10
|
+
export default function makeServer(config, callback = () => {}) {
|
|
16
11
|
const { options = {}, data = {}, cacheControl } = config;
|
|
17
12
|
|
|
18
13
|
options.paths = checkPath(options.paths);
|
|
@@ -23,7 +18,7 @@ function makeServer(config, callback = () => {}) {
|
|
|
23
18
|
timings(req, res, next);
|
|
24
19
|
});
|
|
25
20
|
if (cacheControl) {
|
|
26
|
-
app.use(
|
|
21
|
+
app.use((_req, res, next) => {
|
|
27
22
|
res.setHeader('Cache-Control', cacheControl);
|
|
28
23
|
next();
|
|
29
24
|
});
|
|
@@ -52,7 +47,7 @@ function makeServer(config, callback = () => {}) {
|
|
|
52
47
|
return callback();
|
|
53
48
|
});
|
|
54
49
|
|
|
55
|
-
process.on('SIGINT',
|
|
50
|
+
process.on('SIGINT', () => {
|
|
56
51
|
process.exit();
|
|
57
52
|
});
|
|
58
53
|
|
package/lib/tiles.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = serveData;
|
|
12
|
-
|
|
13
|
-
function serveData(mountPath, options, item) {
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import mbtiles from '@mapwhit/mbtiles';
|
|
5
|
+
import Router from '@pirxpilot/router';
|
|
6
|
+
import fresh from 'fresh';
|
|
7
|
+
import { fixTileJSONCenter, getTileUrls } from './utils.js';
|
|
8
|
+
|
|
9
|
+
export default function serveData(mountPath, options, item) {
|
|
14
10
|
const domains = item.domains || options.domains;
|
|
15
11
|
const format = 'pbf';
|
|
16
12
|
const suffix = options.pbfAlias ?? format;
|
package/lib/utils.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
getTileUrls,
|
|
3
|
-
fixTileJSONCenter
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
function getTileUrls(req, domains, path, format) {
|
|
1
|
+
export function getTileUrls(req, domains, path, format) {
|
|
7
2
|
if (domains && typeof domains === 'string') {
|
|
8
3
|
domains = domains.split(/\s*,\s*/);
|
|
9
4
|
}
|
|
@@ -21,7 +16,7 @@ function getTileUrls(req, domains, path, format) {
|
|
|
21
16
|
);
|
|
22
17
|
}
|
|
23
18
|
|
|
24
|
-
function fixTileJSONCenter(tileJSON) {
|
|
19
|
+
export function fixTileJSONCenter(tileJSON) {
|
|
25
20
|
if (tileJSON.bounds && !tileJSON.center) {
|
|
26
21
|
const fitWidth = 1024;
|
|
27
22
|
const tiles = fitWidth / 256;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapwhit/tileserver",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Map tile server for JSON GL styles - serving vector tiles",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tileserver": "bin/tileserver",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/mapwhit/tileserver.git"
|
|
16
16
|
},
|
|
17
|
+
"type": "module",
|
|
17
18
|
"license": "BSD-2-Clause",
|
|
18
19
|
"scripts": {
|
|
19
20
|
"test": "make check"
|
|
@@ -28,7 +29,7 @@
|
|
|
28
29
|
"server-timings": "~2"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
|
-
"@biomejs/biome": "2.1
|
|
32
|
+
"@biomejs/biome": "2.3.1"
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
|
34
35
|
"index.js",
|