- Create a new GH repo with readme
- open in vscode
- run
npm init -y
- this creates a
package.json
file
- ACP
- add
.gitignore
and addnode_modules
inside file - create routes in index.js
nodemon index.js
to run server
heroku create app-name
- 2 URLs returned - ...herokuapp.com & ...app-name.git
git remote -v
--> shows heroku remote url- add script to
package.json
for starting app
"start": "node index.js"
- Nodemon for constantly listening for changes:
"start:watch": "nodemon index.js"
- push to heroku (from main):
git push heroku main
- push to heroku (from dev):
git push heroku dev:main
- once deploy has successfully completed --> you can go to
...herokuapp.com
and view the deployed site!
- add a data.js file
- create data and save to a variable --> then
module.exports = dataVariable
- go to index.js and import data
const data = require('./data.js');
- can
res.send(data)
in an api endpoint - NOTE: undefined route error:
Cannot GET /blah
- create a
__test__
file with aname.test.js
file - rename index.js to server.js
- add app.js
- server.js is responsible for listening
- app.js responsible for the logic
npm i supertest
-- for making requests in testing to your apps endpointsnpm i jest
-- for testing- add test script
"test": "jest"
- create
it
block with test npm run test
-- which runsjest