-
-
Save harrisonmalone/3a104333a5f02dc8877928ef8a080210 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NODE_ENV=production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const express = require('express') | |
| require('dotenv').config() | |
| const app = express() | |
| const someMiddleWare = (req, res, next) => { | |
| try { | |
| next() | |
| } catch(err) { | |
| next(err) | |
| } | |
| } | |
| app.get('/', someMiddleWare, (req, res, next) => { | |
| try { | |
| throw Error('badddd!') | |
| } catch(err) { | |
| next(err) | |
| } | |
| }) | |
| app.use((err, req, res, next) => { | |
| res.status(500).send('throw an error') | |
| }) | |
| app.listen(5000, () => console.log('listening on port 5000 ')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "next-err", | |
| "version": "1.0.0", | |
| "description": "", | |
| "main": "index.js", | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1" | |
| }, | |
| "keywords": [], | |
| "author": "", | |
| "license": "ISC", | |
| "dependencies": { | |
| "dotenv": "^8.2.0", | |
| "express": "^4.17.1" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment