📅  最后修改于: 2023-12-03 15:14:57.726000             🧑  作者: Mango
ExpressJS是一个基于Node.js的Web应用框架,它提供了许多有用的函数和工具来帮助我们创建Web应用程序。在开发过程中,我们需要不断寻找资源来提高效率和减少工作量,本文介绍了一些实用的ExpressJS资源。
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
const express = require('express');
const cookieParser = require('cookie-parser');
const app = express();
app.use(cookieParser());
const express = require('express');
const morgan = require('morgan');
const app = express();
app.use(morgan('dev'));
const express = require('express');
const nunjucks = require('nunjucks');
const app = express();
nunjucks.configure('views', {
autoescape: true,
express: app
});
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
dialect: 'mysql'
});
sequelize.authenticate()
.then(() => console.log('数据库连接成功'))
.catch(() => console.log('数据库连接失败'));
const express = require('express');
const passport = require('passport');
const app = express();
app.use(passport.initialize());
app.use(passport.session());
# 安装
$ npm install --global nodemon
# 启动
$ nodemon app.js
# 安装
$ npm install --global pm2
# 启动
$ pm2 start app.js --name my-app
以上是一些实用的ExpressJS资源,希望对开发者们有所帮助。