@ttoss/lambda-postgres-query 0.2.2 → 0.2.4
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/README.md +7 -1
- package/dist/cloudformation/index.d.cts +2 -2
- package/dist/cloudformation/index.d.ts +2 -2
- package/dist/cloudformation/index.js +18 -4
- package/dist/esm/cloudformation/index.js +17 -3
- package/package.json +5 -5
- package/src/cloudformation/{createLambdaQueryTemplate.ts → createLambdaPostgresQueryTemplate.ts} +11 -1
- package/src/cloudformation/index.ts +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,11 @@ pnpm install @ttoss/lambda-postgres-query
|
|
|
25
25
|
Create a `src/cloudformation.ts` file with the following content:
|
|
26
26
|
|
|
27
27
|
```typescript
|
|
28
|
-
import {
|
|
28
|
+
import { createLambdaPostgresQueryTemplate } from '@ttoss/lambda-postgres-query/cloudformation';
|
|
29
|
+
|
|
30
|
+
const template = createLambdaPostgresQueryTemplate();
|
|
31
|
+
|
|
32
|
+
export default template;
|
|
29
33
|
```
|
|
30
34
|
|
|
31
35
|
Create a `src/handler.ts` file with the following content:
|
|
@@ -63,6 +67,8 @@ Add the `deploy` script to the `package.json` file:
|
|
|
63
67
|
pnpm deploy
|
|
64
68
|
```
|
|
65
69
|
|
|
70
|
+
_**Note:** When deploying using carlin, you need to set `lambdaFormat: 'cjs'` because `pg` package doesn't support ESM format._
|
|
71
|
+
|
|
66
72
|
It'll create the necessary resources to query the Postgres database and display the name of the Lambda function created.
|
|
67
73
|
|
|
68
74
|
### Querying the database
|
|
@@ -7,7 +7,7 @@ import 'pg';
|
|
|
7
7
|
declare const HANDLER_DEFAULT = "handler.handler";
|
|
8
8
|
declare const MEMORY_SIZE_DEFAULT = 128;
|
|
9
9
|
declare const TIMEOUT_DEFAULT = 30;
|
|
10
|
-
declare const
|
|
10
|
+
declare const createLambdaPostgresQueryTemplate: ({ handler, memorySize, timeout, }?: {
|
|
11
11
|
handler?: string;
|
|
12
12
|
memorySize?: number;
|
|
13
13
|
timeout?: number;
|
|
@@ -15,4 +15,4 @@ declare const createLambdaQueryTemplate: ({ handler, memorySize, timeout, }?: {
|
|
|
15
15
|
|
|
16
16
|
declare const handler: Handler<QueryParams>;
|
|
17
17
|
|
|
18
|
-
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT,
|
|
18
|
+
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT, createLambdaPostgresQueryTemplate, handler };
|
|
@@ -7,7 +7,7 @@ import 'pg';
|
|
|
7
7
|
declare const HANDLER_DEFAULT = "handler.handler";
|
|
8
8
|
declare const MEMORY_SIZE_DEFAULT = 128;
|
|
9
9
|
declare const TIMEOUT_DEFAULT = 30;
|
|
10
|
-
declare const
|
|
10
|
+
declare const createLambdaPostgresQueryTemplate: ({ handler, memorySize, timeout, }?: {
|
|
11
11
|
handler?: string;
|
|
12
12
|
memorySize?: number;
|
|
13
13
|
timeout?: number;
|
|
@@ -15,4 +15,4 @@ declare const createLambdaQueryTemplate: ({ handler, memorySize, timeout, }?: {
|
|
|
15
15
|
|
|
16
16
|
declare const handler: Handler<QueryParams>;
|
|
17
17
|
|
|
18
|
-
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT,
|
|
18
|
+
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT, createLambdaPostgresQueryTemplate, handler };
|
|
@@ -30,16 +30,16 @@ __export(cloudformation_exports, {
|
|
|
30
30
|
HANDLER_DEFAULT: () => HANDLER_DEFAULT,
|
|
31
31
|
MEMORY_SIZE_DEFAULT: () => MEMORY_SIZE_DEFAULT,
|
|
32
32
|
TIMEOUT_DEFAULT: () => TIMEOUT_DEFAULT,
|
|
33
|
-
|
|
33
|
+
createLambdaPostgresQueryTemplate: () => createLambdaPostgresQueryTemplate,
|
|
34
34
|
handler: () => handler
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(cloudformation_exports);
|
|
37
37
|
|
|
38
|
-
// src/cloudformation/
|
|
38
|
+
// src/cloudformation/createLambdaPostgresQueryTemplate.ts
|
|
39
39
|
var HANDLER_DEFAULT = "handler.handler";
|
|
40
40
|
var MEMORY_SIZE_DEFAULT = 128;
|
|
41
41
|
var TIMEOUT_DEFAULT = 30;
|
|
42
|
-
var
|
|
42
|
+
var createLambdaPostgresQueryTemplate = ({
|
|
43
43
|
handler: handler2 = HANDLER_DEFAULT,
|
|
44
44
|
memorySize = 128,
|
|
45
45
|
timeout = 30
|
|
@@ -164,6 +164,20 @@ var createLambdaQueryTemplate = ({
|
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
},
|
|
168
|
+
Outputs: {
|
|
169
|
+
LambdaPostgresQueryFunction: {
|
|
170
|
+
Description: "Lambda function to query PostgreSQL.",
|
|
171
|
+
Value: {
|
|
172
|
+
Ref: "LambdaQueryFunction"
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
LambdaPostgresQueryFunctionArn: {
|
|
176
|
+
Description: "Lambda function to query PostgreSQL ARN.",
|
|
177
|
+
Value: {
|
|
178
|
+
"Fn::GetAtt": ["LambdaQueryFunction", "Arn"]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
167
181
|
}
|
|
168
182
|
};
|
|
169
183
|
};
|
|
@@ -205,6 +219,6 @@ var handler = async event => {
|
|
|
205
219
|
HANDLER_DEFAULT,
|
|
206
220
|
MEMORY_SIZE_DEFAULT,
|
|
207
221
|
TIMEOUT_DEFAULT,
|
|
208
|
-
|
|
222
|
+
createLambdaPostgresQueryTemplate,
|
|
209
223
|
handler
|
|
210
224
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
|
|
2
2
|
|
|
3
|
-
// src/cloudformation/
|
|
3
|
+
// src/cloudformation/createLambdaPostgresQueryTemplate.ts
|
|
4
4
|
var HANDLER_DEFAULT = "handler.handler";
|
|
5
5
|
var MEMORY_SIZE_DEFAULT = 128;
|
|
6
6
|
var TIMEOUT_DEFAULT = 30;
|
|
7
|
-
var
|
|
7
|
+
var createLambdaPostgresQueryTemplate = ({
|
|
8
8
|
handler: handler2 = HANDLER_DEFAULT,
|
|
9
9
|
memorySize = 128,
|
|
10
10
|
timeout = 30
|
|
@@ -129,6 +129,20 @@ var createLambdaQueryTemplate = ({
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
+
},
|
|
133
|
+
Outputs: {
|
|
134
|
+
LambdaPostgresQueryFunction: {
|
|
135
|
+
Description: "Lambda function to query PostgreSQL.",
|
|
136
|
+
Value: {
|
|
137
|
+
Ref: "LambdaQueryFunction"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
LambdaPostgresQueryFunctionArn: {
|
|
141
|
+
Description: "Lambda function to query PostgreSQL ARN.",
|
|
142
|
+
Value: {
|
|
143
|
+
"Fn::GetAtt": ["LambdaQueryFunction", "Arn"]
|
|
144
|
+
}
|
|
145
|
+
}
|
|
132
146
|
}
|
|
133
147
|
};
|
|
134
148
|
};
|
|
@@ -165,4 +179,4 @@ var handler = async event => {
|
|
|
165
179
|
throw error;
|
|
166
180
|
}
|
|
167
181
|
};
|
|
168
|
-
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT,
|
|
182
|
+
export { HANDLER_DEFAULT, MEMORY_SIZE_DEFAULT, TIMEOUT_DEFAULT, createLambdaPostgresQueryTemplate, handler };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/lambda-postgres-query",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "Create a Lambda function that queries a PostgreSQL database.",
|
|
5
5
|
"author": "ttoss",
|
|
6
6
|
"contributors": [
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts"
|
|
20
20
|
},
|
|
21
21
|
"./cloudformation": {
|
|
22
|
-
"import": "./dist/esm/cloudformation.js",
|
|
23
|
-
"require": "./dist/cloudformation.js",
|
|
22
|
+
"import": "./dist/esm/cloudformation/index.js",
|
|
23
|
+
"require": "./dist/cloudformation/index.js",
|
|
24
24
|
"types": "./dist/cloudformation/index.d.ts"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"@types/pg": "^8.11.6",
|
|
39
39
|
"jest": "^29.7.0",
|
|
40
40
|
"tsup": "^8.1.0",
|
|
41
|
-
"@ttoss/
|
|
42
|
-
"@ttoss/
|
|
41
|
+
"@ttoss/test-utils": "^2.1.10",
|
|
42
|
+
"@ttoss/config": "^1.32.6"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"aws",
|
package/src/cloudformation/{createLambdaQueryTemplate.ts → createLambdaPostgresQueryTemplate.ts}
RENAMED
|
@@ -8,7 +8,7 @@ export const MEMORY_SIZE_DEFAULT = 128;
|
|
|
8
8
|
|
|
9
9
|
export const TIMEOUT_DEFAULT = 30;
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const createLambdaPostgresQueryTemplate = ({
|
|
12
12
|
handler = HANDLER_DEFAULT,
|
|
13
13
|
memorySize = 128,
|
|
14
14
|
timeout = 30,
|
|
@@ -119,5 +119,15 @@ export const createLambdaQueryTemplate = ({
|
|
|
119
119
|
},
|
|
120
120
|
},
|
|
121
121
|
},
|
|
122
|
+
Outputs: {
|
|
123
|
+
LambdaPostgresQueryFunction: {
|
|
124
|
+
Description: 'Lambda function to query PostgreSQL.',
|
|
125
|
+
Value: { Ref: 'LambdaQueryFunction' },
|
|
126
|
+
},
|
|
127
|
+
LambdaPostgresQueryFunctionArn: {
|
|
128
|
+
Description: 'Lambda function to query PostgreSQL ARN.',
|
|
129
|
+
Value: { 'Fn::GetAtt': ['LambdaQueryFunction', 'Arn'] },
|
|
130
|
+
},
|
|
131
|
+
},
|
|
122
132
|
};
|
|
123
133
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './createLambdaPostgresQueryTemplate';
|
|
2
2
|
export * from './lambdaQueryHandler';
|