Merge branch 'master' into windows
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
commit
49c27cf77d
6 changed files with 688 additions and 694 deletions
|
@ -28,5 +28,9 @@ module.exports = {
|
|||
rules: {
|
||||
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'warn',
|
||||
{ argsIgnorePattern: 'next|err|info|reject' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
1266
package-lock.json
generated
1266
package-lock.json
generated
File diff suppressed because it is too large
Load diff
20
package.json
20
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tileserver-gl",
|
||||
"version": "4.6.5",
|
||||
"version": "4.6.6",
|
||||
"description": "Map tile server for JSON GL styles - vector and server side generated raster tiles",
|
||||
"main": "src/main.js",
|
||||
"bin": "src/main.js",
|
||||
|
@ -27,6 +27,7 @@
|
|||
"@maplibre/maplibre-gl-style-spec": "18.0.0",
|
||||
"@sindresorhus/fnv1a": "3.0.0",
|
||||
"advanced-pool": "0.3.3",
|
||||
"axios": "^1.6.2",
|
||||
"canvas": "2.11.2",
|
||||
"chokidar": "3.5.3",
|
||||
"clone": "2.1.2",
|
||||
|
@ -40,26 +41,25 @@
|
|||
"pbf": "3.2.1",
|
||||
"pmtiles": "2.11.0",
|
||||
"proj4": "2.9.2",
|
||||
"request": "2.88.2",
|
||||
"sanitize-filename": "1.6.3",
|
||||
"sharp": "0.32.3",
|
||||
"tileserver-gl-styles": "2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^18.2.0",
|
||||
"@commitlint/config-conventional": "^18.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.61.0",
|
||||
"@typescript-eslint/parser": "^5.62.0",
|
||||
"@commitlint/cli": "^18.4.1",
|
||||
"@commitlint/config-conventional": "^18.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"chai": "4.3.10",
|
||||
"eslint": "^8.53.0",
|
||||
"eslint-config-prettier": "^9.0.0",
|
||||
"eslint-plugin-jsdoc": "^46.8.2",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-jsdoc": "^46.9.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"eslint-plugin-security": "^1.7.1",
|
||||
"husky": "^8.0.3",
|
||||
"lint-staged": "^15.0.2",
|
||||
"lint-staged": "^15.1.0",
|
||||
"mocha": "^10.2.0",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.1.0",
|
||||
"should": "^13.2.3",
|
||||
"supertest": "^6.3.3",
|
||||
"yaml-lint": "^1.7.0"
|
||||
|
|
21
src/main.js
21
src/main.js
|
@ -5,7 +5,7 @@
|
|||
import fs from 'node:fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import request from 'request';
|
||||
import axios from 'axios';
|
||||
import { server } from './server.js';
|
||||
import MBTiles from '@mapbox/mbtiles';
|
||||
import { isValidHttpUrl } from './utils.js';
|
||||
|
@ -271,11 +271,24 @@ fs.stat(path.resolve(opts.config), (err, stats) => {
|
|||
const url =
|
||||
'https://github.com/maptiler/tileserver-gl/releases/download/v1.3.0/zurich_switzerland.mbtiles';
|
||||
const filename = 'zurich_switzerland.mbtiles';
|
||||
const stream = fs.createWriteStream(filename);
|
||||
const writer = fs.createWriteStream(filename);
|
||||
console.log(`No input file found`);
|
||||
console.log(`[DEMO] Downloading sample data (${filename}) from ${url}`);
|
||||
stream.on('finish', () => StartWithInputFile(filename));
|
||||
return request.get(url).pipe(stream);
|
||||
axios({
|
||||
url,
|
||||
method: 'GET',
|
||||
responseType: 'stream',
|
||||
})
|
||||
.then((response) => {
|
||||
response.data.pipe(writer);
|
||||
writer.on('finish', () => StartWithInputFile(filename));
|
||||
writer.on('error', (err) =>
|
||||
console.error(`Error writing file: ${err}`),
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(`Error downloading file: ${error}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -17,7 +17,7 @@ import mlgl from '@maplibre/maplibre-gl-native';
|
|||
import MBTiles from '@mapbox/mbtiles';
|
||||
import polyline from '@mapbox/polyline';
|
||||
import proj4 from 'proj4';
|
||||
import request from 'request';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
getFontsPbf,
|
||||
getTileUrls,
|
||||
|
@ -1353,37 +1353,36 @@ export const serve_rendered = {
|
|||
});
|
||||
}
|
||||
} else if (protocol === 'http' || protocol === 'https') {
|
||||
request(
|
||||
{
|
||||
url: req.url,
|
||||
encoding: null,
|
||||
gzip: true,
|
||||
},
|
||||
(err, res, body) => {
|
||||
const parts = url.parse(req.url);
|
||||
const extension = path.extname(parts.pathname).toLowerCase();
|
||||
const format = extensionToFormat[extension] || '';
|
||||
if (err || res.statusCode < 200 || res.statusCode >= 300) {
|
||||
// console.log('HTTP error', err || res.statusCode);
|
||||
createEmptyResponse(format, '', callback);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await axios.get(req.url, {
|
||||
responseType: 'arraybuffer', // Get the response as raw buffer
|
||||
// Axios handles gzip by default, so no need for a gzip flag
|
||||
});
|
||||
|
||||
const response = {};
|
||||
if (res.headers.modified) {
|
||||
response.modified = new Date(res.headers.modified);
|
||||
}
|
||||
if (res.headers.expires) {
|
||||
response.expires = new Date(res.headers.expires);
|
||||
}
|
||||
if (res.headers.etag) {
|
||||
response.etag = res.headers.etag;
|
||||
}
|
||||
const responseHeaders = response.headers;
|
||||
const responseData = response.data;
|
||||
|
||||
response.data = body;
|
||||
callback(null, response);
|
||||
},
|
||||
);
|
||||
const parsedResponse = {};
|
||||
if (responseHeaders['last-modified']) {
|
||||
parsedResponse.modified = new Date(
|
||||
responseHeaders['last-modified'],
|
||||
);
|
||||
}
|
||||
if (responseHeaders.expires) {
|
||||
parsedResponse.expires = new Date(responseHeaders.expires);
|
||||
}
|
||||
if (responseHeaders.etag) {
|
||||
parsedResponse.etag = responseHeaders.etag;
|
||||
}
|
||||
|
||||
parsedResponse.data = responseData;
|
||||
callback(null, parsedResponse);
|
||||
} catch (error) {
|
||||
const parts = url.parse(req.url);
|
||||
const extension = path.extname(parts.pathname).toLowerCase();
|
||||
const format = extensionToFormat[extension] || '';
|
||||
createEmptyResponse(format, '', callback);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
|
@ -151,10 +151,9 @@ function start(opts) {
|
|||
|
||||
if (options.dataDecorator) {
|
||||
try {
|
||||
options.dataDecoratorFunc = require(path.resolve(
|
||||
paths.root,
|
||||
options.dataDecorator,
|
||||
));
|
||||
options.dataDecoratorFunc = require(
|
||||
path.resolve(paths.root, options.dataDecorator),
|
||||
);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
|
@ -427,9 +426,8 @@ function start(opts) {
|
|||
return res.status(404).send('Not found');
|
||||
}
|
||||
}
|
||||
data[
|
||||
'server_version'
|
||||
] = `${packageJson.name} v${packageJson.version}`;
|
||||
data['server_version'] =
|
||||
`${packageJson.name} v${packageJson.version}`;
|
||||
data['public_url'] = opts.publicUrl || '/';
|
||||
data['is_light'] = isLight;
|
||||
data['key_query_part'] = req.query.key
|
||||
|
|
Loading…
Reference in a new issue