mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
backend: route save / restore
This commit is contained in:
parent
032821329b
commit
d932fcb287
17 changed files with 163 additions and 43 deletions
24
backend/utils/parse.js
Normal file
24
backend/utils/parse.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
module.exports.parseRoute = route => route.filter(el => (
|
||||
Object.keys(el).length === 2
|
||||
&& el.lat
|
||||
&& parseInt(el.lat, 10) > 0
|
||||
&& parseInt(el.lat, 10) < 1000
|
||||
&& el.lng
|
||||
&& parseInt(el.lng, 10) > 0
|
||||
&& parseInt(el.lng, 10) < 1000
|
||||
));
|
||||
|
||||
module.exports.parseStickers = stickers => stickers.filter(el => (
|
||||
Object.keys(el).length === 3
|
||||
&& el.latlng
|
||||
&& Object.keys(el.latlng).length === 2
|
||||
&& el.latlng.lat
|
||||
&& parseInt(el.latlng.lat, 10) > 0
|
||||
&& parseInt(el.latlng.lat, 10) < 1000
|
||||
&& el.latlng.lng
|
||||
&& parseInt(el.latlng.lng, 10) > 0
|
||||
&& parseInt(el.latlng.lng, 10) < 1000
|
||||
));
|
||||
|
||||
module.exports.parseString = (value, size) => (value && String(value).substr(0, size)) || '';
|
||||
module.exports.parseNumber = (value, min, max) => (value && Number(value) && Math.min(max, Math.max(min, value))) || 0;
|
Loading…
Add table
Add a link
Reference in a new issue