Skip to content

Commit

Permalink
add morgan logs requests to the console
Browse files Browse the repository at this point in the history
  • Loading branch information
patchamama committed Sep 13, 2023
1 parent 9a2baea commit f1dd003
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ No errors have been found or reported.

# Pending

- Add use of mongoDB and sqlite databases locally for development mode.
- Add use of ~~mongoDB~~ and sqlite databases locally for development mode.
- Generate script (bash, sh) that automates the renaming of files and content to replace `prototype` with a new desired name in the model and controller, as well as the API URL (router).
- Generate a admin panel with a frontend (as react) that emulates the same functionalities as the [Django REST Framework](https://www.django-rest-framework.org/) and facilitates the management of models and API behaviour from a web interface.
- Generate a web interface in the frontend that facilitates the creation of models and controllers.
Expand Down Expand Up @@ -288,9 +288,6 @@ _In this project `npm` has been used as package manager, but you are free to use

```
npm install
```

```
npm start
```

Expand Down
7 changes: 7 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

const config = require('./utils/config')
const express = require('express')
const morgan = require('morgan')
const app = express()
const cors = require('cors')
const logger = require('./utils/logger')
Expand Down Expand Up @@ -35,6 +36,12 @@ const middleware = require('./utils/middleware')
// cors allows requests from other origins
app.use(cors())

// morgan logs requests to the console
morgan.token('body', (req) => JSON.stringify(req.body))
app.use(
morgan(':method :url :status :res[content-length] - :response-time ms :body')
)

// express.static serves the build folder
// (as static files, like images or react code)
// app.use(express.static('build'))
Expand Down
53 changes: 52 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"jsonwebtoken": "9.0.2",
"lodash": "4.17.21",
"mongoose": "7.5.0",
"mongoose-unique-validator": "4.0.0"
"mongoose-unique-validator": "4.0.0",
"morgan": "1.10.0"
},
"devDependencies": {
"cross-env": "7.0.3",
Expand Down

0 comments on commit f1dd003

Please sign in to comment.