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