2020年最推荐的14个最有用NodeJS库
2021-01-07 04:29
标签:yam mys use 部分 ejs bst ast als inf 快速,简单,极简的节点Web框架 1100万 const cheerio = require(\’cheerio\’); const $ = cheerio.load(\’ \’); 420万 98万 · 实施实时分析,二进制流,实例消息传递和文档协作 · 知名用户包括Microsoft Office,Yammer和Zendesk 3M · 在API后端构建尚未完成的情况下构建前端UI并与数据进行交互 · 多种API方法,包括地址,公司,数据库,图像,名称(firstName,lastName) 140万 例如GET / 200 51.267 ms — 1539 · 将请求记录在控制台,文件,数据库中 · 调试和日志历史记录 2M · 易于发送错误响应 · 许多错误属性可用 expose 27M 在处理程序之前在中间件中解析传入的请求主体,该处理程序在req.body属性下可用 · 解释请求正文 · 许多选项,例如inflate,type,verify 1300万 它具有可靠的事务支持,关系,急切和延迟加载,读取复制等功能 · Node.js ORM 720K Passport的唯一目的是对请求进行身份验证,它通过一组称为策略的可扩展插件来完成 · Node.js身份验证 · 与OAuth和OpenID集成(Facebook,Twitter等…登录) 810K 将配置与代码分开存储在环境中 · 加载环境变量,例如AWS,sql用户名,部署,连接到其他工具所需的密码 · 将配置与代码分开存储在环境中 10M · 易于上传多部分/表单数据文件 92000 · 从node.js发出HTTP请求 · 从浏览器发出XMLHttpRequests · 支持Promise API 960万 · 轻松处理CORS问题 370万 2020年最推荐的14个最有用NodeJS库 标签:yam mys use 部分 ejs bst ast als inf 原文地址:https://www.cnblogs.com/zhangycun/p/13570459.htmlExpress
每周下载
cheerio
…
每周下载
nodemailer
从Node.js发送电子邮件
const nodemailer = require("nodemailer");
let testAccount = await nodemailer.createTestAccount();
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false,
auth: {
user: testAccount.user,
pass: testAccount.pass
}
});
let info = await transporter.sendMail({
from: \‘"Fred Foo "
每周下载
socket.io
const server = require(\‘http\‘).createServer();
const io = require(\‘socket.io\‘)(server);
io.on(\‘connection\‘, client => {
client.on(\‘event\‘, data => { ... });
client.on(\‘disconnect\‘, () => { ... });
});
server.listen(3000);
好处
每周下载
Faker
var faker = require(\‘faker\‘);
var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card
好处
每周下载
morgan
morgan
(\‘:method :url :status :res[content-length] - :response-time ms\‘)
---
var express = require(\‘express\‘)
var morgan = require(\‘morgan\‘)
var app = express()
app.use(morgan(\‘combined\‘))
app.get(\‘/\‘, function (req, res) {
res.send(\‘hello, world!\‘)
})
好处
每周下载
http-errors
app.use(function (req, res, next) {
if (!req.user)
return next(createError(401, \‘Please login to view this page.\‘))
next()
})
好处
headers
message
status
statusCode每周下载
body-parser
var express = require(\‘express\‘)
var bodyParser = require(\‘body-parser\‘)
var app = express()
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
好处
每周下载
sequelize
const sequelize = new Sequelize
(\‘database\‘, \‘username\‘, \‘password\‘,
{
host: \‘localhost\‘,
dialect: /* one of \‘mysql\‘
| \‘mariadb\‘ | \‘postgres\‘ | \‘mssql\‘ */ });
好处
每周下载
passport
passport.use(new LocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
if (!user.verifyPassword(password)) { return done(null,
false); }
return done(null, user);
});
}
));
好处
每周下载
Dotenv
require(\‘dotenv\‘).config()
const db = require(\‘db\‘)
db.connect({
host: process.env.DB_HOST,
username: process.env.DB_USER,
password: process.env.DB_PASS
})
// .env file
DB_HOST=localhost
DB_USER=root
DB_PASS=s1mpl3
好处
每周下载
multer
var express = require(\‘express\‘)
var multer = require(\‘multer\‘)
var upload = multer({ dest: \‘uploads/\‘ })
var app = express()
app.post(\‘/profile\‘,
upload.single(\‘avatar\‘), function (req, res, next) {
// req.file is the `avatar` file
// req.body will hold the text fields, if there were any
})
app.post(\‘/photos/upload\‘,
upload.array(\‘photos\‘, 12), function (req, res, next) {
// req.files is array of `photos` files
// req.body will contain the text fields, if there were any
})
好处
每周下载
axios
const axios = require(\‘axios\‘);
// Make a request for a user with a given ID
axios.get(\‘/user?ID=12345\‘)
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});
好处
每周下载
CORS
var express = require(\‘express\‘)
var cors = require(\‘cors\‘)
var app = express()
app.use(cors())
app.get(\‘/products/:id\‘, function (req, res, next) {
res.json({msg: \‘This is CORS-enabled for all origins!\‘})
})
app.listen(80, function () {
console.log(\‘CORS-enabled web server listening on port 80\‘)
})
好处
每周下载
上一篇:在线英语语法检查常用网站
文章标题:2020年最推荐的14个最有用NodeJS库
文章链接:http://soscw.com/index.php/essay/40631.html