Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const defaultConfig = {
mapConfig: {
container: 'map',
style: '//raw.githubusercontent.com/NYCPlanning/labs-gl-style/master/data/style.json',
center: [-73.93181409196421, 40.708434183373726],
zoom: 10.2,
bearing: 0,
pitch: 0,
},
title: 'New York City',
logo: 'https://raw.githubusercontent.com/NYCPlanning/logo/master/dcp_logo_772.png',
content: '',
};
// Initialize a Validator instance first
const validator = new Validator({allErrors: true}); // pass in options to the Ajv instance
// Define a shortcut function
const validate = validator.validate;
// Define a JSON Schema
const PrintSchema = {
type: 'object',
required: ['title', 'mapConfig'],
properties: {
title: {
type: 'string',
},
mapConfig: {
type: 'object',
required: ['style', 'center', 'zoom'],
properties: {
import { Validator } from 'express-json-validator-middleware'
import AlarmSchema from '../schemas/alarms'
const validator = new Validator({ allErrors: true })
const validate = validator.validate.bind(validator)
export default class AlarmRouter {
constructor(alarmService) {
this.alarm = alarmService
}
setup(app) {
app.post('/alarms', validate({ body: AlarmSchema }), this.postAlarm)
app.get('/alarms/:id', this.getAlarm)
app.delete('/alarms/:id', this.deleteAlarm)
}
get postAlarm() {
return (req, res) => buildResponseSchema(this.alarm.storeNewAlarm(req.body), res)
}