fix: refactor to use validateStyleMin
Signed-off-by: Andrew Calcutt <acalcutt@techidiots.net>
This commit is contained in:
parent
dc746c4a56
commit
89bd54e8e2
1 changed files with 3 additions and 3 deletions
|
|
@ -5,7 +5,7 @@ import fs from 'node:fs';
|
||||||
|
|
||||||
import clone from 'clone';
|
import clone from 'clone';
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { validate } from '@maplibre/maplibre-gl-style-spec';
|
import { validateStyleMin } from '@maplibre/maplibre-gl-style-spec';
|
||||||
|
|
||||||
import { getPublicUrl } from './utils.js';
|
import { getPublicUrl } from './utils.js';
|
||||||
|
|
||||||
|
|
@ -86,7 +86,8 @@ export const serve_style = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationErrors = validate(styleFileData);
|
const styleJSON = JSON.parse(styleFileData);
|
||||||
|
const validationErrors = validateStyleMin(styleJSON);
|
||||||
if (validationErrors.length > 0) {
|
if (validationErrors.length > 0) {
|
||||||
console.log(`The file "${params.style}" is not a valid style file:`);
|
console.log(`The file "${params.style}" is not a valid style file:`);
|
||||||
for (const err of validationErrors) {
|
for (const err of validationErrors) {
|
||||||
|
|
@ -94,7 +95,6 @@ export const serve_style = {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const styleJSON = JSON.parse(styleFileData);
|
|
||||||
|
|
||||||
for (const name of Object.keys(styleJSON.sources)) {
|
for (const name of Object.keys(styleJSON.sources)) {
|
||||||
const source = styleJSON.sources[name];
|
const source = styleJSON.sources[name];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue