Skip to content

Code base repository for my students use as reference for JavaScript exercices. Node.js & Express.

Notifications You must be signed in to change notification settings

evertonsavio/nodejs-express-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Server

install dependencies:

npm install express
npm install cors

Create a start script on package.json file:

  "scripts": {
    "start": "node src/app.js"
  },

01 Running a minimal express server

run the server

npm install
and
npm start
or
node src/server.js

02 First endpoint (Text/plain Hello World)

curl -X GET http://localhost:4001/

03 POST data to the server

curl -X POST http://localhost:4001/ -H 'Content-Type: application/json' -d "{\"temperature\": 42}"

04 GET data saved on server & DELETE endpoint

curl -X DELETE http://localhost:4001/

05 Changing object values with PUT and query & path parameters

curl -X PUT http://localhost:4001/<temperature>?id=<id>

06 Path paramenters Vs Query parameters

curl -X GET http://localhost:4001/<id>
curl -X DELETE http://localhost:4001/query?id=<id>

07 Separation of Concerns (SOC) Temperature routes

curl -X POST http://localhost:4001/temperature -H 'Content-Type: application/json' -d "{\"temperature\": <value>}"
curl -X GET http://localhost:4001/temperature
curl -X GET http://localhost:4001/temperature/<id>
curl -X PUT http://localhost:4001/temperature/<temperature>?id=<id>
curl -X DELETE http://localhost:4001/temperature
curl -X DELETE http://localhost:4001/temperature/query?id=<id>

08 Server Side Render

chrome: http://localhost:4001/

About

Code base repository for my students use as reference for JavaScript exercices. Node.js & Express.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published