@jayfong/x-server 2.1.7 → 2.2.1

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.
@@ -1,2 +1,2 @@
1
- // @index(['../../src/crons/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
1
+ // @index(['../../src/crons/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `import '${f.path}'`)
2
2
  // @endindex
@@ -1,3 +1,3 @@
1
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `export * as __${_.pascal(f.path.replace('/src/handlers/', ''))}__ from '${f.path}'`)
1
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `export * as __${_.pascal(f.path.replace('/src/handlers/', ''))}__ from '${f.path}'`)
2
2
 
3
3
  // @endindex
@@ -1,2 +1,2 @@
1
- // @index(['../../src/hooks/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
1
+ // @index(['../../src/hooks/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `import '${f.path}'`)
2
2
  // @endindex
@@ -2,7 +2,7 @@ import * as handlers from './handlers'
2
2
  import { Handler, XServer } from '@jayfong/x-server'
3
3
 
4
4
  const basePathWithHandlers: Array<[string, Record<string, Handler>]> = [
5
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
5
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
6
6
  // @endindex
7
7
  ]
8
8
 
@@ -13,7 +13,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
13
13
  ? I
14
14
  : never
15
15
  type RouteMap = {
16
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
16
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
17
17
  // @endindex
18
18
  }
19
19
  export type HandlerMap = UnionToIntersection<
@@ -56,8 +56,9 @@ class PayService {
56
56
  }
57
57
 
58
58
  async prepareWepay(options) {
59
+ const appId = options.appId || this.options.wepay.appId;
59
60
  const res = await this.wepayRequest('https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi', {
60
- appid: this.options.wepay.appId,
61
+ appid: appId,
61
62
  mchid: this.options.wepay.merchantId,
62
63
  description: options.goodsName,
63
64
  out_trade_no: options.tradeNumber,
@@ -78,7 +79,7 @@ class PayService {
78
79
  }
79
80
 
80
81
  const params = {
81
- appId: this.options.wepay.appId,
82
+ appId: appId,
82
83
  timestamp: String(Math.round(Date.now() / 1000)),
83
84
  nonceStr: Math.random().toString().substr(2, 12),
84
85
  package: `prepay_id=${res.prepay_id}`,
@@ -1,2 +1,2 @@
1
- // @index(['../../src/crons/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
1
+ // @index(['../../src/crons/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `import '${f.path}'`)
2
2
  // @endindex
@@ -1,3 +1,3 @@
1
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `export * as __${_.pascal(f.path.replace('/src/handlers/', ''))}__ from '${f.path}'`)
1
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `export * as __${_.pascal(f.path.replace('/src/handlers/', ''))}__ from '${f.path}'`)
2
2
 
3
3
  // @endindex
@@ -1,2 +1,2 @@
1
- // @index(['../../src/hooks/**/*.ts', '!**/_*'], (f, _) => `import '${f.path}'`)
1
+ // @index(['../../src/hooks/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `import '${f.path}'`)
2
2
  // @endindex
@@ -2,7 +2,7 @@ import * as handlers from './handlers'
2
2
  import { Handler, XServer } from '@jayfong/x-server'
3
3
 
4
4
  const basePathWithHandlers: Array<[string, Record<string, Handler>]> = [
5
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
5
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `['${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}', handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__ as any],`)
6
6
  // @endindex
7
7
  ]
8
8
 
@@ -13,7 +13,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
13
13
  ? I
14
14
  : never
15
15
  type RouteMap = {
16
- // @index(['../../src/handlers/**/*.ts', '!**/_*'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
16
+ // @index(['../../src/handlers/**/*.ts', '!**/_*', '!**/_*/**'], (f, _) => `'${(f.path+'/').replace('../../src/handlers/', '/').replace(/\/index\/$/, '/').split('/').map(v => _.snake(v)).join('/')}': typeof handlers.__${_.pascal(f.path.replace('/src/handlers/', ''))}__,`)
17
17
  // @endindex
18
18
  }
19
19
  export type HandlerMap = UnionToIntersection<
@@ -48,6 +48,8 @@ export interface PayServicePrepareWepayOptions {
48
48
  totalMoney: number;
49
49
  /** 通知地址(POST) */
50
50
  notifyUrl: string;
51
+ /** 对应公众号的 appId */
52
+ appId?: string;
51
53
  /** 对应公众号用户的 openid */
52
54
  openid: string;
53
55
  }
@@ -44,8 +44,9 @@ export class PayService {
44
44
  }
45
45
 
46
46
  async prepareWepay(options) {
47
+ const appId = options.appId || this.options.wepay.appId;
47
48
  const res = await this.wepayRequest('https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi', {
48
- appid: this.options.wepay.appId,
49
+ appid: appId,
49
50
  mchid: this.options.wepay.merchantId,
50
51
  description: options.goodsName,
51
52
  out_trade_no: options.tradeNumber,
@@ -66,7 +67,7 @@ export class PayService {
66
67
  }
67
68
 
68
69
  const params = {
69
- appId: this.options.wepay.appId,
70
+ appId: appId,
70
71
  timestamp: String(Math.round(Date.now() / 1000)),
71
72
  nonceStr: Math.random().toString().substr(2, 12),
72
73
  package: `prepay_id=${res.prepay_id}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jayfong/x-server",
3
- "version": "2.1.7",
3
+ "version": "2.2.1",
4
4
  "license": "ISC",
5
5
  "sideEffects": false,
6
6
  "main": "lib/_cjs/index.js",