https://github.com/evertonsavio/nodejs-express-framework
Code base repository for my students use as reference for JavaScript exercices. Node.js & Express.
https://github.com/evertonsavio/nodejs-express-framework
Last synced: about 1 year ago
JSON representation
Code base repository for my students use as reference for JavaScript exercices. Node.js & Express.
- Host: GitHub
- URL: https://github.com/evertonsavio/nodejs-express-framework
- Owner: evertonsavio
- Created: 2022-03-27T12:41:46.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-23T19:11:51.000Z (about 4 years ago)
- Last Synced: 2025-04-24T06:15:51.128Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 40 KB
- Stars: 3
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## 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/?id=
```
### 06 Path paramenters Vs Query parameters
```
curl -X GET http://localhost:4001/
curl -X DELETE http://localhost:4001/query?id=
```
### 07 Separation of Concerns (SOC) Temperature routes
```
curl -X POST http://localhost:4001/temperature -H 'Content-Type: application/json' -d "{\"temperature\": }"
curl -X GET http://localhost:4001/temperature
curl -X GET http://localhost:4001/temperature/
curl -X PUT http://localhost:4001/temperature/?id=
curl -X DELETE http://localhost:4001/temperature
curl -X DELETE http://localhost:4001/temperature/query?id=
```
### 08 Server Side Render
```
chrome: http://localhost:4001/
```