mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-11-23 01:54:37 +03:00
Simplify the server config
This commit is contained in:
parent
f877543f65
commit
025d1852e6
@ -1,78 +1,47 @@
|
||||
{{={= =}=}}
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
{=# isAuthEnabled =}
|
||||
auth: {
|
||||
jwtSecret: string | undefined;
|
||||
jwtSecret: string;
|
||||
}
|
||||
{=/ isAuthEnabled =}
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.{= databaseUrlEnvVarName =},
|
||||
{=# isAuthEnabled =}
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
{=/ isAuthEnabled =}
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.{= databaseUrlEnvVarName =},
|
||||
allowedCORSOrigins: [],
|
||||
{=# isAuthEnabled =}
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
{=/ isAuthEnabled =}
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -214,7 +214,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/package.json"
|
||||
],
|
||||
"d18af37d0188a6c4c9eef72705e31caf179664cb8621eaacf8bc4c21bc57c212"
|
||||
"9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56"
|
||||
],
|
||||
[
|
||||
[
|
||||
@ -256,7 +256,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/server/config.ts"
|
||||
],
|
||||
"dd528b5db722210a5781f39c4d410024211f31964383bcc708a2611bd8d9d195"
|
||||
"8431eaf0332cdbdd2f36b4c232b4b6b65fd19bad58fe51922f5b2662f22fc8ad"
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -1 +1 @@
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"lodash.merge","version":"^4.6.2"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
@ -1,16 +1,13 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,36 +1,21 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAyBxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;KACvB;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAcxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;CAC9B,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -8,7 +8,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
"prisma": "5.19.1",
|
||||
|
@ -1,67 +1,36 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -1,16 +1,13 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,36 +1,21 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAyBxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;KACvB;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAcxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;CAC9B,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -8,7 +8,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
"prisma": "5.19.1",
|
||||
|
@ -1,67 +1,36 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -214,7 +214,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/package.json"
|
||||
],
|
||||
"d18af37d0188a6c4c9eef72705e31caf179664cb8621eaacf8bc4c21bc57c212"
|
||||
"9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56"
|
||||
],
|
||||
[
|
||||
[
|
||||
@ -256,7 +256,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/server/config.ts"
|
||||
],
|
||||
"dd528b5db722210a5781f39c4d410024211f31964383bcc708a2611bd8d9d195"
|
||||
"8431eaf0332cdbdd2f36b4c232b4b6b65fd19bad58fe51922f5b2662f22fc8ad"
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -1 +1 @@
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"lodash.merge","version":"^4.6.2"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
@ -1,16 +1,13 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,36 +1,21 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAyBxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;KACvB;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAcxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;CAC9B,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -8,7 +8,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
"prisma": "5.19.1",
|
||||
|
@ -1,67 +1,36 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -501,7 +501,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/package.json"
|
||||
],
|
||||
"27e50b464aa1785f4651f4229f509fd2d71ed19076e341c4f3fafb98b11955c0"
|
||||
"e9daaa0fd911e4211651d99935e3191bbc17f33d1c5f8e5e9960fef5a2b0497f"
|
||||
],
|
||||
[
|
||||
[
|
||||
@ -606,7 +606,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/server/config.ts"
|
||||
],
|
||||
"ee59e87efd7cf4904b33d15cde4ef65994f156a3f7fb634942a6414c3505bcf7"
|
||||
"4a78cfcf41a4fa41fa61ee19404fb6f32d5c25a1f854008ad81fcd8c2191e5ab"
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -1 +1 @@
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"lodash.merge","version":"^4.6.2"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"@stitches/react","version":"^1.2.8"},{"name":"@node-rs/argon2","version":"^1.8.3"},{"name":"arctic","version":"^1.2.1"},{"name":"lucia","version":"^3.0.1"},{"name":"oslo","version":"^1.1.2"},{"name":"@lucia-auth/adapter-prisma","version":"^4.0.0"},{"name":"@sendgrid/mail","version":"^7.7.0"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"pg-boss","version":"^8.4.2"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"@stitches/react","version":"^1.2.8"},{"name":"@node-rs/argon2","version":"^1.8.3"},{"name":"arctic","version":"^1.2.1"},{"name":"lucia","version":"^3.0.1"},{"name":"oslo","version":"^1.1.2"},{"name":"@lucia-auth/adapter-prisma","version":"^4.0.0"},{"name":"@sendgrid/mail","version":"^7.7.0"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"pg-boss","version":"^8.4.2"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
@ -1,19 +1,16 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
auth: {
|
||||
jwtSecret: string | undefined;
|
||||
};
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
auth: {
|
||||
jwtSecret: string;
|
||||
};
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,39 +1,24 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AA4BxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;QACtB,IAAI,EAAE;YACJ,SAAS,EAAE,GAAG,CAAC,UAAU;SAC1B;KACF;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAiBxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;IAC7B,IAAI,EAAE;QACJ,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B;CACF,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -13,7 +13,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"lucia": "^3.0.1",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
|
@ -1,73 +1,42 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
auth: {
|
||||
jwtSecret: string | undefined;
|
||||
}
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
auth: {
|
||||
jwtSecret: string;
|
||||
}
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
auth: {
|
||||
jwtSecret: env.JWT_SECRET
|
||||
}
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -221,7 +221,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/package.json"
|
||||
],
|
||||
"657fd7af5d76fbb099b945cae4f34fa4fab061d3606b1ad1d03e81ee0d59535f"
|
||||
"f045068da4d6b321ff13c7fe91eb01a10f98e7bf477edee21ab1621e95166bf7"
|
||||
],
|
||||
[
|
||||
[
|
||||
@ -263,7 +263,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/server/config.ts"
|
||||
],
|
||||
"dd528b5db722210a5781f39c4d410024211f31964383bcc708a2611bd8d9d195"
|
||||
"8431eaf0332cdbdd2f36b4c232b4b6b65fd19bad58fe51922f5b2662f22fc8ad"
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -1 +1 @@
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"lodash.merge","version":"^4.6.2"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"pg-boss","version":"^8.4.2"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"pg-boss","version":"^8.4.2"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
@ -1,16 +1,13 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,36 +1,21 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAyBxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;KACvB;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAcxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;CAC9B,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -8,7 +8,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
"pg-boss": "^8.4.2",
|
||||
|
@ -1,67 +1,36 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
@ -214,7 +214,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/package.json"
|
||||
],
|
||||
"d18af37d0188a6c4c9eef72705e31caf179664cb8621eaacf8bc4c21bc57c212"
|
||||
"9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56"
|
||||
],
|
||||
[
|
||||
[
|
||||
@ -256,7 +256,7 @@
|
||||
"file",
|
||||
"../out/sdk/wasp/server/config.ts"
|
||||
],
|
||||
"dd528b5db722210a5781f39c4d410024211f31964383bcc708a2611bd8d9d195"
|
||||
"8431eaf0332cdbdd2f36b4c232b4b6b65fd19bad58fe51922f5b2662f22fc8ad"
|
||||
],
|
||||
[
|
||||
[
|
||||
|
@ -1 +1 @@
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"lodash.merge","version":"^4.6.2"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
||||
{"_waspSdkNpmDeps":{"dependencies":[{"name":"@prisma/client","version":"5.19.1"},{"name":"prisma","version":"5.19.1"},{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"express","version":"~4.21.0"},{"name":"mitt","version":"3.0.0"},{"name":"react","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"},{"name":"react-hook-form","version":"^7.45.4"},{"name":"superjson","version":"^2.2.1"},{"name":"vitest","version":"^1.2.1"},{"name":"@vitest/ui","version":"^1.2.1"},{"name":"jsdom","version":"^21.1.1"},{"name":"@testing-library/react","version":"^14.1.2"},{"name":"@testing-library/jest-dom","version":"^6.3.0"},{"name":"msw","version":"^1.1.0"},{"name":"zod","version":"^3.23.8"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/express-serve-static-core","version":"^4.17.13"}]},"_userNpmDeps":{"userDependencies":[{"name":"react","version":"^18.2.0"},{"name":"wasp","version":"file:.wasp/out/sdk/wasp"}],"userDevDependencies":[{"name":"@types/react","version":"^18.0.37"},{"name":"prisma","version":"5.19.1"},{"name":"typescript","version":"^5.1.0"},{"name":"vite","version":"^4.3.9"}]},"_waspFrameworkNpmDeps":{"npmDepsForWebApp":{"dependencies":[{"name":"@tanstack/react-query","version":"^4.29.0"},{"name":"axios","version":"^1.4.0"},{"name":"react-dom","version":"^18.2.0"},{"name":"react-router-dom","version":"^6.26.2"}],"devDependencies":[{"name":"@tsconfig/vite-react","version":"^2.0.0"},{"name":"@types/react-dom","version":"^18.0.11"},{"name":"@vitejs/plugin-react","version":"^4.2.1"},{"name":"dotenv","version":"^16.0.3"}]},"npmDepsForServer":{"dependencies":[{"name":"cookie-parser","version":"~1.4.6"},{"name":"cors","version":"^2.8.5"},{"name":"dotenv","version":"^16.0.2"},{"name":"express","version":"~4.21.0"},{"name":"helmet","version":"^6.0.0"},{"name":"morgan","version":"~1.10.0"},{"name":"superjson","version":"^2.2.1"}],"devDependencies":[{"name":"@tsconfig/node18","version":"latest"},{"name":"@types/cors","version":"^2.8.5"},{"name":"@types/express","version":"^4.17.13"},{"name":"@types/express-serve-static-core","version":"^4.17.13"},{"name":"@types/node","version":"^18.0.0"},{"name":"nodemon","version":"^2.0.19"},{"name":"rollup","version":"^4.9.6"},{"name":"rollup-plugin-esbuild","version":"^6.1.1"}]}}}
|
@ -1,16 +1,13 @@
|
||||
type BaseConfig = {
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
import { env } from './env.js';
|
||||
type NodeEnv = typeof env.NODE_ENV;
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
};
|
||||
type EnvConfig = BaseConfig & {
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
};
|
||||
type Config = CommonConfig & EnvConfig;
|
||||
declare const resolvedConfig: Config;
|
||||
export default resolvedConfig;
|
||||
declare const config: Config;
|
||||
export default config;
|
||||
|
@ -1,36 +1,21 @@
|
||||
import merge from 'lodash.merge';
|
||||
import { env } from './env.js';
|
||||
import { stripTrailingSlash } from '../universal/url.js';
|
||||
const config = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
const allowedCORSOriginsPerEnv = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
};
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV];
|
||||
const config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
};
|
||||
const resolvedConfig = merge(config.all, config[env.NODE_ENV]);
|
||||
// PUBLIC API
|
||||
export default resolvedConfig;
|
||||
function getDevelopmentConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
};
|
||||
}
|
||||
function getProductionConfig() {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
};
|
||||
}
|
||||
export default config;
|
||||
//# sourceMappingURL=config.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAyBxD,MAAM,MAAM,GAIR;IACF,GAAG,EAAE;QACH,GAAG,EAAE,GAAG,CAAC,QAAQ;QACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;QAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,kBAAkB,EAAE,EAAE;KACvB;IACD,WAAW,EAAE,oBAAoB,EAAE;IACnC,UAAU,EAAE,mBAAmB,EAAE;CAClC,CAAA;AAED,MAAM,cAAc,GAAW,KAAK,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AACtE,aAAa;AACb,eAAe,cAAc,CAAA;AAE7B,SAAS,oBAAoB;IAC3B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,GAAG;KACxB,CAAA;AACH,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAChE,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,WAAW;QACX,SAAS;QACT,kBAAkB,EAAE,CAAC,WAAW,CAAC;KAClC,CAAA;AACH,CAAC"}
|
||||
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../server/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAcxD,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AAC/D,MAAM,SAAS,GAAG,kBAAkB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;AAEzD,MAAM,wBAAwB,GAAuC;IACnE,WAAW,EAAE,GAAG;IAChB,UAAU,EAAE,CAAC,WAAW,CAAC;CAC1B,CAAA;AACD,MAAM,kBAAkB,GAAG,wBAAwB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAEjE,MAAM,MAAM,GAAW;IACrB,WAAW;IACX,SAAS;IACT,kBAAkB;IAClB,GAAG,EAAE,GAAG,CAAC,QAAQ;IACjB,aAAa,EAAE,GAAG,CAAC,QAAQ,KAAK,aAAa;IAC7C,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,WAAW,EAAE,GAAG,CAAC,YAAY;CAC9B,CAAA;AAED,aAAa;AACb,eAAe,MAAM,CAAA"}
|
@ -8,7 +8,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
"prisma": "5.19.1",
|
||||
|
@ -1,67 +1,36 @@
|
||||
import merge from 'lodash.merge'
|
||||
|
||||
import { env } from './env.js'
|
||||
import { stripTrailingSlash } from '../universal/url.js'
|
||||
|
||||
// TODO:
|
||||
// - Use dotenv library to consume env vars from a file.
|
||||
// - Use convict library to define schema and validate env vars.
|
||||
// https://codingsans.com/blog/node-config-best-practices
|
||||
type NodeEnv = typeof env.NODE_ENV
|
||||
|
||||
type BaseConfig = {
|
||||
type Config = {
|
||||
env: NodeEnv;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string;
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
allowedCORSOrigins: string | string[];
|
||||
}
|
||||
|
||||
type CommonConfig = BaseConfig & {
|
||||
env: string;
|
||||
isDevelopment: boolean;
|
||||
port: number;
|
||||
databaseUrl: string | undefined;
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL)
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL)
|
||||
|
||||
const allowedCORSOriginsPerEnv: Record<NodeEnv, string | string[]> = {
|
||||
development: '*',
|
||||
production: [frontendUrl]
|
||||
}
|
||||
const allowedCORSOrigins = allowedCORSOriginsPerEnv[env.NODE_ENV]
|
||||
|
||||
const config: Config = {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins,
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
}
|
||||
|
||||
type EnvConfig = BaseConfig & {
|
||||
frontendUrl: string;
|
||||
serverUrl: string;
|
||||
}
|
||||
|
||||
type Config = CommonConfig & EnvConfig
|
||||
|
||||
const config: {
|
||||
all: CommonConfig,
|
||||
development: EnvConfig,
|
||||
production: EnvConfig,
|
||||
} = {
|
||||
all: {
|
||||
env: env.NODE_ENV,
|
||||
isDevelopment: env.NODE_ENV === 'development',
|
||||
port: env.PORT,
|
||||
databaseUrl: env.DATABASE_URL,
|
||||
allowedCORSOrigins: [],
|
||||
},
|
||||
development: getDevelopmentConfig(),
|
||||
production: getProductionConfig(),
|
||||
}
|
||||
|
||||
const resolvedConfig: Config = merge(config.all, config[env.NODE_ENV])
|
||||
// PUBLIC API
|
||||
export default resolvedConfig
|
||||
|
||||
function getDevelopmentConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: '*',
|
||||
}
|
||||
}
|
||||
|
||||
function getProductionConfig(): EnvConfig {
|
||||
const frontendUrl = stripTrailingSlash(env.WASP_WEB_CLIENT_URL);
|
||||
const serverUrl = stripTrailingSlash(env.WASP_SERVER_URL);
|
||||
return {
|
||||
frontendUrl,
|
||||
serverUrl,
|
||||
allowedCORSOrigins: [frontendUrl],
|
||||
}
|
||||
}
|
||||
export default config
|
||||
|
1
waspc/examples/todoApp/package-lock.json
generated
1
waspc/examples/todoApp/package-lock.json
generated
@ -38,7 +38,6 @@
|
||||
"axios": "^1.4.0",
|
||||
"express": "~4.21.0",
|
||||
"jsdom": "^21.1.1",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"lucia": "^3.0.1",
|
||||
"mitt": "3.0.0",
|
||||
"msw": "^1.1.0",
|
||||
|
@ -196,7 +196,6 @@ npmDepsForSdk spec =
|
||||
("express", Server.expressVersionStr),
|
||||
("mitt", "3.0.0"),
|
||||
("react", show reactVersion),
|
||||
("lodash.merge", "^4.6.2"),
|
||||
("react-router-dom", show reactRouterVersion),
|
||||
("react-hook-form", "^7.45.4"),
|
||||
("superjson", show superjsonVersion)
|
||||
|
Loading…
Reference in New Issue
Block a user