中间件
简单但重要的发送/响应
app.use(express.json())
app.post('/friends', (req, res) => {
if(!req.body.name){
return res.status(400).json({
error:'Missing friend name'
})
}
const newFriend = {
name: req.body.name,
id: friends.length
}
friends.push(newFriend)
res.json(newFriend)
})
app.get('/friends', (req, res) => {
res.json(friends)
})
MVC(Model View Controller)
添加 router
Restful Api
CRUD
CRUD 工程师其实很多业务都是以这些操作为主
Template engines
仓库
感谢点点 star ~