declapract-typescript-ehmpathy 0.30.2 → 0.30.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.
@@ -30,7 +30,6 @@ jobs:
30
30
  uses: actions/setup-node@v3
31
31
  with:
32
32
  node-version-file: '.nvmrc'
33
- cache: 'npm'
34
33
 
35
34
  - name: node-modules cache get
36
35
  uses: actions/cache/restore@v3
@@ -64,7 +63,6 @@ jobs:
64
63
  uses: actions/setup-node@v3
65
64
  with:
66
65
  node-version-file: '.nvmrc'
67
- cache: 'npm'
68
66
 
69
67
  - name: get node-modules from cache
70
68
  uses: actions/cache/restore@v3
@@ -86,7 +84,6 @@ jobs:
86
84
  uses: actions/setup-node@v3
87
85
  with:
88
86
  node-version-file: '.nvmrc'
89
- cache: 'npm'
90
87
 
91
88
  - name: get node-modules from cache
92
89
  uses: actions/cache/restore@v3
@@ -108,7 +105,6 @@ jobs:
108
105
  uses: actions/setup-node@v3
109
106
  with:
110
107
  node-version-file: '.nvmrc'
111
- cache: 'npm'
112
108
 
113
109
  - name: get node-modules from cache
114
110
  uses: actions/cache/restore@v3
@@ -130,7 +126,6 @@ jobs:
130
126
  uses: actions/setup-node@v3
131
127
  with:
132
128
  node-version-file: '.nvmrc'
133
- cache: 'npm'
134
129
 
135
130
  - name: get node-modules from cache
136
131
  uses: actions/cache/restore@v3
@@ -152,7 +147,6 @@ jobs:
152
147
  uses: actions/setup-node@v3
153
148
  with:
154
149
  node-version-file: '.nvmrc'
155
- cache: 'npm'
156
150
 
157
151
  - name: get node-modules from cache
158
152
  uses: actions/cache/restore@v3
@@ -174,7 +168,6 @@ jobs:
174
168
  uses: actions/setup-node@v3
175
169
  with:
176
170
  node-version-file: '.nvmrc'
177
- cache: 'npm'
178
171
 
179
172
  - name: get node-modules from cache
180
173
  uses: actions/cache/restore@v3
@@ -215,7 +208,6 @@ jobs:
215
208
  uses: actions/setup-node@v3
216
209
  with:
217
210
  node-version-file: '.nvmrc'
218
- cache: 'npm'
219
211
 
220
212
  - name: get node-modules from cache
221
213
  uses: actions/cache/restore@v3
@@ -19,7 +19,6 @@ jobs:
19
19
  with:
20
20
  registry-url: 'https://registry.npmjs.org/'
21
21
  node-version-file: '.nvmrc'
22
- cache: 'npm'
23
22
 
24
23
  - name: node-modules cache get
25
24
  uses: actions/cache/restore@v3
@@ -46,7 +46,6 @@ jobs:
46
46
  uses: actions/setup-node@v3
47
47
  with:
48
48
  node-version-file: '.nvmrc'
49
- cache: 'npm'
50
49
 
51
50
  - name: configure aws credentials
52
51
  uses: aws-actions/configure-aws-credentials@v1
@@ -87,7 +86,6 @@ jobs:
87
86
  uses: actions/setup-node@v3
88
87
  with:
89
88
  node-version-file: '.nvmrc'
90
- cache: 'npm'
91
89
 
92
90
  - name: configure aws credentials
93
91
  uses: aws-actions/configure-aws-credentials@v1
@@ -152,7 +150,6 @@ jobs:
152
150
  uses: actions/setup-node@v3
153
151
  with:
154
152
  node-version-file: '.nvmrc'
155
- cache: 'npm'
156
153
 
157
154
  - name: configure aws credentials
158
155
  uses: aws-actions/configure-aws-credentials@v1
@@ -44,7 +44,6 @@ jobs:
44
44
  uses: actions/setup-node@v3
45
45
  with:
46
46
  node-version-file: '.nvmrc'
47
- cache: 'npm'
48
47
 
49
48
  - name: node-modules cache get
50
49
  uses: actions/cache/restore@v3
@@ -129,7 +128,6 @@ jobs:
129
128
  uses: actions/setup-node@v3
130
129
  with:
131
130
  node-version-file: '.nvmrc'
132
- cache: 'npm'
133
131
 
134
132
  - name: node-modules cache get
135
133
  uses: actions/cache/restore@v3
@@ -1,3 +1,5 @@
1
+ import { DropFirst } from 'type-fns';
2
+
1
3
  import {
2
4
  DatabaseConnection,
3
5
  getDatabaseConnection,
@@ -22,21 +24,23 @@ import {
22
24
  export const withDatabaseConnection = <
23
25
  P extends { dbConnection: DatabaseConnection },
24
26
  R,
27
+ PR, // the rest of the parameters
25
28
  >(
26
- logic: (args: P) => R | Promise<R>,
29
+ logic: (args0: P, ...argsRest: PR[]) => R | Promise<R>,
27
30
  ) => {
28
31
  return async (
29
- args: Omit<P, 'dbConnection'> & { dbConnection?: DatabaseConnection },
32
+ args0: Omit<P, 'dbConnection'> & { dbConnection?: DatabaseConnection },
33
+ ...argsRest: DropFirst<Parameters<typeof logic>>
30
34
  ) => {
31
35
  // open the db connection, if one was not given
32
- const dbConnection = args.dbConnection ?? (await getDatabaseConnection());
36
+ const dbConnection = args0.dbConnection ?? (await getDatabaseConnection());
33
37
 
34
38
  // try and run the logic with db connection
35
39
  try {
36
- return await logic({ ...args, dbConnection } as P); // as P because: https://github.com/microsoft/TypeScript/issues/35858
40
+ return await logic({ ...args0, dbConnection } as P, ...argsRest); // as P because: https://github.com/microsoft/TypeScript/issues/35858
37
41
  } finally {
38
42
  // make sure to close the db connection, both when `logic` throws an error or succeeds
39
- if (!args.dbConnection) await dbConnection.end();
43
+ if (!args0.dbConnection) await dbConnection.end();
40
44
  }
41
45
  };
42
46
  };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "declapract-typescript-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "declapract best practices declarations for typescript",
5
- "version": "0.30.2",
5
+ "version": "0.30.3",
6
6
  "main": "src/index.js",
7
7
  "repository": "ehmpathy/declapract-typescript-ehmpathy",
8
8
  "homepage": "https://github.com/ehmpathy/declapract-typescript-ehmpathy",