-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
142vip.cn
committed
Nov 17, 2023
1 parent
0716934
commit d3a774b
Showing
9 changed files
with
919 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const express = require('express') | ||
const app = express() | ||
const port = 4000 | ||
const appName = require('./package.json').name | ||
app.get('/', async(req, res) => { | ||
console.log('请求进来了...') | ||
throw new Error('手动抛错了!!') | ||
}) | ||
|
||
app.listen(port, () => { | ||
console.log(`${appName} listening on port ${port}`) | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const express = require('express') | ||
const app = express() | ||
const bodyParser = require('body-parser') | ||
const methodOverride = require('method-override') | ||
const port = 4000 | ||
app.use(bodyParser.urlencoded({ | ||
extended: true | ||
})) | ||
app.use(bodyParser.json()) | ||
app.use(methodOverride()) | ||
|
||
|
||
/** | ||
* 定义一些路由逻辑 | ||
*/ | ||
|
||
app.get('/get', async(req, res) => { | ||
console.log('处理业务逻辑') | ||
}) | ||
|
||
/** | ||
* 最后自定义错误处理 | ||
* | ||
*/ | ||
app.use((err, req, res, next) => { | ||
console.log('捕获到的错误信息') | ||
console.log(err) | ||
}) | ||
|
||
app.listen(port, () => { | ||
console.log('app listen on:', port) | ||
}) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.