本文整理匯總了TypeScript中joi.bool函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bool函數的具體用法?TypeScript bool怎麽用?TypeScript bool使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了bool函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: initStatusApi
export function initStatusApi(server: Server) {
server.route({
method: 'GET',
path: `${ROOT}/server`,
options: {
validate: {
query: Joi.object().keys({
_debug: Joi.bool()
})
}
},
handler: req => {
const setup = setupRequest(req);
return getServerStatus({ setup }).catch(defaultErrorHandler);
}
});
server.route({
method: 'GET',
path: `${ROOT}/agent`,
options: {
validate: {
query: Joi.object().keys({
_debug: Joi.bool()
})
}
},
handler: req => {
const setup = setupRequest(req);
return getAgentStatus({ setup }).catch(defaultErrorHandler);
}
});
}
示例2: reply
export const createBeatUpdateRoute = (libs: CMServerLibs) => ({
method: 'PUT',
path: '/api/beats/agent/{beatId}',
licenseRequired: true,
config: {
auth: {
mode: 'optional',
},
validate: {
headers: Joi.object({
'kbn-beats-access-token': Joi.string(),
}).options({
allowUnknown: true,
}),
params: Joi.object({
beatId: Joi.string(),
}),
payload: Joi.object({
active: Joi.bool(),
ephemeral_id: Joi.string(),
host_name: Joi.string(),
local_configuration_yml: Joi.string(),
metadata: Joi.object(),
name: Joi.string(),
type: Joi.string(),
version: Joi.string(),
}),
},
},
handler: async (request: FrameworkRequest, reply: any) => {
const { beatId } = request.params;
const accessToken = request.headers['kbn-beats-access-token'];
const remoteAddress = request.info.remoteAddress;
const userOrToken = accessToken || request.user;
if (request.user.kind === 'unauthenticated' && request.payload.active !== undefined) {
return reply({ message: 'access-token is not a valid auth type to change beat status' }).code(
401
);
}
try {
const status = await libs.beats.update(userOrToken, beatId, {
...request.payload,
host_ip: remoteAddress,
});
switch (status) {
case 'beat-not-found':
return reply({ message: 'Beat not found', success: false }).code(404);
case 'invalid-access-token':
return reply({ message: 'Invalid access token', success: false }).code(401);
}
reply({ success: true }).code(204);
} catch (err) {
return reply(wrapEsError(err));
}
},
});
示例3:
export const withDefaultValidators = (validators = {}) => {
return Joi.object().keys({
_debug: Joi.bool(),
start: dateValidation,
end: dateValidation,
uiFiltersES: Joi.string(),
...validators
});
};
示例4: initGetPrivilegesApi
export function initGetPrivilegesApi(
server: Record<string, any>,
routePreCheckLicenseFn: () => void
) {
server.route({
method: 'GET',
path: '/api/security/privileges',
handler(req: Record<string, any>) {
const { authorization } = server.plugins.security;
const privileges: RawKibanaPrivileges = authorization.privileges.get();
if (req.query.includeActions) {
return privileges;
}
return {
global: Object.keys(privileges.global),
space: Object.keys(privileges.space),
features: Object.entries(privileges.features).reduce(
(acc, [featureId, featurePrivileges]) => {
return {
...acc,
[featureId]: Object.keys(featurePrivileges),
};
},
{}
),
reserved: Object.keys(privileges.reserved),
};
},
config: {
pre: [routePreCheckLicenseFn],
validate: {
query: Joi.object().keys({
includeActions: Joi.bool(),
}),
},
},
});
}
示例5: buildValidationSchema
function buildValidationSchema(application: string, actions: string[], resources: string[]) {
const actionValidationSchema = buildActionsValidationSchema(actions);
const resourceValidationSchema = Joi.object({
...resources.reduce((acc, resource) => {
return {
...acc,
[resource]: actionValidationSchema,
};
}, {}),
}).required();
return Joi.object({
username: Joi.string().required(),
has_all_requested: Joi.bool(),
cluster: Joi.object(),
application: Joi.object({
[application]: resourceValidationSchema,
}).required(),
index: Joi.object(),
}).required();
}
示例6: registerRoutes
export const Validation = {
UpdateAppConfig: joi.object().keys({
label: joi.object().keys({
text: joi.string().label("Label"),
placement: joi.string().only("top", "right", "bottom", "left").label("Label placement"),
textAlignment: joi.string().only("left", "right").label("Label text alignment"),
classes: joi.string().optional().label("Label CSS classes"),
}),
input: joi.object().keys({
classes: joi.string().optional().label("Text field CSS classes"),
placeholder: joi.string().optional().label("Text field placeholder"),
}),
format: joi.string().only("mm/dd/yyyy", "dd/mm/yyyy").label("Format"),
maxDays: joi.number().label("Maximum allowed days"),
placement: joi.string().only("left", "right", "center"),
allowChangeFromCheckout: joi.bool(),
addPickerToCheckout: joi.bool(),
error: joi.any().strip(),
isSaving: joi.any().strip(),
})
}
export function registerRoutes(server: Server)
{
server.route({
method: "OPTIONS",
path: Routes.AppConfig,
config: {
auth: false,
plugins: {
crumb: false,
示例7:
...actions.reduce<Record<string, any>>((acc, action) => {
return {
...acc,
[action]: Joi.bool().required(),
};
}, {}),
示例8: async
export const createBeatUpdateRoute = (libs: CMServerLibs) => ({
method: 'PUT',
path: '/api/beats/agent/{beatId}',
licenseRequired: REQUIRED_LICENSES,
requiredRoles: ['beats_admin'],
config: {
validate: {
headers: Joi.object({
'kbn-beats-access-token': Joi.string(),
}).options({
allowUnknown: true,
}),
params: Joi.object({
beatId: Joi.string(),
}),
payload: Joi.object({
active: Joi.bool(),
ephemeral_id: Joi.string(),
host_name: Joi.string(),
local_configuration_yml: Joi.string(),
metadata: Joi.object(),
name: Joi.string(),
type: Joi.string(),
version: Joi.string(),
}),
},
},
handler: async (
request: FrameworkRequest
): Promise<BaseReturnType | ReturnTypeUpdate<CMBeat>> => {
const { beatId } = request.params;
const accessToken = request.headers['kbn-beats-access-token'];
const remoteAddress = request.info.remoteAddress;
const userOrToken = accessToken || request.user;
if (request.user.kind === 'unauthenticated' && request.payload.active !== undefined) {
return {
error: {
message: 'access-token is not a valid auth type to change beat status',
code: 401,
},
success: false,
};
}
const status = await libs.beats.update(userOrToken, beatId, {
...request.payload,
host_ip: remoteAddress,
});
switch (status) {
case 'beat-not-found':
return {
error: {
message: 'Beat not found',
code: 404,
},
success: false,
};
case 'invalid-access-token':
return {
error: {
message: 'Invalid access token',
code: 401,
},
success: false,
};
}
const beat = await libs.beats.getById(internalUser, beatId);
return {
item: beat,
action: 'updated',
success: true,
};
},
});
示例9:
.max(50)
.allow('')
.optional(),
// tslint:disable-next-line:no-null-keyword
category: Joi.string().allow(null),
description: Joi.string()
.max(250)
.allow(''),
pipeline_status: {
current_stage: {
promoted_by: Joi.string(),
promoted_on: Joi.date(),
id: Joi.string()
}
},
locked: Joi.bool()
})
export const BotEditSchema = Joi.object().keys({
name: Joi.string()
.allow('')
.max(50),
// tslint:disable-next-line:no-null-keyword
category: Joi.string().allow(null),
description: Joi.string()
.max(250)
.allow(''),
disabled: Joi.bool(),
private: Joi.bool(),
defaultLanguage: Joi.string()
.min(2)
示例10:
// https://webpack.js.org/configuration/entry-context/#entry
'entry': Joi.alternatives(
Joi.string(),
Joi.array().items(Joi.alternatives(
Joi.string(),
Joi.object().pattern(
Joi.string(),
Joi.alternatives(
Joi.string(),
Joi.array().items(Joi.string())
)
)
)),
Joi.func()
),
'enableSourceMap': Joi.bool(),
'enableExtract': Joi.bool(),
'cssLoaderOption': Joi.object(), // 第三方配置
'styleLoaderOption': Joi.object(), // 第三方配置
'sassLoaderOption': Joi.object(), // 第三方配置
'lessLoaderOption': Joi.object(), // 第三方配置
'stylusLoaderOption': Joi.object(), // 第三方配置
'mediaUrlLoaderOption': Joi.object(), // 第三方配置
'fontUrlLoaderOption': Joi.object(), // 第三方配置
'imageUrlLoaderOption': Joi.object(), // 第三方配置
'miniCssExtractPluginOption': Joi.object(), // 第三方配置
'module': Joi.object().keys({
'postcss': Joi.object().pattern(
Joi.string(),
Joi.object().keys({