An open API service indexing awesome lists of open source software.

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.

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/
```