摘要:
添加字段验证 //引入 joi 模块 const Joi = require('joi'); module.exports = async(req, res) => { // 定义规则对象 const schema = { username: Joi.string().min(2).max(12). 阅读全文
摘要:
阅读全文
摘要:
阅读全文
摘要:
// 引入body-parser 模块 用来处理 post 请求参数 const bodyParser = require('body-parser'); // 处理post 请求参数 app.use(bodyParser.urlencoded({extended:false})) npm inst 阅读全文
摘要:
// 引入mongoose 第三方模块 const mongoose = require('mongoose'); // 连接数据库 mongoose.connect('mongodb://localhost/blog', { useNewUrlParser: true, useUnifiedTop 阅读全文
摘要:
2 生成json文件npm init -y 3 安装项目所需模块npm install express mongoose art-template express-art-template // 引入 express 框架 const express = require('express'); // 阅读全文