create-aws-project 1.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.
- package/README.md +118 -0
- package/dist/__tests__/generator/replace-tokens.spec.d.ts +1 -0
- package/dist/__tests__/generator/replace-tokens.spec.js +281 -0
- package/dist/__tests__/generator.spec.d.ts +1 -0
- package/dist/__tests__/generator.spec.js +162 -0
- package/dist/__tests__/validation/project-name.spec.d.ts +1 -0
- package/dist/__tests__/validation/project-name.spec.js +57 -0
- package/dist/__tests__/wizard.spec.d.ts +1 -0
- package/dist/__tests__/wizard.spec.js +232 -0
- package/dist/aws/iam.d.ts +75 -0
- package/dist/aws/iam.js +264 -0
- package/dist/aws/organizations.d.ts +79 -0
- package/dist/aws/organizations.js +168 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +206 -0
- package/dist/commands/setup-github.d.ts +4 -0
- package/dist/commands/setup-github.js +185 -0
- package/dist/generator/copy-file.d.ts +15 -0
- package/dist/generator/copy-file.js +56 -0
- package/dist/generator/generate-project.d.ts +14 -0
- package/dist/generator/generate-project.js +81 -0
- package/dist/generator/index.d.ts +4 -0
- package/dist/generator/index.js +3 -0
- package/dist/generator/replace-tokens.d.ts +29 -0
- package/dist/generator/replace-tokens.js +68 -0
- package/dist/github/secrets.d.ts +109 -0
- package/dist/github/secrets.js +275 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/prompts/auth.d.ts +3 -0
- package/dist/prompts/auth.js +23 -0
- package/dist/prompts/aws-config.d.ts +2 -0
- package/dist/prompts/aws-config.js +14 -0
- package/dist/prompts/features.d.ts +2 -0
- package/dist/prompts/features.js +10 -0
- package/dist/prompts/github-setup.d.ts +53 -0
- package/dist/prompts/github-setup.js +208 -0
- package/dist/prompts/org-structure.d.ts +9 -0
- package/dist/prompts/org-structure.js +93 -0
- package/dist/prompts/platforms.d.ts +2 -0
- package/dist/prompts/platforms.js +12 -0
- package/dist/prompts/project-name.d.ts +2 -0
- package/dist/prompts/project-name.js +8 -0
- package/dist/prompts/theme.d.ts +2 -0
- package/dist/prompts/theme.js +14 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/index.js +2 -0
- package/dist/templates/manifest.d.ts +11 -0
- package/dist/templates/manifest.js +99 -0
- package/dist/templates/tokens.d.ts +39 -0
- package/dist/templates/tokens.js +37 -0
- package/dist/templates/types.d.ts +52 -0
- package/dist/templates/types.js +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.js +1 -0
- package/dist/validation/project-name.d.ts +1 -0
- package/dist/validation/project-name.js +12 -0
- package/dist/wizard.d.ts +2 -0
- package/dist/wizard.js +81 -0
- package/package.json +68 -0
- package/templates/.github/actions/build-and-test/action.yml +24 -0
- package/templates/.github/actions/deploy-cdk/action.yml +46 -0
- package/templates/.github/actions/deploy-web/action.yml +72 -0
- package/templates/.github/actions/setup/action.yml +29 -0
- package/templates/.github/pull_request_template.md +15 -0
- package/templates/.github/workflows/deploy-dev.yml +80 -0
- package/templates/.github/workflows/deploy-prod.yml +67 -0
- package/templates/.github/workflows/deploy-stage.yml +77 -0
- package/templates/.github/workflows/pull-request.yml +72 -0
- package/templates/.vscode/extensions.json +7 -0
- package/templates/.vscode/settings.json +67 -0
- package/templates/apps/api/.eslintrc.json +18 -0
- package/templates/apps/api/cdk/app.ts +93 -0
- package/templates/apps/api/cdk/auth/cognito-stack.ts +164 -0
- package/templates/apps/api/cdk/cdk.json +73 -0
- package/templates/apps/api/cdk/deployment-user-stack.ts +187 -0
- package/templates/apps/api/cdk/org-stack.ts +67 -0
- package/templates/apps/api/cdk/static-stack.ts +361 -0
- package/templates/apps/api/cdk/tsconfig.json +39 -0
- package/templates/apps/api/cdk/user-stack.ts +255 -0
- package/templates/apps/api/jest.config.ts +38 -0
- package/templates/apps/api/lambdas.yml +84 -0
- package/templates/apps/api/project.json.template +58 -0
- package/templates/apps/api/src/__tests__/setup.ts +10 -0
- package/templates/apps/api/src/handlers/users/create-user.ts +52 -0
- package/templates/apps/api/src/handlers/users/delete-user.ts +45 -0
- package/templates/apps/api/src/handlers/users/get-me.ts +72 -0
- package/templates/apps/api/src/handlers/users/get-user.ts +45 -0
- package/templates/apps/api/src/handlers/users/get-users.ts +23 -0
- package/templates/apps/api/src/handlers/users/index.ts +17 -0
- package/templates/apps/api/src/handlers/users/update-user.ts +72 -0
- package/templates/apps/api/src/lib/dynamo/dynamo-model.ts +504 -0
- package/templates/apps/api/src/lib/dynamo/index.ts +12 -0
- package/templates/apps/api/src/lib/dynamo/utils.ts +39 -0
- package/templates/apps/api/src/middleware/auth0-auth.ts +97 -0
- package/templates/apps/api/src/middleware/cognito-auth.ts +90 -0
- package/templates/apps/api/src/models/UserModel.ts +109 -0
- package/templates/apps/api/src/schemas/user.schema.ts +44 -0
- package/templates/apps/api/src/services/user-service.ts +108 -0
- package/templates/apps/api/src/utils/auth-context.ts +60 -0
- package/templates/apps/api/src/utils/common/helpers.ts +26 -0
- package/templates/apps/api/src/utils/lambda-handler.ts +148 -0
- package/templates/apps/api/src/utils/response.ts +52 -0
- package/templates/apps/api/src/utils/validator.ts +75 -0
- package/templates/apps/api/tsconfig.app.json +15 -0
- package/templates/apps/api/tsconfig.json +19 -0
- package/templates/apps/api/tsconfig.spec.json +17 -0
- package/templates/apps/mobile/.env.example +5 -0
- package/templates/apps/mobile/.eslintrc.json +33 -0
- package/templates/apps/mobile/app.json +33 -0
- package/templates/apps/mobile/assets/.gitkeep +0 -0
- package/templates/apps/mobile/babel.config.js +19 -0
- package/templates/apps/mobile/index.js +7 -0
- package/templates/apps/mobile/jest.config.ts +22 -0
- package/templates/apps/mobile/metro.config.js +35 -0
- package/templates/apps/mobile/package.json +22 -0
- package/templates/apps/mobile/project.json.template +64 -0
- package/templates/apps/mobile/src/App.tsx +367 -0
- package/templates/apps/mobile/src/__tests__/App.spec.tsx +46 -0
- package/templates/apps/mobile/src/__tests__/store/user-store.spec.ts +156 -0
- package/templates/apps/mobile/src/config/api.ts +16 -0
- package/templates/apps/mobile/src/store/user-store.ts +56 -0
- package/templates/apps/mobile/src/test-setup.ts +10 -0
- package/templates/apps/mobile/tsconfig.json +22 -0
- package/templates/apps/web/.env.example +13 -0
- package/templates/apps/web/.eslintrc.json +26 -0
- package/templates/apps/web/index.html +13 -0
- package/templates/apps/web/jest.config.ts +24 -0
- package/templates/apps/web/package.json +15 -0
- package/templates/apps/web/project.json.template +66 -0
- package/templates/apps/web/src/App.tsx +352 -0
- package/templates/apps/web/src/__mocks__/config/api.ts +41 -0
- package/templates/apps/web/src/__tests__/App.spec.tsx +240 -0
- package/templates/apps/web/src/__tests__/store/user-store.spec.ts +185 -0
- package/templates/apps/web/src/auth/auth0-provider.tsx +103 -0
- package/templates/apps/web/src/auth/cognito-provider.tsx +143 -0
- package/templates/apps/web/src/auth/index.ts +7 -0
- package/templates/apps/web/src/auth/use-auth.ts +16 -0
- package/templates/apps/web/src/config/amplify-config.ts +31 -0
- package/templates/apps/web/src/config/api.ts +38 -0
- package/templates/apps/web/src/config/auth0-config.ts +17 -0
- package/templates/apps/web/src/main.tsx +41 -0
- package/templates/apps/web/src/store/user-store.ts +56 -0
- package/templates/apps/web/src/styles.css +165 -0
- package/templates/apps/web/src/test-setup.ts +1 -0
- package/templates/apps/web/src/theme/index.ts +30 -0
- package/templates/apps/web/src/vite-env.d.ts +19 -0
- package/templates/apps/web/tsconfig.app.json +24 -0
- package/templates/apps/web/tsconfig.json +22 -0
- package/templates/apps/web/tsconfig.spec.json +28 -0
- package/templates/apps/web/vite.config.ts +87 -0
- package/templates/manifest.json +28 -0
- package/templates/packages/api-client/.eslintrc.json +18 -0
- package/templates/packages/api-client/jest.config.ts +13 -0
- package/templates/packages/api-client/package.json +8 -0
- package/templates/packages/api-client/project.json.template +34 -0
- package/templates/packages/api-client/src/__tests__/api-client.spec.ts +408 -0
- package/templates/packages/api-client/src/api-client.ts +201 -0
- package/templates/packages/api-client/src/config.ts +193 -0
- package/templates/packages/api-client/src/index.ts +9 -0
- package/templates/packages/api-client/tsconfig.json +22 -0
- package/templates/packages/api-client/tsconfig.lib.json +11 -0
- package/templates/packages/api-client/tsconfig.spec.json +14 -0
- package/templates/packages/common-types/.eslintrc.json +18 -0
- package/templates/packages/common-types/package.json +6 -0
- package/templates/packages/common-types/project.json.template +26 -0
- package/templates/packages/common-types/src/api.types.ts +24 -0
- package/templates/packages/common-types/src/auth.types.ts +36 -0
- package/templates/packages/common-types/src/common.types.ts +46 -0
- package/templates/packages/common-types/src/index.ts +19 -0
- package/templates/packages/common-types/src/lambda.types.ts +39 -0
- package/templates/packages/common-types/src/user.types.ts +31 -0
- package/templates/packages/common-types/tsconfig.json +19 -0
- package/templates/packages/common-types/tsconfig.lib.json +11 -0
- package/templates/root/.editorconfig +23 -0
- package/templates/root/.nvmrc +1 -0
- package/templates/root/eslint.config.js +61 -0
- package/templates/root/jest.preset.js +16 -0
- package/templates/root/nx.json +29 -0
- package/templates/root/package.json +131 -0
- package/templates/root/tsconfig.base.json +29 -0
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Client Configuration Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides environment-aware configuration for the API client.
|
|
5
|
+
* Works across different environments (web, mobile, Node.js)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ApiClientConfig } from './api-client';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Environment-specific configuration options
|
|
12
|
+
*/
|
|
13
|
+
export interface EnvironmentConfig {
|
|
14
|
+
/**
|
|
15
|
+
* API base URL (e.g., 'https://api.example.com')
|
|
16
|
+
*/
|
|
17
|
+
apiBaseUrl?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Request timeout in milliseconds
|
|
21
|
+
*/
|
|
22
|
+
apiTimeout?: string | number;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* API key or token for authentication
|
|
26
|
+
*/
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether to send credentials (cookies) with requests
|
|
31
|
+
*/
|
|
32
|
+
apiWithCredentials?: string | boolean;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Enable debug logging
|
|
36
|
+
*/
|
|
37
|
+
apiDebug?: string | boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Default configuration values
|
|
42
|
+
*/
|
|
43
|
+
const DEFAULT_CONFIG = {
|
|
44
|
+
baseURL: 'http://localhost:3000',
|
|
45
|
+
timeout: 30000,
|
|
46
|
+
withCredentials: false,
|
|
47
|
+
debug: false,
|
|
48
|
+
} as const;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Convert string values to appropriate types
|
|
52
|
+
*/
|
|
53
|
+
function parseValue<T>(value: string | T | undefined, defaultValue: T): T {
|
|
54
|
+
if (value === undefined) return defaultValue;
|
|
55
|
+
if (typeof value !== 'string') return value;
|
|
56
|
+
|
|
57
|
+
// Handle boolean strings
|
|
58
|
+
if (typeof defaultValue === 'boolean') {
|
|
59
|
+
return (value.toLowerCase() === 'true') as T;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Handle number strings
|
|
63
|
+
if (typeof defaultValue === 'number') {
|
|
64
|
+
const parsed = parseInt(value, 10);
|
|
65
|
+
return (isNaN(parsed) ? defaultValue : parsed) as T;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return value as T;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get environment variable value
|
|
73
|
+
*
|
|
74
|
+
* Supports multiple environment variable naming conventions:
|
|
75
|
+
* - Vite: VITE_API_BASE_URL
|
|
76
|
+
* - Expo: EXPO_PUBLIC_API_BASE_URL
|
|
77
|
+
* - Node.js: API_BASE_URL
|
|
78
|
+
*/
|
|
79
|
+
function getEnvVar(name: string): string | undefined {
|
|
80
|
+
// Check Node.js process.env (works for both Node.js and React Native/Expo)
|
|
81
|
+
if (typeof process !== 'undefined' && process.env) {
|
|
82
|
+
// Try EXPO_PUBLIC_ prefix first (for React Native/Expo)
|
|
83
|
+
const expoVar = process.env[`EXPO_PUBLIC_${name}`] as string | undefined;
|
|
84
|
+
if (expoVar) return expoVar;
|
|
85
|
+
|
|
86
|
+
// Try VITE_ prefix (for Vite)
|
|
87
|
+
const viteVar = process.env[`VITE_${name}`] as string | undefined;
|
|
88
|
+
if (viteVar) return viteVar;
|
|
89
|
+
|
|
90
|
+
// Try regular name (for Node.js)
|
|
91
|
+
const nodeVar = process.env[name] as string | undefined;
|
|
92
|
+
if (nodeVar) return nodeVar;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Create API client configuration from environment variables
|
|
100
|
+
*
|
|
101
|
+
* Environment variable mapping:
|
|
102
|
+
* - VITE_API_BASE_URL / EXPO_PUBLIC_API_BASE_URL / API_BASE_URL
|
|
103
|
+
* - VITE_API_TIMEOUT / EXPO_PUBLIC_API_TIMEOUT / API_TIMEOUT
|
|
104
|
+
* - VITE_API_KEY / EXPO_PUBLIC_API_KEY / API_KEY
|
|
105
|
+
* - VITE_API_WITH_CREDENTIALS / EXPO_PUBLIC_API_WITH_CREDENTIALS / API_WITH_CREDENTIALS
|
|
106
|
+
* - VITE_API_DEBUG / EXPO_PUBLIC_API_DEBUG / API_DEBUG
|
|
107
|
+
*
|
|
108
|
+
* @param overrides - Optional configuration overrides
|
|
109
|
+
* @returns API client configuration
|
|
110
|
+
*/
|
|
111
|
+
export function createConfigFromEnv(overrides?: Partial<ApiClientConfig>): ApiClientConfig {
|
|
112
|
+
const baseURL = getEnvVar('API_BASE_URL') || DEFAULT_CONFIG.baseURL;
|
|
113
|
+
const timeout = parseValue(getEnvVar('API_TIMEOUT'), DEFAULT_CONFIG.timeout);
|
|
114
|
+
const withCredentials = parseValue(getEnvVar('API_WITH_CREDENTIALS'), DEFAULT_CONFIG.withCredentials);
|
|
115
|
+
const apiKey = getEnvVar('API_KEY');
|
|
116
|
+
const debug = parseValue(getEnvVar('API_DEBUG'), DEFAULT_CONFIG.debug);
|
|
117
|
+
|
|
118
|
+
// Build headers
|
|
119
|
+
const headers: Record<string, string> = {};
|
|
120
|
+
if (apiKey) {
|
|
121
|
+
headers['Authorization'] = `Bearer ${apiKey}`;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Log configuration in debug mode
|
|
125
|
+
if (debug) {
|
|
126
|
+
console.log('[API Client] Configuration:', {
|
|
127
|
+
baseURL,
|
|
128
|
+
timeout,
|
|
129
|
+
withCredentials,
|
|
130
|
+
hasApiKey: !!apiKey,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
baseURL,
|
|
136
|
+
timeout,
|
|
137
|
+
withCredentials,
|
|
138
|
+
headers,
|
|
139
|
+
...overrides,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get default API base URL based on environment
|
|
145
|
+
*
|
|
146
|
+
* Auto-detects the appropriate URL:
|
|
147
|
+
* - In production (web): Uses window.location.origin
|
|
148
|
+
* - In development (web): Uses localhost:3000
|
|
149
|
+
* - With env var: Uses provided URL
|
|
150
|
+
*
|
|
151
|
+
* @returns The base URL for API requests
|
|
152
|
+
*/
|
|
153
|
+
export function getDefaultBaseURL(): string {
|
|
154
|
+
// Check for explicit environment variable
|
|
155
|
+
const envUrl = getEnvVar('API_BASE_URL');
|
|
156
|
+
if (envUrl) return envUrl;
|
|
157
|
+
|
|
158
|
+
// In browser, check if we're in production
|
|
159
|
+
if (typeof window !== 'undefined') {
|
|
160
|
+
const origin = window.location.origin;
|
|
161
|
+
|
|
162
|
+
// If running on localhost, assume API is on port 3000
|
|
163
|
+
if (origin.includes('localhost') || origin.includes('127.0.0.1')) {
|
|
164
|
+
return 'http://localhost:3000';
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// In production, API is at same origin (CloudFront setup)
|
|
168
|
+
return origin;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Default fallback
|
|
172
|
+
return DEFAULT_CONFIG.baseURL;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Create API client configuration with smart defaults
|
|
177
|
+
*
|
|
178
|
+
* @param overrides - Optional configuration overrides
|
|
179
|
+
* @returns API client configuration
|
|
180
|
+
*/
|
|
181
|
+
export function createConfig(overrides?: Partial<ApiClientConfig>): ApiClientConfig {
|
|
182
|
+
const baseURL = overrides?.baseURL || getDefaultBaseURL();
|
|
183
|
+
|
|
184
|
+
return createConfigFromEnv({
|
|
185
|
+
...overrides,
|
|
186
|
+
baseURL,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Export default configuration values for reference
|
|
192
|
+
*/
|
|
193
|
+
export const DEFAULT_API_CONFIG = DEFAULT_CONFIG;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ApiClient, createApiClient, ApiError } from './api-client';
|
|
2
|
+
export type { ApiClientConfig } from './api-client';
|
|
3
|
+
export {
|
|
4
|
+
createConfig,
|
|
5
|
+
createConfigFromEnv,
|
|
6
|
+
getDefaultBaseURL,
|
|
7
|
+
DEFAULT_API_CONFIG
|
|
8
|
+
} from './config';
|
|
9
|
+
export type { EnvironmentConfig } from './config';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true
|
|
11
|
+
},
|
|
12
|
+
"files": [],
|
|
13
|
+
"include": [],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.lib.json"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "./tsconfig.spec.json"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"types": ["node"],
|
|
7
|
+
"moduleResolution": "node"
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*.ts"],
|
|
10
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../dist/out-tsc",
|
|
5
|
+
"module": "commonjs",
|
|
6
|
+
"types": ["jest", "node"]
|
|
7
|
+
},
|
|
8
|
+
"include": [
|
|
9
|
+
"jest.config.ts",
|
|
10
|
+
"src/**/*.test.ts",
|
|
11
|
+
"src/**/*.spec.ts",
|
|
12
|
+
"src/**/*.d.ts"
|
|
13
|
+
]
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": ["../../.eslintrc.js"],
|
|
3
|
+
"ignorePatterns": ["!**/*"],
|
|
4
|
+
"overrides": [
|
|
5
|
+
{
|
|
6
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
7
|
+
"rules": {}
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"files": ["*.ts", "*.tsx"],
|
|
11
|
+
"rules": {}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"files": ["*.js", "*.jsx"],
|
|
15
|
+
"rules": {}
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "common-types",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/common-types/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": ["type:lib"],
|
|
7
|
+
"targets": {
|
|
8
|
+
"lint": {
|
|
9
|
+
"executor": "@nx/eslint:lint",
|
|
10
|
+
"outputs": ["{options.outputFile}"],
|
|
11
|
+
"options": {
|
|
12
|
+
"lintFilePatterns": ["packages/common-types/**/*.ts"]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"build": {
|
|
16
|
+
"executor": "@nx/js:tsc",
|
|
17
|
+
"outputs": ["{options.outputPath}"],
|
|
18
|
+
"options": {
|
|
19
|
+
"outputPath": "dist/packages/common-types",
|
|
20
|
+
"main": "packages/common-types/src/index.ts",
|
|
21
|
+
"tsConfig": "packages/common-types/tsconfig.lib.json",
|
|
22
|
+
"assets": ["packages/common-types/*.md"]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Response Types
|
|
3
|
+
*
|
|
4
|
+
* Standard response structures for API endpoints
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Standard API response wrapper
|
|
9
|
+
*/
|
|
10
|
+
export interface ApiResponse<T = unknown> {
|
|
11
|
+
success: boolean;
|
|
12
|
+
data?: T;
|
|
13
|
+
error?: ApiError;
|
|
14
|
+
message?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Error details structure
|
|
19
|
+
*/
|
|
20
|
+
export interface ApiError {
|
|
21
|
+
code: string;
|
|
22
|
+
message: string;
|
|
23
|
+
details?: Record<string, unknown>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authenticated user information
|
|
3
|
+
*/
|
|
4
|
+
export interface AuthUser {
|
|
5
|
+
id: string; // Cognito sub
|
|
6
|
+
email: string;
|
|
7
|
+
emailVerified: boolean;
|
|
8
|
+
groups?: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Auth state for UI consumption
|
|
13
|
+
*/
|
|
14
|
+
export interface AuthState {
|
|
15
|
+
user: AuthUser | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
isAuthenticated: boolean;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Auth context actions
|
|
23
|
+
*/
|
|
24
|
+
export interface AuthActions {
|
|
25
|
+
signIn: (email: string, password: string) => Promise<void>;
|
|
26
|
+
signUp: (email: string, password: string) => Promise<void>;
|
|
27
|
+
signOut: () => Promise<void>;
|
|
28
|
+
confirmSignUp: (email: string, code: string) => Promise<void>;
|
|
29
|
+
forgotPassword: (email: string) => Promise<void>;
|
|
30
|
+
confirmForgotPassword: (email: string, code: string, newPassword: string) => Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Complete auth context type
|
|
35
|
+
*/
|
|
36
|
+
export type AuthContextType = AuthState & AuthActions;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common Types and Constants
|
|
3
|
+
*
|
|
4
|
+
* Shared utility types and constant values used across the application
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Utility Types
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Makes a type nullable (can be T or null)
|
|
13
|
+
*/
|
|
14
|
+
export type Nullable<T> = T | null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Makes a type optional (can be T or undefined)
|
|
18
|
+
*/
|
|
19
|
+
export type Optional<T> = T | undefined;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Constants
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* HTTP status codes
|
|
27
|
+
*/
|
|
28
|
+
export const HTTP_STATUS = {
|
|
29
|
+
OK: 200,
|
|
30
|
+
CREATED: 201,
|
|
31
|
+
BAD_REQUEST: 400,
|
|
32
|
+
UNAUTHORIZED: 401,
|
|
33
|
+
FORBIDDEN: 403,
|
|
34
|
+
NOT_FOUND: 404,
|
|
35
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
36
|
+
} as const;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Application error codes
|
|
40
|
+
*/
|
|
41
|
+
export const ERROR_CODES = {
|
|
42
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR',
|
|
43
|
+
NOT_FOUND: 'NOT_FOUND',
|
|
44
|
+
UNAUTHORIZED: 'UNAUTHORIZED',
|
|
45
|
+
INTERNAL_ERROR: 'INTERNAL_ERROR',
|
|
46
|
+
} as const;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* {{PACKAGE_SCOPE}}/common-types
|
|
3
|
+
*
|
|
4
|
+
* Shared TypeScript types for the monorepo
|
|
5
|
+
*
|
|
6
|
+
* This package provides common types used across frontend and backend:
|
|
7
|
+
* - User types and API requests
|
|
8
|
+
* - API response structures
|
|
9
|
+
* - AWS Lambda event/context types
|
|
10
|
+
* - Common utilities and constants
|
|
11
|
+
* - Authentication types (Cognito/Auth0)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Re-export all types for convenience
|
|
15
|
+
export * from './user.types';
|
|
16
|
+
export * from './api.types';
|
|
17
|
+
export * from './lambda.types';
|
|
18
|
+
export * from './common.types';
|
|
19
|
+
export * from './auth.types';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Lambda Types
|
|
3
|
+
*
|
|
4
|
+
* Types for AWS Lambda events, contexts, and responses
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* AWS Lambda execution context
|
|
9
|
+
*/
|
|
10
|
+
export interface LambdaContext {
|
|
11
|
+
requestId: string;
|
|
12
|
+
functionName: string;
|
|
13
|
+
functionVersion: string;
|
|
14
|
+
memoryLimitInMB: string;
|
|
15
|
+
logGroupName: string;
|
|
16
|
+
logStreamName: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* API Gateway proxy event structure
|
|
21
|
+
*/
|
|
22
|
+
export interface ApiGatewayProxyEvent {
|
|
23
|
+
httpMethod: string;
|
|
24
|
+
path: string;
|
|
25
|
+
pathParameters: Record<string, string> | null;
|
|
26
|
+
queryStringParameters: Record<string, string> | null;
|
|
27
|
+
headers: Record<string, string>;
|
|
28
|
+
body: string | null;
|
|
29
|
+
isBase64Encoded: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* API Gateway proxy response structure
|
|
34
|
+
*/
|
|
35
|
+
export interface ApiGatewayProxyResult {
|
|
36
|
+
statusCode: number;
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
body: string;
|
|
39
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Domain Types
|
|
3
|
+
*
|
|
4
|
+
* Contains all user-related types and interfaces
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* User entity
|
|
9
|
+
*/
|
|
10
|
+
export interface User {
|
|
11
|
+
id: string;
|
|
12
|
+
email: string;
|
|
13
|
+
name: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
updatedAt?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Request body for creating a new user
|
|
20
|
+
*/
|
|
21
|
+
export interface CreateUserRequest {
|
|
22
|
+
email: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Request body for updating an existing user
|
|
28
|
+
*/
|
|
29
|
+
export interface UpdateUserRequest {
|
|
30
|
+
name?: string;
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true
|
|
11
|
+
},
|
|
12
|
+
"files": [],
|
|
13
|
+
"include": [],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.lib.json"
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# EditorConfig helps maintain consistent coding styles
|
|
2
|
+
# for multiple developers working on the same project
|
|
3
|
+
# across various editors and IDEs
|
|
4
|
+
# https://editorconfig.org
|
|
5
|
+
|
|
6
|
+
root = true
|
|
7
|
+
|
|
8
|
+
[*]
|
|
9
|
+
charset = utf-8
|
|
10
|
+
end_of_line = lf
|
|
11
|
+
insert_final_newline = true
|
|
12
|
+
trim_trailing_whitespace = true
|
|
13
|
+
indent_style = space
|
|
14
|
+
indent_size = 2
|
|
15
|
+
|
|
16
|
+
[*.md]
|
|
17
|
+
trim_trailing_whitespace = false
|
|
18
|
+
|
|
19
|
+
[*.{yml,yaml}]
|
|
20
|
+
indent_size = 2
|
|
21
|
+
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.16.0
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const {
|
|
2
|
+
defineConfig,
|
|
3
|
+
globalIgnores,
|
|
4
|
+
} = require("eslint/config");
|
|
5
|
+
|
|
6
|
+
const nx = require("@nx/eslint-plugin");
|
|
7
|
+
const js = require("@eslint/js");
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
FlatCompat,
|
|
11
|
+
} = require("@eslint/eslintrc");
|
|
12
|
+
|
|
13
|
+
const compat = new FlatCompat({
|
|
14
|
+
baseDirectory: __dirname,
|
|
15
|
+
recommendedConfig: js.configs.recommended,
|
|
16
|
+
allConfig: js.configs.all
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
module.exports = defineConfig([{
|
|
20
|
+
plugins: {
|
|
21
|
+
"@nx": nx,
|
|
22
|
+
},
|
|
23
|
+
}, globalIgnores([
|
|
24
|
+
"**/node_modules/**",
|
|
25
|
+
"**/dist/**",
|
|
26
|
+
"**/build/**",
|
|
27
|
+
"**/coverage/**",
|
|
28
|
+
"**/.nx/**",
|
|
29
|
+
"**/cdk.out/**",
|
|
30
|
+
"**/tmp/**"
|
|
31
|
+
]), {
|
|
32
|
+
files: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
|
|
33
|
+
|
|
34
|
+
rules: {
|
|
35
|
+
"@nx/enforce-module-boundaries": ["error", {
|
|
36
|
+
enforceBuildableLibDependency: true,
|
|
37
|
+
allow: [],
|
|
38
|
+
|
|
39
|
+
depConstraints: [{
|
|
40
|
+
sourceTag: "*",
|
|
41
|
+
onlyDependOnLibsWithTags: ["*"],
|
|
42
|
+
}],
|
|
43
|
+
}],
|
|
44
|
+
},
|
|
45
|
+
}, {
|
|
46
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
47
|
+
extends: compat.extends("plugin:@nx/typescript"),
|
|
48
|
+
|
|
49
|
+
rules: {
|
|
50
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
51
|
+
|
|
52
|
+
"@typescript-eslint/no-unused-vars": ["warn", {
|
|
53
|
+
argsIgnorePattern: "^_",
|
|
54
|
+
varsIgnorePattern: "^_",
|
|
55
|
+
}],
|
|
56
|
+
},
|
|
57
|
+
}, {
|
|
58
|
+
files: ["**/*.js", "**/*.jsx"],
|
|
59
|
+
extends: compat.extends("plugin:@nx/javascript"),
|
|
60
|
+
rules: {},
|
|
61
|
+
}]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const nxPreset = require('@nx/jest/preset').default;
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
...nxPreset,
|
|
5
|
+
testMatch: ['**/+(*.)+(spec|test).+(ts|js|tsx|jsx)'],
|
|
6
|
+
transform: {
|
|
7
|
+
'^.+\\.(ts|tsx|js|jsx)$': [
|
|
8
|
+
'ts-jest',
|
|
9
|
+
{
|
|
10
|
+
tsconfig: '<rootDir>/tsconfig.spec.json',
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
|
|
15
|
+
coverageReporters: ['html', 'text', 'json', 'json-summary'],
|
|
16
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/nx/schemas/nx-schema.json",
|
|
3
|
+
"affected": {
|
|
4
|
+
"defaultBase": "main"
|
|
5
|
+
},
|
|
6
|
+
"targetDefaults": {
|
|
7
|
+
"build": {
|
|
8
|
+
"cache": true,
|
|
9
|
+
"dependsOn": ["^build"]
|
|
10
|
+
},
|
|
11
|
+
"lint": {
|
|
12
|
+
"cache": true
|
|
13
|
+
},
|
|
14
|
+
"test": {
|
|
15
|
+
"cache": true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"defaultProject": "web",
|
|
19
|
+
"namedInputs": {
|
|
20
|
+
"default": ["{projectRoot}/**/*", "sharedGlobals"],
|
|
21
|
+
"production": [
|
|
22
|
+
"default",
|
|
23
|
+
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
|
|
24
|
+
"!{projectRoot}/tsconfig.spec.json",
|
|
25
|
+
"!{projectRoot}/.eslintrc.json"
|
|
26
|
+
],
|
|
27
|
+
"sharedGlobals": []
|
|
28
|
+
}
|
|
29
|
+
}
|