q-koa 9.0.2 → 9.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/core/config.js CHANGED
@@ -132,6 +132,9 @@ module.exports = {
132
132
  },
133
133
  cacheModel: [],
134
134
  defaultRouter: (router) => (app) => {
135
+ router.get('/cache/get', app.controller.cache.get)
136
+ router.get('/cache/clear', app.controller.cache.clear)
137
+
135
138
  router.get('/weixin/h5_login', app.controller.weixin.h5_login)
136
139
  router.get(
137
140
  '/weixin/h5_login_callback',
@@ -0,0 +1,23 @@
1
+ const { getAppByCtx, getUserByCtx, getConfig } = require('q-koa')
2
+
3
+ exports.get = async (ctx) => {
4
+ const { app, appName } = getAppByCtx(ctx)
5
+ const key =
6
+ ctx.request.method === 'POST' ? ctx.request.body.key : ctx.query.key
7
+
8
+ if (!key) return ctx.ERROR('缺key')
9
+ const result = app.cache.get(key)
10
+
11
+ ctx.SUCCESS(result || '')
12
+ }
13
+
14
+ exports.clear = async (ctx) => {
15
+ const { app, appName } = getAppByCtx(ctx)
16
+ const key =
17
+ ctx.request.method === 'POST' ? ctx.request.body.key : ctx.query.key
18
+
19
+ if (!key) return ctx.ERROR('缺key')
20
+ app.cache.set(key, '')
21
+
22
+ ctx.SUCCESS('ok')
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "9.0.2",
3
+ "version": "9.0.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {