koishi-plugin-http-monetary 0.0.3 → 0.0.5

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.
Files changed (2) hide show
  1. package/lib/index.js +4 -5
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -51,7 +51,7 @@ var Config = import_koishi.Schema.intersect([
51
51
 
52
52
  // src/index.ts
53
53
  var name = "plugin-http-monetary";
54
- var inject = ["monetary", "server", "logger"];
54
+ var inject = ["monetary", "server", "logger", "database"];
55
55
  var usage = `
56
56
  <hr>
57
57
  <h2>浅浅的用http封装一下www(带鉴权版)</h2>
@@ -80,7 +80,6 @@ function apply(ctx, config) {
80
80
  handleUnauthorized(koaCtx);
81
81
  return;
82
82
  }
83
- const koishiCtx = koaCtx.ctx;
84
83
  const uid = parseInt(koaCtx.params.uid);
85
84
  if (isNaN(uid)) {
86
85
  koaCtx.status = 400;
@@ -90,7 +89,7 @@ function apply(ctx, config) {
90
89
  }
91
90
  const currency = koaCtx.query.currency || "default";
92
91
  try {
93
- const [data] = await koishiCtx.database.get("monetary", { uid, currency }, ["value"]);
92
+ const [data] = await ctx.database.get("monetary", { uid, currency }, ["value"]);
94
93
  koaCtx.body = {
95
94
  uid,
96
95
  currency,
@@ -117,7 +116,7 @@ function apply(ctx, config) {
117
116
  return;
118
117
  }
119
118
  try {
120
- await koishiCtx.monetary.gain(uid, amount, currency || "default");
119
+ await ctx.monetary.gain(uid, amount, currency || "default");
121
120
  koaCtx.body = { success: true };
122
121
  logger_status(logger, config.loggerinfo)?.info(`增加点数成功: uid=${uid} amount=${amount} currency=${currency || "default"}`);
123
122
  } catch (e) {
@@ -140,7 +139,7 @@ function apply(ctx, config) {
140
139
  return;
141
140
  }
142
141
  try {
143
- await koishiCtx.monetary.cost(uid, amount, currency || "default");
142
+ await ctx.monetary.cost(uid, amount, currency || "default");
144
143
  koaCtx.body = { success: true };
145
144
  logger_status(logger, config.loggerinfo)?.info(`扣除点数成功: uid=${uid} amount=${amount} currency=${currency || "default"}`);
146
145
  } catch (e) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koishi-plugin-http-monetary",
3
3
  "description": "HTTP API for Koishi Monetary Plugin",
4
- "version": "0.0.3",
4
+ "version": "0.0.5",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "contributors": [