https://github.com/easonlai/node-express-js-rest-api-demo
Node Express JS Rest API with Winston Logging Configuration Demo Repo.
https://github.com/easonlai/node-express-js-rest-api-demo
containerization express express-js expressjs logging node node-js nodejs winston winston-logger winston-transport winstonjs
Last synced: 3 months ago
JSON representation
Node Express JS Rest API with Winston Logging Configuration Demo Repo.
- Host: GitHub
- URL: https://github.com/easonlai/node-express-js-rest-api-demo
- Owner: easonlai
- Created: 2021-06-17T16:06:27.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-06-18T04:24:35.000Z (almost 4 years ago)
- Last Synced: 2025-01-08T12:13:52.895Z (5 months ago)
- Topics: containerization, express, express-js, expressjs, logging, node, node-js, nodejs, winston, winston-logger, winston-transport, winstonjs
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Node Express JS Rest API with Winston Logging Configuration Demo Repo
This is demo repo to demostrate how to work with [Winston](https://www.npmjs.com/package/winston) logging in Node Express JS Rest API. Logging will output to STROUT (console) and log path (/logs/log.log). This repo also contain containerization materials for futher deployment in Kubernetes (K8S) cluster (e.g Azure Kubernetes Service (AKS)).Readme update 1.0
## With Winston Logging
* Logging format = Type, Label, Datetime, Status Code, Status Message, Request Path, Request Method, Client IP, Host IP
```shell
Please refer to index.js line 6 - 27 for core Winston configuration.
Line 33 for normal response capture.
Line 38 - 47 for error capture.
```## Run locally
```shell
node index.js
```## Test Rest API locally
```shell
http://localhost:8081
```## Containerize
1. Build a docker image using `Dockerfile`:
```
docker build -t node-express-js-rest-api-demo .
```
2. Run docker image locally
```
docker run --rm -p 8081:8081 node-express-js-rest-api-demo
```
3. Then you can access the Rest API at http://localhost:8081/listSAs from Postman.## Deploy to K8S
```shell
kubectl apply -f node-express-js-rest-api-demo.yaml
```