Skip to content

Commit 48f8aac

Browse files
author
Steve Hobbs
authored
Dependency refactor (#130)
* Refactored dependencies and docker build in sample 02 * Refactored dependencies for 01-login * Added --init to Docker run (consistency)
1 parent d8f04a8 commit 48f8aac

8 files changed

Lines changed: 21 additions & 18 deletions

File tree

01-Login/exec.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
docker build --rm -t auth0-react-01-login .
2-
docker run -p 3000:3000 -it auth0-react-01-login
2+
docker run --init -p 3000:3000 -it auth0-react-01-login

01-Login/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
},
1111
"dependencies": {
1212
"express": "^4.16.4",
13-
"morgan": "^1.9.1"
14-
},
15-
"devDependencies": {
13+
"morgan": "^1.9.1",
1614
"@auth0/auth0-spa-js": "^1.0.2",
1715
"@fortawesome/fontawesome-svg-core": "^1.2.17",
1816
"@fortawesome/free-solid-svg-icons": "^5.8.1",
@@ -25,6 +23,7 @@
2523
"reactstrap": "^8.0.0",
2624
"samples-bootstrap-theme": "github:auth0-quickstarts/samples-bootstrap-theme"
2725
},
26+
"devDependencies": {},
2827
"eslintConfig": {
2928
"extends": "react-app"
3029
},

01-Login/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ const { join } = require("path");
44
const morgan = require("morgan");
55
const app = express();
66

7+
const port = process.env.SERVER_PORT || 3000;
8+
79
app.use(morgan("dev"));
810
app.use(express.static(join(__dirname, "build")));
911

1012
app.use((_, res) => {
1113
res.sendFile(join(__dirname, "build", "index.html"));
1214
});
1315

14-
app.listen(3000, () => console.log("Listening on port 3000"));
16+
app.listen(port, () => console.log(`Listening on port ${port}`));

02-Calling-an-API/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ COPY --from=build /app/src/auth_config.json ./src/auth_config.json
3434
COPY --from=build /app/server.js .
3535

3636
EXPOSE 3000
37-
37+
ENV SERVER_PORT=3000
3838
ENV NODE_ENV production
3939

4040
CMD ["node", "server.js"]

02-Calling-an-API/exec.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
docker build --rm -t auth0-react-03-calling-an-api .
2-
docker run -p 3000:3000 -it auth0-react-03-calling-an-api
1+
docker build --rm -t auth0-react-02-calling-an-api .
2+
docker run --init -p 3000:3000 -it auth0-react-02-calling-an-api

02-Calling-an-API/exec.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
2-
docker build -t auth0-react-03-calling-an-api .
3-
docker run --init -p 3000:3000 -it auth0-react-03-calling-an-api
2+
docker build -t auth0-react-02-calling-an-api .
3+
docker run --init -p 3000:3000 -it auth0-react-02-calling-an-api

02-Calling-an-API/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,26 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"start": "react-scripts start",
6+
"start": "npm-run-all --parallel spa server",
77
"build": "react-scripts build",
88
"test": "react-scripts test",
99
"eject": "react-scripts eject",
10-
"server": "nodemon server.js",
11-
"dev": "npm-run-all --parallel start server"
10+
"spa": "react-scripts start",
11+
"server": "node server.js",
12+
"server:dev": "nodemon server.js",
13+
"dev": "npm-run-all --parallel spa server:dev"
1214
},
1315
"dependencies": {
1416
"express": "^4.16.4",
1517
"express-jwt": "^5.3.1",
1618
"helmet": "^3.18.0",
1719
"jwks-rsa": "^1.4.0",
18-
"morgan": "^1.9.1"
19-
},
20-
"devDependencies": {
20+
"morgan": "^1.9.1",
2121
"@auth0/auth0-spa-js": "^1.0.2",
2222
"@fortawesome/fontawesome-svg-core": "^1.2.17",
2323
"@fortawesome/free-solid-svg-icons": "^5.8.1",
2424
"@fortawesome/react-fontawesome": "^0.1.4",
2525
"highlight.js": "^9.15.6",
26-
"nodemon": "^1.19.0",
2726
"npm-run-all": "^4.1.5",
2827
"react": "^16.8.6",
2928
"react-dom": "^16.8.6",
@@ -32,6 +31,9 @@
3231
"reactstrap": "^8.0.0",
3332
"samples-bootstrap-theme": "github:auth0-quickstarts/samples-bootstrap-theme"
3433
},
34+
"devDependencies": {
35+
"nodemon": "^1.19.0"
36+
},
3537
"eslintConfig": {
3638
"extends": "react-app"
3739
},

02-Calling-an-API/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const authConfig = require("./src/auth_config.json");
88

99
const app = express();
1010

11-
const port = process.env.NODE_ENV === "production" ? 3000 : 3001;
11+
const port = process.env.SERVER_PORT || 3001;
1212

1313
if (!authConfig.domain || !authConfig.audience) {
1414
throw new Error(

0 commit comments

Comments
 (0)