Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requestSchema = Joi.object({
context: Joi.object().description('Usually the hapi `request`'),
hostPrefix: Joi.string(),
path: Joi.string().default(requestDefaults.path),
method: Joi.string().required(),
operation: Joi.string().required().description('Ex: GET_supply_properties_v1'),
queryParams: Joi.object(),
pathParams: Joi.object(),
headers: Joi.object().default(requestDefaults.headers),
payload: Joi.any(),
redirects: Joi.alternatives().try(Joi.number(), Joi.valid(false)), // default value provided by global config
connectTimeout: Joi.number(), // default value provided by global config
maxConnectRetry: Joi.number(), // default value provided by global config
timeout: Joi.number(), // default value provided by global config
agent: Joi.object(), // default value provided by global config
read: Joi.bool().default(requestDefaults.read),
readOptions: Joi.object({
timeout: Joi.number().default(requestDefaults.readOptions.timeout),
json: Joi.valid(true, false, 'strict', 'force').default(requestDefaults.readOptions.json),
maxBytes: Joi.number(),
gunzip: Joi.valid(true, false, 'force').default(requestDefaults.readOptions.gunzip)
}).default(requestDefaults.readOptions),
plugins: Joi.object().default(requestDefaults.plugins)
}).unknown(true).default(requestDefaults)
// defaults listed in config.js
const globalSchema = Joi.object({
plugins: Joi.array().items(Joi.function()),
base: Joi.object(),
overrides: Joi.object().pattern(/.+/, Joi.object())
})
.min(60)
.max(1209600)
});
const sqs = Joi.alternatives().try(
arn,
sqsQueue.keys({
dlq: sqsQueue.keys({
maxReceiveCount: Joi.number().min(1)
})
})
);
const schema = Joi.object({
sns: sns.required(),
rawMessageDelivery: Joi.bool(),
filterPolicy: Joi.object(),
sqs: sqs.required(),
batchSize: Joi.number()
.min(1)
.max(10)
});
module.exports = schema;
.alphanum()
.length(34),
recipientId: Joi.string()
.alphanum()
.length(34),
timestamp: Joi.number()
.integer()
.min(0),
amount: Joi.number()
.integer()
.min(0),
fee: Joi.number()
.integer()
.min(0),
vendorFieldHex: Joi.string().hex(),
transform: Joi.bool().default(true),
},
},
};
export const transactionsSent: object = {
params: {
id: Joi.string(),
},
query: {
...pagination,
...{
orderBy: Joi.string(),
id: Joi.string()
.hex()
.length(64),
blockId,
.integer()
.min(0),
}),
vendorField: Joi.string()
.min(1)
.max(255),
expirationType: Joi.number().only(...Object.values(Enums.HtlcLockExpirationType)),
expirationValue: Joi.object().keys({
from: Joi.number()
.integer()
.min(0),
to: Joi.number()
.integer()
.min(0),
}),
isExpired: Joi.bool(),
},
};
export const unlocked: object = {
query: {
...pagination,
...{
orderBy: orderBy(transactionIteratees),
},
},
payload: {
ids: Joi.array()
.unique()
.min(1)
.max(25)
.items(
},
},
payload: {
address,
publicKey,
bridgechainRepository: Joi.string().max(80),
genesisHash: Joi.string()
.hex()
.length(64),
name: genericName,
seedNodes: Joi.array()
.unique()
.min(1)
.max(10)
.items(Joi.string().ip()),
isResigned: Joi.bool(),
},
};
if (model.routeOptions) {
resourceAliasForRoute = model.routeOptions.alias || model.modelName
} else {
resourceAliasForRoute = model.modelName
}
let handler = HandlerHelper.generateDeleteHandler(model, options, Log)
let payloadModel = null
if (config.enableSoftDelete) {
payloadModel = Joi.alternatives().try(
Joi.array().items(
Joi.object({
_id: Joi.objectId(),
hardDelete: Joi.bool().default(false)
})
),
Joi.array().items(Joi.objectId())
)
} else {
payloadModel = Joi.array().items(Joi.objectId())
}
if (!config.enablePayloadValidation) {
payloadModel = Joi.alternatives().try(payloadModel, Joi.any())
}
let auth = false
let deleteManyHeadersValidation = Object.assign(headersValidation, {})
if (config.authStrategy && model.routeOptions.deleteAuth !== false) {
...pagination,
...{
orderBy: orderBy(businessIteratees),
},
},
payload: {
address,
publicKey,
name: genericName,
website: Joi.string().max(80),
vat: Joi.string()
.alphanum()
.max(15),
repository: Joi.string().max(80),
isResigned: Joi.bool(),
transform: Joi.bool().default(true),
},
};
export const show: object = {
params: {
id: Joi.string()
.hex()
.length(64),
},
query: {
transform: Joi.bool().default(true),
},
};
export const unconfirmed: object = {
query: {
...pagination,
...{
transform: Joi.bool().default(true),
},
},
};
export const showUnconfirmed: object = {
params: {
id: Joi.string()
.hex()
.length(64),
},
};
export const search: object = {
query: {
...pagination,
...{
if (!fieldCopy.type) {
fieldCopy.type = {
schemaName: 'None'
}
}
switch (fieldCopy.type.schemaName) {
case 'ObjectId':
model = internals.joiObjectId()
break
case 'Mixed':
model = Joi.object()
break
case 'Boolean':
model = Joi.bool()
break
case 'Number':
model = Joi.number()
break
case 'Date':
model = Joi.date()
break
case 'String':
if (fieldCopy.enum) {
model = Joi.any().only(fieldCopy.enum)
} else if (fieldCopy.regex) {
if (!(fieldCopy.regex instanceof RegExp)) {
if (fieldCopy.regex.options) {
model = Joi.string().regex(
fieldCopy.regex.pattern,
fieldCopy.regex.options
const trace = require('./trace')
const attrSchema = Joi.object({
name: Joi.string().min(3),
category: isValidCategory,
route: isValidRoute,
transformPath: Joi.func()
.maxArity(1)
.required()
.error(
() =>
'"transformPath" must be a function that transforms named params to a new path'
),
transformQueryParams: Joi.func().arity(1),
dateAdded: Joi.date().required(),
overrideTransformedQueryParams: Joi.bool().optional(),
}).required()
module.exports = function redirector(attrs) {
const {
name,
category,
route,
transformPath,
transformQueryParams,
overrideTransformedQueryParams,
} = Joi.attempt(attrs, attrSchema, `Redirector for ${attrs.route.base}`)
return class Redirector extends BaseService {
static get name() {
if (name) {
return name