Skip to content

Commit 53e1a47

Browse files
committed
build(server): envs production
1 parent fab8cf8 commit 53e1a47

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

apps/server/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async function bootstrap() {
2727

2828
const port = +process.env.PORT || 3000;
2929
await app.listen(port);
30-
const url = `http://localhost:${port}/${urlPrefix}`;
30+
const url = `http://localhost:${port}/docs`;
3131
Logger.log(`🚀 Application is running on: ${url}`);
3232
}
3333

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "nx run-many -t serve --projects=server,devmx --configuration=development",
77
"dev:server": "nx serve server",
8+
"build:server": "export NODE_ENV=production && nx build server",
89
"dev:mx": "nx serve devmx",
910
"affected": "nx affected -t lint test build --parallel=10",
1011
"commit": "czg"

packages/shared/api-interfaces/src/server/envs/env.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
export abstract class Env {
2+
abstract production: boolean
3+
24
abstract db: {
35
name: string;
46
host: string;

packages/shared/data-source/src/lib/providers.ts

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ export function provideMongoURI() {
99
provide: 'MONGO_URI',
1010
useFactory(env: Env) {
1111
const { user, pass, host, port, name } = env.db;
12+
13+
if (env.production) {
14+
return `mongodb+srv://${user}:${pass}@${host}/?retryWrites=true&w=majority&appName=${name}`;
15+
}
16+
1217
return `mongodb://${user}:${pass}@${host}:${port}/${name}?authSource=admin`;
1318
},
1419
inject: [Env],

0 commit comments

Comments
 (0)