-
const db_data = await ctx.service.product.index();
查看全部 -
'use strict';
// import { log } from '../utils/log';
const log = console.log;
const Service = require('egg').Service;
class ProductService extends Service {
// DB SQL
async find(uid) {
const product = await this.ctx.db.query('select * from product where uid = ?', uid);
return product;
}
}
module.exports = ProductService;
查看全部 -
DB
MySQL / MongoDB
查看全部 -
查看全部
-
查看全部
-
## CSRF 攻击:伪造用户请求向网站发起恶意请求。
> message: "invalid csrf token"
https://eggjs.org/zh-cn/core/security.html#安全威胁csrf的防范
https://eggjs.org/zh-cn/core/security.html#安全威胁-csrf-的防范
```js
// CSRF
// config/config.default.js
// module.exports = {
// security: {
// csrf: {
// ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
// },
// },
// };
config.security = {
csrf: {
enable: false,
},
};
```
查看全部 -
```js// config/config.default.js
module.exports = {
security: {
csrf: {
ignoreJSON: true, // 默认为 false,当设置为 true 时,将会放过所有 content-type 为 `application/json` 的请求
},
},
};
```
查看全部 -
查看全部
-
查看全部
-
HTTP methods
https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
查看全部 -
module.exports = app => {
// KOA 洋葱模型,middleware
const {
router,
controller,
} = app;
router.get('/', controller.home.index);
// router.get('/', controller.product.index);
router.get('/product', controller.product.index);
// query
// http://localhost:7001/product/detail?id=123&name=admin
router.get('/product/detail', controller.product.detail);
// params
// http://localhost:7001/product/detail2/123/admin
router.get('/product/detail2/:id/:name', controller.product.detail2);
};
查看全部 -
竟然不支持 import
查看全部 -
fixed 404 bug
http://localhost:7001/product
// router.get('/', controller.product.index);
router.get('/product', controller.product.index);
查看全部 -
koa 洋葱模型
koa 中间件
查看全部 -
查看全部
举报