ActivityPub-federated video streaming platform using P2P directly in your web browser
Resolve enums at compile time
Chocobozzzfba87e27c1cb
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.tsindex 105c366002..b04970108e 100644--- a/server/helpers/custom-validators/users.ts+++ b/server/helpers/custom-validators/users.ts@@ -90,7 +90,7 @@ function isUserBlockedReasonValid (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)}// ---------------------------------------------------------------------------diff --git a/shared/models/http/http-error-codes.ts b/shared/models/http/http-error-codes.tsindex b2fbdfc5a0..5ebff1cb59 100644--- a/shared/models/http/http-error-codes.ts+++ b/shared/models/http/http-error-codes.ts@@ -4,7 +4,7 @@** 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.1diff --git a/shared/models/http/http-methods.ts b/shared/models/http/http-methods.tsindex 1cfa458b95..3f4adafe2b 100644--- a/shared/models/http/http-methods.ts+++ b/shared/models/http/http-methods.ts@@ -1,5 +1,5 @@/** 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. */CONNECT = 'CONNECT',/** The DELETE method deletes the specified resource. */diff --git a/shared/models/plugins/plugin.type.ts b/shared/models/plugins/plugin.type.tsindex b6766821af..016219cebc 100644--- a/shared/models/plugins/plugin.type.ts+++ b/shared/models/plugins/plugin.type.ts@@ -1,4 +1,4 @@-export enum PluginType {+export const enum PluginType {PLUGIN = 1,THEME = 2}diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.tsindex 94413abca3..687a2aa0d5 100644--- a/shared/models/users/user-role.ts+++ b/shared/models/users/user-role.ts@@ -1,5 +1,5 @@// Keep the order-export enum UserRole {+export const enum UserRole {ADMINISTRATOR = 0,MODERATOR = 1,USER = 2