More use of isProduction/isDevelopment getters
This commit is contained in:
@@ -89,7 +89,7 @@ export default async function userInviter({
|
||||
teamUrl: team.url,
|
||||
}).schedule();
|
||||
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
Logger.info(
|
||||
"email",
|
||||
`Sign in immediately: ${
|
||||
|
||||
@@ -8,8 +8,7 @@ import Logger from "@server/logging/Logger";
|
||||
import { trace } from "@server/logging/tracing";
|
||||
import { baseStyles } from "./templates/components/EmailLayout";
|
||||
|
||||
const useTestEmailService =
|
||||
env.ENVIRONMENT === "development" && !env.SMTP_USERNAME;
|
||||
const useTestEmailService = env.isDevelopment && !env.SMTP_USERNAME;
|
||||
|
||||
type SendMailOptions = {
|
||||
to: string;
|
||||
@@ -192,7 +191,7 @@ export class Mailer {
|
||||
name: env.SMTP_NAME,
|
||||
host: env.SMTP_HOST,
|
||||
port: env.SMTP_PORT,
|
||||
secure: env.SMTP_SECURE ?? env.ENVIRONMENT === "production",
|
||||
secure: env.SMTP_SECURE ?? env.isProduction,
|
||||
auth: env.SMTP_USERNAME
|
||||
? {
|
||||
user: env.SMTP_USERNAME,
|
||||
|
||||
@@ -41,7 +41,7 @@ signin page at: ${teamUrl}
|
||||
}
|
||||
|
||||
protected render({ token, client, teamUrl }: Props) {
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
logger.debug("email", `Sign-In link: ${this.signinLink(token, client)}`);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ async function master() {
|
||||
await checkEnv();
|
||||
await checkPendingMigrations();
|
||||
|
||||
if (env.TELEMETRY && env.ENVIRONMENT === "production") {
|
||||
if (env.TELEMETRY && env.isProduction) {
|
||||
void checkUpdates();
|
||||
setInterval(checkUpdates, 24 * 3600 * 1000);
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ export default function createMiddleware(providerName: string) {
|
||||
);
|
||||
}
|
||||
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
|
||||
@@ -160,9 +160,7 @@ class Team extends ParanoidModel {
|
||||
* @return {boolean} Whether to show email login options
|
||||
*/
|
||||
get emailSigninEnabled(): boolean {
|
||||
return (
|
||||
this.guestSignin && (!!env.SMTP_HOST || env.ENVIRONMENT === "development")
|
||||
);
|
||||
return this.guestSignin && (!!env.SMTP_HOST || env.isDevelopment);
|
||||
}
|
||||
|
||||
get url() {
|
||||
|
||||
@@ -20,8 +20,6 @@ import {
|
||||
} from "@server/errors";
|
||||
import { requestErrorHandler } from "@server/logging/sentry";
|
||||
|
||||
const isDev = env.ENVIRONMENT === "development";
|
||||
const isProd = env.ENVIRONMENT === "production";
|
||||
let errorHtmlCache: Buffer | undefined;
|
||||
|
||||
export default function onerror(app: Koa) {
|
||||
@@ -159,11 +157,11 @@ function wrapInNativeError(err: any): Error {
|
||||
}
|
||||
|
||||
function readErrorFile(): Buffer {
|
||||
if (isDev) {
|
||||
if (env.isDevelopment) {
|
||||
return fs.readFileSync(path.join(__dirname, "error.dev.html"));
|
||||
}
|
||||
|
||||
if (isProd) {
|
||||
if (env.isProduction) {
|
||||
return (
|
||||
errorHtmlCache ??
|
||||
(errorHtmlCache = fs.readFileSync(
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function present(
|
||||
MAXIMUM_IMPORT_SIZE: env.MAXIMUM_IMPORT_SIZE,
|
||||
PDF_EXPORT_ENABLED: false,
|
||||
DEFAULT_LANGUAGE: env.DEFAULT_LANGUAGE,
|
||||
EMAIL_ENABLED: !!env.SMTP_HOST || env.ENVIRONMENT === "development",
|
||||
EMAIL_ENABLED: !!env.SMTP_HOST || env.isDevelopment,
|
||||
GOOGLE_ANALYTICS_ID: env.GOOGLE_ANALYTICS_ID,
|
||||
RELEASE:
|
||||
process.env.SOURCE_COMMIT || process.env.SOURCE_VERSION || undefined,
|
||||
|
||||
@@ -18,7 +18,7 @@ export default class DebounceProcessor extends BaseProcessor {
|
||||
{
|
||||
// speed up revision creation in development, we don't have all the
|
||||
// time in the world.
|
||||
delay: (env.ENVIRONMENT === "development" ? 0.5 : 5) * 60 * 1000,
|
||||
delay: (env.isProduction ? 5 : 0.5) * 60 * 1000,
|
||||
}
|
||||
);
|
||||
break;
|
||||
|
||||
@@ -50,7 +50,7 @@ export default class ExportJSONTask extends ExportTask {
|
||||
|
||||
zip.file(
|
||||
`metadata.json`,
|
||||
env.ENVIRONMENT === "development"
|
||||
env.isDevelopment
|
||||
? JSON.stringify(metadata, null, 2)
|
||||
: JSON.stringify(metadata)
|
||||
);
|
||||
@@ -142,7 +142,7 @@ export default class ExportJSONTask extends ExportTask {
|
||||
|
||||
zip.file(
|
||||
`${serializeFilename(collection.name)}.json`,
|
||||
env.ENVIRONMENT === "development"
|
||||
env.isDevelopment
|
||||
? JSON.stringify(output, null, 2)
|
||||
: JSON.stringify(output)
|
||||
);
|
||||
|
||||
@@ -102,7 +102,7 @@ export default class RevisionCreatedNotificationsTask extends BaseTask<RevisionE
|
||||
});
|
||||
|
||||
if (notification) {
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
Logger.info(
|
||||
"processor",
|
||||
`would have suppressed notification to ${user.id}, but not in development`
|
||||
|
||||
@@ -93,7 +93,7 @@ router.use("/", groups.routes());
|
||||
router.use("/", fileOperationsRoute.routes());
|
||||
router.use("/", urls.routes());
|
||||
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
router.use("/", developer.routes());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { safeEqual } from "@server/utils/crypto";
|
||||
import * as T from "./schema";
|
||||
|
||||
const router = new Router();
|
||||
const emailEnabled = !!(env.SMTP_HOST || env.ENVIRONMENT === "development");
|
||||
const emailEnabled = !!(env.SMTP_HOST || env.isDevelopment);
|
||||
|
||||
const handleTeamUpdate = async (ctx: APIContext<T.TeamsUpdateSchemaReq>) => {
|
||||
const { transaction } = ctx.state;
|
||||
|
||||
@@ -27,7 +27,7 @@ import pagination from "../middlewares/pagination";
|
||||
import * as T from "./schema";
|
||||
|
||||
const router = new Router();
|
||||
const emailEnabled = !!(env.SMTP_HOST || env.ENVIRONMENT === "development");
|
||||
const emailEnabled = !!(env.SMTP_HOST || env.isDevelopment);
|
||||
|
||||
router.post(
|
||||
"users.list",
|
||||
@@ -457,7 +457,7 @@ router.post(
|
||||
user.incrementFlag(UserFlag.InviteSent);
|
||||
await user.save({ transaction });
|
||||
|
||||
if (env.ENVIRONMENT === "development") {
|
||||
if (env.isDevelopment) {
|
||||
logger.info(
|
||||
"email",
|
||||
`Sign in immediately: ${
|
||||
|
||||
@@ -11,7 +11,7 @@ type RedisAdapterOptions = RedisOptions & {
|
||||
const defaultOptions: RedisOptions = {
|
||||
maxRetriesPerRequest: 20,
|
||||
enableReadyCheck: false,
|
||||
showFriendlyErrorStack: env.ENVIRONMENT === "development",
|
||||
showFriendlyErrorStack: env.isDevelopment,
|
||||
|
||||
retryStrategy(times: number) {
|
||||
Logger.warn(`Retrying redis connection: attempt ${times}`);
|
||||
@@ -40,8 +40,7 @@ export default class RedisAdapter extends Redis {
|
||||
* For debugging. The connection name is based on the services running in
|
||||
* this process. Note that this does not need to be unique.
|
||||
*/
|
||||
const connectionNamePrefix =
|
||||
env.ENVIRONMENT === "development" ? process.pid : "outline";
|
||||
const connectionNamePrefix = env.isDevelopment ? process.pid : "outline";
|
||||
const connectionName =
|
||||
`${connectionNamePrefix}:${env.SERVICES.replace(/,/g, "-")}` +
|
||||
(connectionNameSuffix ? `:${connectionNameSuffix}` : "");
|
||||
|
||||
@@ -61,14 +61,14 @@ export async function checkEnv() {
|
||||
}
|
||||
});
|
||||
|
||||
if (env.ENVIRONMENT === "production") {
|
||||
if (env.isProduction) {
|
||||
Logger.info(
|
||||
"lifecycle",
|
||||
chalk.green(`
|
||||
Is your team enjoying Outline? Consider supporting future development by sponsoring the project:\n\nhttps://github.com/sponsors/outline
|
||||
`)
|
||||
);
|
||||
} else if (env.ENVIRONMENT === "development") {
|
||||
} else if (env.isDevelopment) {
|
||||
Logger.warn(
|
||||
`Running Outline in ${chalk.bold(
|
||||
"development mode"
|
||||
|
||||
Reference in New Issue
Block a user