Skip to content

Commit d017299

Browse files
committed
Typescript Bootcamp
1 parent 7810a65 commit d017299

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

rest-api/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11

22
NODE_ENV=development
3-
PORT=9000
3+
#PORT=9003
44

rest-api/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
},
1212
"author": "",
1313
"license": "MIT",
14+
15+
16+
17+
1418
"devDependencies": {
1519
"@types/express": "^4.17.13",
1620
"npm-run-all": "^4.1.5",

rest-api/src/server.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,14 @@ function startServer() {
2525

2626
let port: number;
2727

28-
const portArg = process.argv[2];
28+
const portEnv = process.env.PORT,
29+
portArg = process.argv[2];
2930

30-
if (isInteger(portArg)) {
31+
if (isInteger(portEnv)) {
32+
port = parseInt(portEnv);
33+
}
34+
35+
if (!port && isInteger(portArg)) {
3136
port = parseInt(portArg);
3237
}
3338

0 commit comments

Comments
 (0)