新年快乐!
🗞 News
Create React App 5 发布
此次大版本更新的 CRA(Create React App)升级了 Webpack 5,PostCSS 8,以及支持使用 Tailwind CSS(此前在新版 React 官方文档中已有使用)。
Release Message:Release v5.0.0 · facebook/create-react-app
GitHub Repo:facebook/create-react-app: Set up a modern web app by running one command. (github.com)
📦 Open Source
express-validator
一款用于参数字段校验的 Express 中间件。
使用方式也非常简单,安装依赖后即可使用:
// ...rest of the initial code omitted for simplicity.
import { body, validationResult } from 'express-validator';
app.post(
'/user',
// username must be an email
body('username').isEmail(),
// password must be at least 5 chars long
body('password').isLength({ min: 5 }),
(req: express.Request, res: express.Response) => {
// Finds the validation errors in this request and wraps them in an object with handy functions
const errors = validationResult(req);
if (!errors.isEmpty()) {
return res.status(400).json({ errors: errors.array() });
}
User.create({
username: req.body.username,
password: req.body.password,
}).then((user) => res.json(user));
}
);
Home Page:Getting Started · express-validator
GitHub Repo:express-validator/express-validator: An express.js middleware for validator.js.
Pinia
Vuex 的替代品,类型安全的新一代 Vue 官方状态管理工具。