Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup express server #2

Merged
merged 10 commits into from
Nov 3, 2021
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
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_DEBUG_HIDE_DATE=true
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ typings/
.yarn-integrity

# dotenv environment variables file
.env
.env.test
#.env
#.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"@testing-library/user-event": "^12.8.3",
"axios": "^0.23.0",
"body-parser": "^1.19.0",
"chalk": "^4.1.2",
"concurrently": "^6.3.0",
"cypress": "^8.7.0",
"debug": "^4.3.2",
"express": "^4.17.1",
"mongoose": "^6.0.10",
"nodemon": "^2.0.14",
Expand All @@ -21,7 +23,7 @@
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"start": "concurrently \"DEBUG=http:server nodemon ./src/server/server.js -q\" \"react-scripts start\"",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
Expand All @@ -43,5 +45,11 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"nodemon": "^2.0.14"
},
"nodemonConfig": {
"verbose": false
}
}
21 changes: 16 additions & 5 deletions src/server/server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
const express = require("express");
const app = express();
const port = 3000;
const port = 4000;

app.get("/", (req, res) => res.send("Good monring sunshine!"));
const chalk = require('chalk')
const debug = require('debug');
const log = debug('http:server');
const http = require('http');
const name = '[server.js]';
const serverLog = chalk.redBright.bold

app.get("/", (req, res) => {
res.send("Boom, you've hit the express server")
log(serverLog(`${name} returned a response @ '/'`))
});

app.listen(port, () => {
log(serverLog(`starting ${name} on port ${port}.`));
})

app.listen(port, () => console.log(
`Example app listening on port ${port}!`
));