Resolve enums at compile time
This commit is contained in:
parent
81d02aac56
commit
fba87e27c1
|
@ -90,7 +90,7 @@ function isUserBlockedReasonValid (value: any) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function isUserRoleValid (value: any) {
|
function isUserRoleValid (value: any) {
|
||||||
return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined
|
return exists(value) && validator.isInt('' + value) && [ UserRole.ADMINISTRATOR, UserRole.MODERATOR, UserRole.USER ].includes(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* WebDAV and other codes useless with regards to PeerTube are not listed.
|
* WebDAV and other codes useless with regards to PeerTube are not listed.
|
||||||
*/
|
*/
|
||||||
export enum HttpStatusCode {
|
export const enum HttpStatusCode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1
|
* Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/** HTTP request method to indicate the desired action to be performed for a given resource. */
|
/** HTTP request method to indicate the desired action to be performed for a given resource. */
|
||||||
export enum HttpMethod {
|
export const enum HttpMethod {
|
||||||
/** The CONNECT method establishes a tunnel to the server identified by the target resource. */
|
/** The CONNECT method establishes a tunnel to the server identified by the target resource. */
|
||||||
CONNECT = 'CONNECT',
|
CONNECT = 'CONNECT',
|
||||||
/** The DELETE method deletes the specified resource. */
|
/** The DELETE method deletes the specified resource. */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
export enum PluginType {
|
export const enum PluginType {
|
||||||
PLUGIN = 1,
|
PLUGIN = 1,
|
||||||
THEME = 2
|
THEME = 2
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Keep the order
|
// Keep the order
|
||||||
export enum UserRole {
|
export const enum UserRole {
|
||||||
ADMINISTRATOR = 0,
|
ADMINISTRATOR = 0,
|
||||||
MODERATOR = 1,
|
MODERATOR = 1,
|
||||||
USER = 2
|
USER = 2
|
||||||
|
|
Loading…
Reference in New Issue