Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const Joi = require('@hapi/joi')
const isObjectId = require('../../util/is-object-id')
const pointSchemaJoi = Joi.object().keys({
_id: Joi.any()
.custom(isObjectId)
.allow(null),
type: Joi.string()
.valid('Point')
.required(),
coordinates: Joi.array()
.ordered(
Joi.number()
.max(-66)
.min(-128)
.required(), // general continental US longitude parameters
Joi.number()
.min(23)
.max(50)
.required(), // general continental US latitude parameters, to keep
// from accidentally switching lat, lng
)
.min(2)
.max(2),
})
const addressSchemaJoi = Joi.object().keys({
const hexSchema = Joi.object({
downloads: Joi.object({
// these keys may or may not exist
all: Joi.number()
.integer()
.default(0),
week: Joi.number()
.integer()
.default(0),
day: Joi.number()
.integer()
.default(0),
}).required(),
meta: Joi.object({
licenses: Joi.array().required(),
}).required(),
releases: Joi.array()
.items(Joi.object({ version: Joi.string().required() }).required())
.required(),
}).required()
class BaseHexPmService extends BaseJsonService {
static get defaultBadgeData() {
return { label: 'hex' }
}
async fetch({ packageName }) {
return this._requestJson({
schema: hexSchema,
url: `https://hex.pm/api/packages/${packageName}`,
})
Use of this source code is governed by an MIT-style
license that can be found in the LICENSE file or at
https://opensource.org/licenses/MIT.
*/
const joi = require('@hapi/joi');
const baseSchema = require('./base-schema');
const defaults = require('./defaults');
// Define some additional constraints.
module.exports = baseSchema.keys({
globDirectory: joi.string().required(),
globFollow: joi.boolean().default(defaults.globFollow),
globIgnores: joi.array().items(joi.string()).default(defaults.globIgnores),
globPatterns: joi.array().items(joi.string()).default(defaults.globPatterns),
globStrict: joi.boolean().default(defaults.globStrict),
});
filters: Joi.array().items(Joi.object().keys({
dimension: id,
member: id,
operator: Joi.valid(operators).required(),
values: Joi.array().items(Joi.string().allow(''))
}).xor('dimension', 'member')),
timeDimensions: Joi.array().items(Joi.object().keys({
dimension: id.required(),
granularity: Joi.valid('day', 'month', 'year', 'week', 'hour', 'minute', 'second', null),
dateRange: [
Joi.array().items(Joi.string()).min(1).max(2),
Joi.string()
]
})),
order: Joi.object().pattern(id, Joi.valid('asc', 'desc')),
segments: Joi.array().items(id),
timezone: Joi.string(),
limit: Joi.number().integer().min(1).max(50000),
offset: Joi.number().integer().min(0),
renewQuery: Joi.boolean(),
ungrouped: Joi.boolean()
});
const normalizeQuery = (query) => {
// eslint-disable-next-line no-unused-vars
const { error, value } = Joi.validate(query, querySchema);
if (error) {
throw new UserError(`Invalid query format: ${error.message || error.toString()}`);
}
const validQuery = query.measures && query.measures.length ||
query.dimensions && query.dimensions.length ||
query.timeDimensions && query.timeDimensions.filter(td => !!td.granularity).length;
const strategySchema = require('./routes/admin-api/strategy-schema');
const YAML = require('js-yaml');
const {
FEATURE_IMPORT,
DROP_FEATURES,
STRATEGY_IMPORT,
DROP_STRATEGIES,
} = require('./event-type');
const dataSchema = joi.object().keys({
version: joi.number(),
features: joi
.array()
.optional()
.items(featureShema),
strategies: joi
.array()
.optional()
.items(strategySchema),
});
function readFile(file) {
return new Promise((resolve, reject) =>
fs.readFile(file, (err, v) => (err ? reject(err) : resolve(v)))
);
}
function parseFile(file, data) {
return mime.getType(file) === 'text/yaml'
? YAML.safeLoad(data)
: JSON.parse(data);
}
tags: ['api'],
validate: {
params: Joi.object().keys({
uId: Joi.string().hex().length(31).required().description('the universally-unique identifier'),
apiV: Joi.string().required().description('the api version')
}).unknown(true),
payload: Joi.object().keys({
proof: Joi.string().required().description('credential registration request')
}).unknown(true).required()
},
response: {
schema: Joi.object().keys({
verification: Joi.string().required().description('credential registration response'),
surveyorIds: Joi.array().min(1).items(Joi.string()).required().description('allowed surveyors')
})
}
}
const keychainSchema = Joi.object().keys({
xpub: braveJoi.string().Xpub().required(),
path: Joi.string().optional(),
encryptedXprv: Joi.string().optional()
})
v1.createPersona =
{ handler: (runtime) => createPersona(runtime, 1),
description: 'Registers a user persona',
tags: ['api'],
validate: {
.example(10),
created: Joi.string()
.required()
.isoDate()
.description('ISO date string')
.example('2015-12-01'),
modified: Joi.string()
.isoDate()
.description('ISO date string')
.example('2015-12-01')
})
.label('Sum')
.description('json body for sum');
const listModel = Joi.object({
items: Joi.array().items(sumModel),
count: Joi.number()
.required()
.example('1'),
pageSize: Joi.number()
.required()
.example('10'),
page: Joi.number()
.required()
.example('1'),
pageCount: Joi.number()
.required()
.example('1')
}).label('List');
const resultModel = Joi.object({
equals: Joi.number()
indent: joi.alternatives().try(joi.number(), joi.string()).allow('').default(2),
preformatter: joi.function().maxArity(2),
postformatter: joi.function().maxArity(2),
handleUncaught: joi.boolean().default(false),
stream: joi.object().allow(null),
hapiPino: joi.object({
stream: joi.object().allow(null),
prettyPrint: joi.boolean(),
tags: joi.object(),
allTags: joi.string(),
instance: joi.object(),
logEvents: joi.alternatives().try(joi.array().items(joi.string()), joi.any().allow(false, null)),
mergeHapiLogData: joi.boolean().default(false),
serializers: joi.object(),
logRouteTags: joi.boolean(),
ignorePaths: joi.array().items(joi.string()),
logPayload: joi.boolean().default(true),
level: joi.string()
}).default(),
pino: joi.object({
safe: joi.boolean(),
name: joi.string(),
serializers: joi.object(),
timestamp: joi.alternatives().try(joi.function(), joi.boolean()),
slowtime: joi.boolean(),
extreme: joi.boolean(),
level: joi.string(),
levelVal: joi.number(),
customLevels: joi.object(),
redact: joi.alternatives().try(joi.array(), joi.object()),
prettyPrint: joi.any(),
messageKey: joi.string().default('msg'),
rule_id: Joi.string()
.guid()
.required(),
rule_type: Joi.string()
.valid(['count', 'time', 'speed', 'user'])
.required(),
rule_units: Joi.string().valid(['seconds', 'minutes', 'hours', 'mph', 'kph']),
geographies: Joi.array().items(Joi.string().guid()),
statuses: Joi.object().keys({
available: Joi.array(),
reserved: Joi.array(),
unavailable: Joi.array(),
removed: Joi.array(),
inactive: Joi.array(),
trip: Joi.array(),
elsewhere: Joi.array()
}),
vehicle_types: Joi.array().items(Joi.string().valid(Object.values(VEHICLE_TYPES))),
maximum: Joi.number(),
minimum: Joi.number(),
start_time: Joi.string(),
end_time: Joi.string(),
days: Joi.array().items(Joi.string().valid(DAYS_OF_WEEK)),
messages: Joi.object(),
value_url: Joi.string().uri()
})
const policiesSchema = Joi.array().items(
Joi.object().keys({
name: Joi.string().required(),
description: Joi.string().required(),
policy_id: Joi.string()
'use strict'
const Joi = require('@hapi/joi')
const { renderVersionBadge } = require('../version')
const { BaseJsonService, NotFound } = require('..')
const schema = Joi.object({
entries: Joi.array()
.items(
Joi.object({
source_package_version: Joi.string().required(),
})
)
.required(),
}).required()
module.exports = class Ubuntu extends BaseJsonService {
static get category() {
return 'version'
}
static get route() {
return {
base: 'ubuntu/v',