@phila/cli 0.0.14 → 0.0.15

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.
@@ -39,15 +39,19 @@
39
39
  * by the CDK construct when a database is attached to the stack.
40
40
  */
41
41
 
42
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
43
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
44
- import { Router, http, validate } from '@phila/philaroute';
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
- router.path('/health').get([health.check]);
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,7 +8,7 @@
8
8
  "watch": "{{execCommand}} tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@types/aws-lambda": "^8.10.0"
13
13
  },
14
14
  "devDependencies": {
@@ -8,9 +8,13 @@
8
8
  * DynamoDB integration using AWS SDK v3 DocumentClient
9
9
  */
10
10
 
11
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
12
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
13
- import { Router, http, validate } from '@phila/philaroute';
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,
@@ -8,7 +8,7 @@
8
8
  "watch": "{{execCommand}} tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@aws-sdk/client-dynamodb": "^3.0.0",
13
13
  "@aws-sdk/lib-dynamodb": "^3.0.0",
14
14
  "@types/aws-lambda": "^8.10.0"
@@ -12,9 +12,13 @@
12
12
  * by the CDK construct.
13
13
  */
14
14
 
15
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
16
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
17
- import { Router, http, validate } from '@phila/philaroute';
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,7 +8,7 @@
8
8
  "watch": "{{execCommand}} tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@phila/db-postgres": "^{{dbPostgresVersion}}",
13
13
  "@types/aws-lambda": "^8.10.0"
14
14
  },
@@ -8,9 +8,13 @@
8
8
  * DynamoDB integration using AWS SDK v3 DocumentClient
9
9
  */
10
10
 
11
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
12
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
13
- import { Router, http, validate } from '@phila/philaroute';
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,
@@ -8,7 +8,7 @@
8
8
  "watch": "tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@aws-sdk/client-dynamodb": "^3.0.0",
13
13
  "@aws-sdk/lib-dynamodb": "^3.0.0",
14
14
  "@types/aws-lambda": "^8.10.0"
@@ -39,9 +39,13 @@
39
39
  * by the CDK construct when a database is attached to the stack.
40
40
  */
41
41
 
42
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
43
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
44
- import { Router, http, validate } from '@phila/philaroute';
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: {
@@ -8,7 +8,7 @@
8
8
  "watch": "tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@types/aws-lambda": "^8.10.0"
13
13
  },
14
14
  "devDependencies": {
@@ -12,9 +12,13 @@
12
12
  * by the CDK construct.
13
13
  */
14
14
 
15
- import type { APIGWV1Payload } from '@phila/philaroute/dist/aws';
16
- import type { RestAccumulator } from '@phila/philaroute/dist/types';
17
- import { Router, http, validate } from '@phila/philaroute';
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,7 +8,7 @@
8
8
  "watch": "tsc -w"
9
9
  },
10
10
  "dependencies": {
11
- "@phila/philaroute": "^1.0.12",
11
+ "@phila/philaroute": "^1.0.14",
12
12
  "@phila/db-postgres": "^{{dbPostgresVersion}}",
13
13
  "@types/aws-lambda": "^8.10.0"
14
14
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phila/cli",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
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.7",
27
+ "@phila/constructs": "0.0.8",
28
28
  "@phila/db-postgres": "0.0.6"
29
29
  },
30
30
  "devDependencies": {