Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core-services/account/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ const { str } = envalid;

export default envalid.cleanEnv(process.env, {
HYDRA_OAUTH2_INTROSPECT_URL: str({ devDefault: "http://hydra:4445/oauth2/introspect" }),
NODE_ENV: str({ default: "production" }),
REACTION_IDENTITY_PUBLIC_PASSWORD_RESET_URL: str({ devDefault: "http://localhost:4100/reset-password/TOKEN" }),
REACTION_IDENTITY_PUBLIC_VERIFY_EMAIL_URL: str({ devDefault: "http://localhost:4100/#/verify-email/TOKEN" }),
REACTION_ADMIN_PUBLIC_ACCOUNT_REGISTRATION_URL: str({ devDefault: "http://localhost:4080" })
}, {
dotEnvPath: null
});
3 changes: 2 additions & 1 deletion src/core-services/account/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
defaultShopManagerRoles,
defaultVisitorRoles
} from "./util/defaultRoles.js";
import config from "./config.js";

/**
* @summary Called on startup
Expand All @@ -21,7 +22,7 @@ export default async function startup(context) {
await ensureRoles(context, defaultVisitorRoles);

// timing is important, packages are rqd for initial permissions configuration.
if (process.env.NODE_ENV !== "jesttest") {
if (config.NODE_ENV !== "test") {
await addPluginRolesToGroups(context);
}
}
2 changes: 2 additions & 0 deletions src/core-services/files/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ const { str } = envalid;

export default envalid.cleanEnv(process.env, {
NODE_ENV: str({ default: "production" })
}, {
dotEnvPath: null
});
2 changes: 1 addition & 1 deletion src/core-services/files/setUpFileCollections.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export default function setUpFileCollections({
// These workers use `.watch` API, which requires a replica set and proper read/write concern support.
// Currently our in-memory Mongo server used for Jest integrations tests does not meet these needs,
// so we skip this code if we're testing.
if (!["jesttest", "test"].includes(config.NODE_ENV)) {
if (config.NODE_ENV !== "test") {
/**
* @name remoteUrlWorker
* @type RemoteUrlWorker
Expand Down
8 changes: 1 addition & 7 deletions src/core/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ export default envalid.cleanEnv(process.env, {
}),
GRAPHQL_INTROSPECTION_ENABLED: bool({ default: false, devDefault: true }),
GRAPHQL_PLAYGROUND_ENABLED: bool({ default: false, devDefault: true }),
MIGRATION_BYPASS_ENABLED: bool({
default: false,
desc: "Bypasses migration version checks and migration runs. Enables startup if migration state is not compatible. " +
"This can be dangerous enough to cause data inconsistencies. Use at your own risk!"
}),
MONGO_URL: str({
devDefault: "mongodb://localhost:27017/reaction",
desc: "A valid MongoDB connection string URI, ending with the database name",
Expand Down Expand Up @@ -50,8 +45,7 @@ export default envalid.cleanEnv(process.env, {
desc: "The protocol, domain, and port portion of the URL, to which relative paths will be appended. " +
"This is used when full URLs are generated for things such as emails and notifications, so it must be publicly accessible.",
example: "https://shop.mydomain.com"
}),
SKIP_FIXTURES: bool({ default: false })
})
}, {
dotEnvPath: null
});
2 changes: 2 additions & 0 deletions src/plugins/email-smtp/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const config = envalid.cleanEnv(process.env, {
desc: "An SMTP mail url, i.e. smtp://user:[email protected]:465",
default: ""
})
}, {
dotEnvPath: null
});

export const SMTPConfig = { logger: config.EMAIL_DEBUG };
Expand Down
14 changes: 5 additions & 9 deletions src/plugins/job-queue/config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import envalid from "envalid";

const { bool, str } = envalid;
const { bool } = envalid;

export default envalid.cleanEnv(process.env, {
// This is necessary to override the envalid default
// validation for NODE_ENV, which uses
// str({ choices: ['development', 'test', 'production'] })
//
// We currently need to set NODE_ENV to "jesttest" when
// integration tests run.
NODE_ENV: str(),
REACTION_WORKERS_ENABLED: bool({ default: true })
REACTION_WORKERS_ENABLED: bool({ default: true }),
VERBOSE_JOBS: bool({ default: false })
}, {
dotEnvPath: null
});
3 changes: 2 additions & 1 deletion src/plugins/job-queue/startup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Logger from "@reactioncommerce/logger";
import config from "./config.js";
import { Jobs } from "./jobs.js";
import removeOldJobs from "./removeOldJobs.js";
import { jobCleanupRequests } from "./registration.js";
Expand All @@ -13,7 +14,7 @@ export default async function startup(context) {
const { appEvents, collections: { Jobs: MongoJobsCollection } } = context;
Jobs.setCollection(MongoJobsCollection);

if (process.env.VERBOSE_JOBS) {
if (config.VERBOSE_JOBS) {
Jobs.setLogStream(process.stdout);
}

Expand Down
2 changes: 2 additions & 0 deletions src/plugins/payments-stripe/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ export default envalid.cleanEnv(process.env, {
desc: "A private Stripe API key",
devDefault: testOnly("YOUR_PRIVATE_STRIPE_API_KEY")
})
}, {
dotEnvPath: null
});
5 changes: 1 addition & 4 deletions src/registerPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,5 @@ export default async function registerPlugins(app) {
* Miscellaneous
*/
await registerNotificationsPlugin(app); // OPTIONAL

if (process.env.NODE_ENV === "development") {
await registerTestAddressValidationPlugin(app);
}
await registerTestAddressValidationPlugin(app); // OPTIONAL
}
2 changes: 1 addition & 1 deletion tests/integration/api/queries/roles/roles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ test("a shop owner can view all user roles", async () => {
return;
}

expect(result.roles.nodes[0].name).toEqual("account/enroll");
expect(result.roles.nodes[0].name).toEqual(jasmine.any(String));
});