@phila/cli 0.0.14 → 0.0.17
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/dist/templates/lambda-api-nodejs/apps/__lambdaName__/index.ts +25 -8
- package/dist/templates/lambda-api-nodejs/apps/__lambdaName__/package.json +1 -1
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/index.ts +7 -3
- package/dist/templates/lambda-dynamo-api/apps/__lambdaName__/package.json +1 -1
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/index.ts +7 -3
- package/dist/templates/lambda-postgres-api/apps/__lambdaName__/package.json +1 -1
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/index.ts +7 -3
- package/dist/templates/webapp-lambda-dynamo-node/apps/api/package.json +1 -1
- package/dist/templates/webapp-lambda-node/apps/api/index.ts +7 -3
- package/dist/templates/webapp-lambda-node/apps/api/package.json +1 -1
- package/dist/templates/webapp-lambda-postgres-node/apps/api/index.ts +7 -3
- package/dist/templates/webapp-lambda-postgres-node/apps/api/package.json +1 -1
- package/package.json +2 -2
|
@@ -39,15 +39,19 @@
|
|
|
39
39
|
* by the CDK construct when a database is attached to the stack.
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
import
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
import {
|
|
43
|
+
Router,
|
|
44
|
+
http,
|
|
45
|
+
validate,
|
|
46
|
+
type APIGWV1Payload,
|
|
47
|
+
type RestAccumulator,
|
|
48
|
+
} from '@phila/philaroute';
|
|
45
49
|
|
|
46
50
|
const router = Router({
|
|
47
51
|
cors: {
|
|
48
52
|
'Access-Control-Allow-Origin': '*',
|
|
49
53
|
'Access-Control-Allow-Method': 'GET,POST,PUT,DELETE,OPTIONS',
|
|
50
|
-
'Access-Control-Allow-Headers': 'Content-Type,Authorization',
|
|
54
|
+
'Access-Control-Allow-Headers': 'Content-Type,Authorization,x-api-key',
|
|
51
55
|
},
|
|
52
56
|
});
|
|
53
57
|
|
|
@@ -67,6 +71,13 @@ const hello = {
|
|
|
67
71
|
};
|
|
68
72
|
|
|
69
73
|
const items = {
|
|
74
|
+
list: async (acc: RestAccumulator) => {
|
|
75
|
+
acc.data.items = [
|
|
76
|
+
{ id: '1', name: 'Example Item 1' },
|
|
77
|
+
{ id: '2', name: 'Example Item 2' },
|
|
78
|
+
];
|
|
79
|
+
return acc;
|
|
80
|
+
},
|
|
70
81
|
create: async (acc: RestAccumulator) => {
|
|
71
82
|
acc.data.item = { id: '123', ...acc.data.valid.body };
|
|
72
83
|
acc.data.message = 'Item created';
|
|
@@ -77,13 +88,19 @@ const items = {
|
|
|
77
88
|
// Route definitions
|
|
78
89
|
// The router automatically responds with 200 and acc.data as body.
|
|
79
90
|
// Use http.response({ statusCode }) only when overriding (e.g., 201 for POST).
|
|
91
|
+
//
|
|
92
|
+
// Routes under /public/* require no authentication
|
|
93
|
+
// Routes under /private/key/* require API key authentication
|
|
94
|
+
// API key is stored in Secrets Manager - check Parameter Store for secret ARN
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
router.path('/hello').get([validate.parameters(['name']), hello.greet]);
|
|
96
|
+
// Public routes - no authentication required
|
|
97
|
+
router.path('/public/health').get([health.check]);
|
|
98
|
+
router.path('/public/hello').get([validate.parameters(['name']), hello.greet]);
|
|
84
99
|
|
|
100
|
+
// Protected routes - API key required
|
|
101
|
+
router.path('/private/key/items').get([items.list]);
|
|
85
102
|
router
|
|
86
|
-
.path('/items')
|
|
103
|
+
.path('/private/key/items')
|
|
87
104
|
.post([validate.body({ name: 'string' }), items.create, http.response({ statusCode: 201 })]);
|
|
88
105
|
|
|
89
106
|
export const handler = async (event: APIGWV1Payload) => router.routeToPath(event);
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* DynamoDB integration using AWS SDK v3 DocumentClient
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import {
|
|
12
|
+
Router,
|
|
13
|
+
http,
|
|
14
|
+
validate,
|
|
15
|
+
type APIGWV1Payload,
|
|
16
|
+
type RestAccumulator,
|
|
17
|
+
} from '@phila/philaroute';
|
|
14
18
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
15
19
|
import {
|
|
16
20
|
DynamoDBDocumentClient,
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
* by the CDK construct.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
Router,
|
|
17
|
+
http,
|
|
18
|
+
validate,
|
|
19
|
+
type APIGWV1Payload,
|
|
20
|
+
type RestAccumulator,
|
|
21
|
+
} from '@phila/philaroute';
|
|
18
22
|
import { getPool } from '@phila/db-postgres';
|
|
19
23
|
|
|
20
24
|
const router = Router({
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
* DynamoDB integration using AWS SDK v3 DocumentClient
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
import {
|
|
12
|
+
Router,
|
|
13
|
+
http,
|
|
14
|
+
validate,
|
|
15
|
+
type APIGWV1Payload,
|
|
16
|
+
type RestAccumulator,
|
|
17
|
+
} from '@phila/philaroute';
|
|
14
18
|
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
15
19
|
import {
|
|
16
20
|
DynamoDBDocumentClient,
|
|
@@ -39,9 +39,13 @@
|
|
|
39
39
|
* by the CDK construct when a database is attached to the stack.
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
import
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
import {
|
|
43
|
+
Router,
|
|
44
|
+
http,
|
|
45
|
+
validate,
|
|
46
|
+
type APIGWV1Payload,
|
|
47
|
+
type RestAccumulator,
|
|
48
|
+
} from '@phila/philaroute';
|
|
45
49
|
|
|
46
50
|
const router = Router({
|
|
47
51
|
cors: {
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
* by the CDK construct.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
import {
|
|
16
|
+
Router,
|
|
17
|
+
http,
|
|
18
|
+
validate,
|
|
19
|
+
type APIGWV1Payload,
|
|
20
|
+
type RestAccumulator,
|
|
21
|
+
} from '@phila/philaroute';
|
|
18
22
|
import { getPool } from '@phila/db-postgres';
|
|
19
23
|
|
|
20
24
|
const router = Router({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phila/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "CLI tool for City of Philadelphia AWS infrastructure",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"commander": "^11.0.0",
|
|
25
25
|
"fs-extra": "^11.1.0",
|
|
26
26
|
"inquirer": "^8.2.5",
|
|
27
|
-
"@phila/constructs": "0.0.
|
|
27
|
+
"@phila/constructs": "0.0.10",
|
|
28
28
|
"@phila/db-postgres": "0.0.6"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|