Add validators
This commit is contained in:
parent
37e237a3a4
commit
890d573cac
|
@ -11,7 +11,7 @@ import {
|
||||||
|
|
||||||
const { PermissionLevel, PermissionType } = permissions
|
const { PermissionLevel, PermissionType } = permissions
|
||||||
|
|
||||||
export function rowActionValidator() {
|
function rowActionValidator() {
|
||||||
return middleware.joiValidator.body(
|
return middleware.joiValidator.body(
|
||||||
Joi.object({
|
Joi.object({
|
||||||
name: Joi.string().required(),
|
name: Joi.string().required(),
|
||||||
|
@ -20,6 +20,15 @@ export function rowActionValidator() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function rowTriggerValidator() {
|
||||||
|
return middleware.joiValidator.body(
|
||||||
|
Joi.object({
|
||||||
|
rowId: Joi.string().required(),
|
||||||
|
}),
|
||||||
|
{ allowUnknown: false }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const router: Router = new Router()
|
const router: Router = new Router()
|
||||||
|
|
||||||
// CRUD endpoints
|
// CRUD endpoints
|
||||||
|
@ -51,6 +60,7 @@ router
|
||||||
.post(
|
.post(
|
||||||
"/api/tables/:tableId/actions/:actionId/trigger",
|
"/api/tables/:tableId/actions/:actionId/trigger",
|
||||||
appInfoMiddleware({ appType: AppType.PROD }),
|
appInfoMiddleware({ appType: AppType.PROD }),
|
||||||
|
rowTriggerValidator(),
|
||||||
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
|
authorizedResource(PermissionType.TABLE, PermissionLevel.READ, "tableId"),
|
||||||
rowActionController.run
|
rowActionController.run
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue