-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
158d8e8
commit 2b9dc0f
Showing
36 changed files
with
20,612 additions
and
7,663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
/// <reference types="vite/client" /> | ||
/// <reference types="vite-plugin-pages/client" /> | ||
|
||
import { | ||
SendMessagesCommandOutput, | ||
UpdateEndpointCommandOutput | ||
} from '@aws-sdk/client-pinpoint' | ||
|
||
declare module '*.vue' { | ||
import type { DefineComponent } from 'vue' | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types | ||
const component: DefineComponent<{}, {}, any> | ||
export default component | ||
} | ||
|
||
declare type SignupResponse = { | ||
headers?: any | ||
statusCode: number | ||
body: [UpdateEndpointCommandOutput, SendMessagesCommandOutput] | Error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Converts any string to PascalCase. | ||
* | ||
* @param str - The input string | ||
* @returns A PascalCase string from the input string | ||
* | ||
*/ | ||
export function pascalCase(str: string): string { | ||
return str.replace(/\w+/g, (word) => { | ||
return word[0].toUpperCase() + word.slice(1).toLowerCase() | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@casimir/lib", | ||
"private": true, | ||
"main": "index.ts", | ||
"scripts": { | ||
"dev": "npx esno index.ts", | ||
"build": "esbuild index.ts --bundle --minify --sourcemap --platform=node --target=es2020 --outfile=dist/index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^17.0.38", | ||
"esbuild": "^0.14.42", | ||
"esno": "^0.16.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "commonjs", | ||
"lib": [ | ||
"es2018" | ||
], | ||
"declaration": true, | ||
"strict": true, | ||
"noImplicitAny": true, | ||
"strictNullChecks": true, | ||
"noImplicitThis": true, | ||
"alwaysStrict": true, | ||
"noUnusedLocals": false, | ||
"noUnusedParameters": false, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": false, | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"experimentalDecorators": true, | ||
"strictPropertyInitialization": false, | ||
"typeRoots": [ | ||
"./node_modules/@types" | ||
], | ||
"outDir": "dist" | ||
}, | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*.js | ||
!jest.config.js | ||
*.d.ts | ||
node_modules | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out | ||
cdk.context.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
*.ts | ||
!*.d.ts | ||
|
||
# CDK asset staging directory | ||
.cdk.staging | ||
cdk.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Welcome to your CDK TypeScript project | ||
|
||
This is a blank project for TypeScript development with CDK. | ||
|
||
The `cdk.json` file tells the CDK Toolkit how to execute your app. | ||
|
||
## Useful commands | ||
|
||
* `npm run build` compile typescript to js | ||
* `npm run watch` watch for changes and compile | ||
* `npm run test` perform the jest unit tests | ||
* `cdk deploy` deploy this stack to your default AWS account/region | ||
* `cdk diff` compare deployed stack with current state | ||
* `cdk synth` emits the synthesized CloudFormation template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env node | ||
import 'source-map-support/register' | ||
import * as cdk from 'aws-cdk-lib' | ||
import { WebsiteStack } from '../lib/website/website-stack' | ||
import { UsersStack } from '../lib/users/users-stack' | ||
|
||
const project = process.env.PROJECT?.replace(/\b\w/g, c => c.toUpperCase()) | ||
const stage = process.env.STAGE?.replace(/\b\w/g, c => c.toUpperCase()) | ||
|
||
const app = new cdk.App() | ||
new WebsiteStack(app, `${project}WebsiteStack${stage}`) | ||
new UsersStack(app, `${project}UsersStack${stage}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"app": "npx esno bin/index.ts", | ||
"watch": { | ||
"include": [ | ||
"**" | ||
], | ||
"exclude": [ | ||
"README.md", | ||
"cdk*.json", | ||
"**/*.d.ts", | ||
"**/*.js", | ||
"tsconfig.json", | ||
"package*.json", | ||
"yarn.lock", | ||
"node_modules", | ||
"test" | ||
] | ||
}, | ||
"context": { | ||
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true, | ||
"@aws-cdk/core:stackRelativeExports": true, | ||
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true, | ||
"@aws-cdk/aws-lambda:recognizeVersionProps": true, | ||
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true, | ||
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true, | ||
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true, | ||
"@aws-cdk/aws-iam:minimizePolicies": true, | ||
"@aws-cdk/core:target-partitions": [ | ||
"aws", | ||
"aws-cn" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
roots: ['<rootDir>/test'], | ||
testMatch: ['**/*.test.ts'], | ||
transform: { | ||
'^.+\\.tsx?$': 'ts-jest' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { Stack, StackProps } from 'aws-cdk-lib' | ||
import { Construct } from 'constructs' | ||
import * as awspinpoint from 'aws-cdk-lib/aws-pinpoint' | ||
import * as apigateway from 'aws-cdk-lib/aws-apigateway' | ||
import * as lambda from 'aws-cdk-lib/aws-lambda' | ||
|
||
/** | ||
* Class representing the users stack. | ||
* | ||
* Shortest name: {@link UsersStack} | ||
* Full name: {@link (UsersStack:class)} | ||
*/ | ||
export class UsersStack extends Stack { | ||
|
||
/** | ||
* UsersStack class constructor. | ||
* | ||
* Shortest name: {@link (UsersStack:constructor)} | ||
* Full name: {@link (UsersStack:constructor)} | ||
*/ | ||
constructor(scope: Construct, id: string, props?: StackProps) { | ||
|
||
/** | ||
* UsersStack class constructor super method. | ||
* | ||
* Shortest name: {@link (UsersStack:constructor:super)} | ||
* Full name: {@link (UsersStack:constructor:super)} | ||
*/ | ||
super(scope, id, props) | ||
|
||
const project = process.env.PROJECT?.replace(/\b\w/g, c => c.toUpperCase()) | ||
const stage = process.env.STAGE?.replace(/\b\w/g, c => c.toUpperCase()) | ||
const service = 'Users' | ||
|
||
const pinpointApp = new awspinpoint.CfnApp(this, `${project}${service}PinpointApp${stage}`, { | ||
name: `${project}${service}PinpointApp${stage}` | ||
}) | ||
|
||
// Todo set path alias for services | ||
const lambdaHandler = new lambda.Function(this, `${project}${service}Api${stage}`, { | ||
runtime: lambda.Runtime.NODEJS_14_X, | ||
handler: 'index.handler', | ||
code: lambda.Code.fromAsset('../../services/users/dist'), | ||
environment: { | ||
APP_ID: pinpointApp.ref, | ||
SOURCE_EMAIL: 'team@casimir.co', | ||
PROJECT: process.env.PROJECT as string, | ||
STAGE: process.env.STAGE as string | ||
} | ||
}) | ||
|
||
// Todo update to use new api gateway version when stable | ||
// https://docs.aws.amazon.com/cdk/api/v2/docs/aws-apigateway-readme.html#apigateway-v2 | ||
new apigateway.LambdaRestApi(this, `${project}${service}ApiGateway${stage}`, { | ||
restApiName: `${project}${service}UsersApiGateway${stage}`, | ||
handler: lambdaHandler, | ||
// Todo restrict cors | ||
defaultCorsPreflightOptions: { | ||
allowOrigins: apigateway.Cors.ALL_ORIGINS, | ||
allowMethods: apigateway.Cors.ALL_METHODS | ||
} | ||
}) | ||
|
||
} | ||
} |
Oops, something went wrong.