mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-29 00:46:26 -08:00
api-v1: start work on sanitize middleware func
This commit is contained in:
parent
6e6afd274b
commit
503f5f315f
|
@ -74,7 +74,7 @@ export const noAPIAccess: RequestHandler = function(req, res, next) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Blocks requests based on whether or not the token being used to access the route is of type `User` unless a condition is met.
|
* @description Blocks requests based on whether or not the token being used to access the route is of type `User` unless a condition is met.
|
||||||
* @param tokenPermissions Permissions which your route requires.
|
* @param condition Permissions which your route requires.
|
||||||
* @returns Express middleware
|
* @returns Express middleware
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -85,3 +85,32 @@ export const noAPIAccessIf = function(condition: (acc:Account, token:string) =>
|
||||||
else next()
|
else next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SchemeType = "array" | "object" | "string" | "number" | "boolean"
|
||||||
|
|
||||||
|
interface SchemeObject {
|
||||||
|
type: "object"
|
||||||
|
children: {
|
||||||
|
[key: string]: SchemeParameter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SchemeArray {
|
||||||
|
type: "array",
|
||||||
|
children: SchemeParameter /* All children of the array must be this type */
|
||||||
|
| SchemeParameter[] /* Array must match this pattern */
|
||||||
|
}
|
||||||
|
|
||||||
|
type SchemeParameter = SchemeType | SchemeObject | SchemeArray
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Blocks requests based on whether or not the token being used to access the route is of type `User` unless a condition is met.
|
||||||
|
* @param tokenPermissions Permissions which your route requires.
|
||||||
|
* @returns Express middleware
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const sanitize = function(scheme: SchemeObject):RequestHandler {
|
||||||
|
return function(req, res, next) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue