lambda-serverless-api
Advanced tools
Comparing version 8.1.0 to 8.2.0
@@ -43,2 +43,6 @@ "use strict"; | ||
const GeoPoly = require('./param/geo-poly'); | ||
const GeoPolyList = require('./param/geo-poly-list'); | ||
const GeoRect = require('./param/geo-rect'); | ||
@@ -48,2 +52,4 @@ | ||
const GeoShapeList = require('./param/geo-shape-list'); | ||
const NumberParam = require('./param/number-param'); | ||
@@ -91,2 +97,6 @@ | ||
module.exports.GeoPoly = (...args) => new GeoPoly(...args); | ||
module.exports.GeoPolyList = (...args) => new GeoPolyList(...args); | ||
module.exports.GeoRect = (...args) => new GeoRect(...args); | ||
@@ -96,2 +106,4 @@ | ||
module.exports.GeoShapeList = (...args) => new GeoShapeList(...args); | ||
module.exports.Number = (...args) => new NumberParam(...args); |
"use strict"; | ||
const assert = require('assert'); | ||
const Joi = require('joi-strict'); | ||
const Json = require('./json'); | ||
const validateGeoShape = require('../util/validate-geo-shape'); | ||
const { | ||
genSchema | ||
} = require('../util/geo-shape'); | ||
const genSchema = ({ | ||
maxPoints, | ||
clockwise, | ||
relaxed | ||
}) => { | ||
assert(relaxed === undefined || typeof relaxed === 'boolean'); | ||
const schema = Joi.array().items(Joi.array().ordered(Joi.number().min(-180).max(180), Joi.number().min(-90).max(90))).custom((value, _) => { | ||
if (!validateGeoShape({ | ||
geoShape: value, | ||
clockwise, | ||
relaxed: relaxed === true | ||
})) { | ||
throw new Error('Invalid GeoShape'); | ||
} | ||
return value; | ||
}); | ||
return maxPoints === undefined ? schema : schema.max(maxPoints); | ||
}; | ||
class GeoShape extends Json { | ||
constructor(name, position, opts = {}) { | ||
const schema = genSchema(opts); | ||
const schema = genSchema({ | ||
maxPoints: opts.maxPoints, | ||
clockwise: opts.clockwise, | ||
relaxed: opts.relaxed | ||
}); | ||
super(name, position, { ...opts, | ||
@@ -35,0 +17,0 @@ schema |
@@ -42,3 +42,3 @@ { | ||
}, | ||
"version": "8.1.0", | ||
"version": "8.2.0", | ||
"scripts": { | ||
@@ -45,0 +45,0 @@ "clean": "rm -rf lib", |
@@ -103,4 +103,7 @@ # Rest Abstraction for Serverless API | ||
- _GeoPoint_: GPS coordinate input | ||
- _GeoPoly_: GPS coordinate of polygon input and holes | ||
- _GeoPolyList_: List of GPS coordinate of polygon input and holes | ||
- _GeoRect_: GPS coordinate rectangle input | ||
- _GeoShape_: GPS coordinate polygon input | ||
- _GeoShapeList_: GPS coordinate polygon list input | ||
- _Int_: Integer input | ||
@@ -107,0 +110,0 @@ - _IntShort_: Short Integer input |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97577
70
2366
236