Separate environment configs (#6597)
* Separate environment configs * wip * wip * test * plugins * test * test * .sequelizerc, unfortunately can't go through /utils/environment due to not supporting TS * docker-compose -> docker compose * fix: .local wipes .development * Add custom validation message for invalid SECRET_KEY (often confused)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "Iframely",
|
||||
"description": "Integrate Iframely to enable unfurling of arbitrary urls",
|
||||
"requiredEnvVars": ["IFRAMELY_URL", "IFRAMELY_API_KEY"]
|
||||
"requiredEnvVars": ["IFRAMELY_API_KEY"]
|
||||
}
|
||||
|
||||
27
plugins/iframely/server/env.ts
Normal file
27
plugins/iframely/server/env.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { IsOptional, IsUrl } from "class-validator";
|
||||
import { Environment } from "@server/env";
|
||||
import environment from "@server/utils/environment";
|
||||
import { CannotUseWithout } from "@server/utils/validators";
|
||||
|
||||
class IframelyPluginEnvironment extends Environment {
|
||||
/**
|
||||
* Iframely url
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsUrl({
|
||||
require_tld: false,
|
||||
require_protocol: true,
|
||||
allow_underscores: true,
|
||||
protocols: ["http", "https"],
|
||||
})
|
||||
public IFRAMELY_URL = environment.IFRAMELY_URL ?? "https://iframe.ly";
|
||||
|
||||
/**
|
||||
* Iframely API key
|
||||
*/
|
||||
@IsOptional()
|
||||
@CannotUseWithout("IFRAMELY_URL")
|
||||
public IFRAMELY_API_KEY = this.toOptionalString(environment.IFRAMELY_API_KEY);
|
||||
}
|
||||
|
||||
export default new IframelyPluginEnvironment();
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Day } from "@shared/utils/time";
|
||||
import env from "@server/env";
|
||||
import { InternalError } from "@server/errors";
|
||||
import Logger from "@server/logging/Logger";
|
||||
import Redis from "@server/storage/redis";
|
||||
import fetch from "@server/utils/fetch";
|
||||
import env from "./env";
|
||||
|
||||
class Iframely {
|
||||
private static apiUrl = `${env.IFRAMELY_URL}/api`;
|
||||
|
||||
Reference in New Issue
Block a user