
eggjs
皮阿玛
这个作者很懒,什么都没留下…
展开
-
egg-redis
Redis 是完全开源免费的,遵守 BSD 协议,是一个高性能的 key-value 数据库,它也属于 nosql。Redis 和 Memcached 类似,都是内存级别的数据缓存,主要用户数据缓存,它支持存储的 value 类型相对更多,包括 string(字符串)、list(链表)、set(集合)、zset(sorted set --有序集合)和 hash(哈希类型)。Redis 不仅有丰富的特性(数据持久化到硬盘、 publish/subscribe、 key 过期),还有极高性能,经测试Re原创 2021-12-23 13:50:55 · 2622 阅读 · 0 评论 -
eggjs定时任务实现网站监控 爬虫
app/schedule1.es6语法 比较麻烦const Subscription = require('egg').Subscription;class UpdateCache extends Subscription { // 通过 schedule 属性来设置定时任务的执行间隔等配置 static get schedule() { return { interval: '1m', // 1 分钟间隔 type: 'all', // 指定所有的 w原创 2021-08-29 16:23:17 · 435 阅读 · 0 评论 -
egg.js 抽取基类控制器实现继承成功失败等方法
app -> 新建文件夹 core ->base.js抽取处理成功失败的方法'use strict';const Controller = require('egg').Controller;class BaseController extends Controller { async success(redirectUrl,path){ await this.ctx.render(path,{redirectUrl}); } async e原创 2021-08-29 13:21:55 · 184 阅读 · 0 评论 -
egg.js路由
路由的写法router.verb('path-match', app.controller.action);路径 控制器调用的方法router.verb('router-name', 'path-match', app.controller.action);路由名称 路径 控制器调用的方法router.verb('path-match', middleware1, ..., middlewareN, app.controller.action);路径 中间件 控制器调用的方法路由名称 路原创 2021-08-29 12:38:45 · 326 阅读 · 0 评论 -
egg.js 中间件的使用
1.路由中间件 就是任意路由都触发的中间件config.default.js // 配置中间件 config.middleware = ['auth']; //给中间件传参 config.auth={ title:'this is auth111' }middleware auth.jsmodule.exports = (option, app) => { return async function auth(ctx, next) {.原创 2021-08-29 11:01:10 · 905 阅读 · 0 评论 -
egg之新闻系统
知识点: 1.使用ejs 2.遵循MVC设计模式 3.配置url到配置文件中 4.使用中间件 5.使用扩展helper.js 配置ejs 中间件 参数(即options)以及url共享config.default.js/* eslint valid-jsdoc: "off" */'use strict';/** * @param {Egg.EggAppInfo} appI...原创 2021-08-28 17:48:53 · 155 阅读 · 0 评论 -
eggjs cookie和session
cookie设置 this.ctx.cookies.set('username','牛召功',{ maxAge:1000*60*60*24, signed:true, //对cookie进行签名 防止用户修改cookie encrypt:true //是否对cookie进行加密 如果cookie加密那么获取的时候要对cookie进行解密 });获取 // 清除cookie th原创 2021-08-28 16:40:21 · 301 阅读 · 0 评论 -
egg.js-get post 以及mvc思想渲染网页数据
get xx.com/xx='xxx'&xx=xx获取方式this.ctx.querypost 默认需要csrf配置post请求默认会提示csrf攻击没有设置invalidcsrftoken添加csrfget方式渲染ejs两种方式 1.普通方式 直接把csrf设为参数传递过去awaitthis.ctx.render('postsub',{csrf:this.ctx.csrf}) 2.使用中间件避免每...原创 2021-08-28 16:35:14 · 239 阅读 · 1 评论