Skip to content

Commit

Permalink
Add email service
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Jun 10, 2022
1 parent 158d8e8 commit 2b9dc0f
Show file tree
Hide file tree
Showing 36 changed files with 20,612 additions and 7,663 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

# Skip any pushes with commit flag '(skip deploy)'
# Comment out for testing
if: ${{ !contains(github.event.head_commit.message, '(skip deploy)') }}
# if: ${{ !contains(github.event.head_commit.message, '(skip deploy)') }}

steps:
- name: Check out the repo
Expand All @@ -33,13 +33,13 @@ jobs:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Build and deploy email templates
run: npm run deploy:templates

- name: Build and deploy stacks
run: npm run deploy

- name: Build and deploy email templates
run: npm run deploy:templates

- name: Set deployment outputs
run: |
export "STACK_KEY=${PROJECT^}${SERVICE^}Stack${STAGE^}"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}

- name: Build and deploy email templates
run: npm run deploy:templates

- name: Build and deploy website
run: npm run deploy

- name: Build and deploy email templates
run: npm run deploy:templates

- name: Sync released version files to develop
if: ${{ github.actor != 'nektos/act' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"preview": "vite preview"
},
"dependencies": {
"@heroicons/vue": "^1.0.6",
"vue": "^3.2.25",
"vue-router": "^4.0.15"
},
Expand Down
11 changes: 11 additions & 0 deletions apps/website/src/env.d.ts
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
}
14 changes: 7 additions & 7 deletions apps/website/src/pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
<div class="basis-1/2">
<div class="linear-bg w-full h-full pt-[30%] pl-[30%]">
<img
src="web-demo.svg"
src="/web-demo.svg"
alt=""
class="float-right h-[100%]"
>
Expand All @@ -53,7 +53,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="cosmos.svg"
src="/cosmos.svg"
alt=""
class="h-[25px]"
>
Expand All @@ -63,7 +63,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="iotex.svg"
src="/iotex.svg"
alt=""
class="h-[25px]"
>
Expand All @@ -73,7 +73,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="livepeer.svg"
src="/livepeer.svg"
alt=""
class="h-[25px]"
>
Expand All @@ -83,7 +83,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="kava.png"
src="/kava.png"
alt=""
class="h-[25px]"
>
Expand All @@ -93,7 +93,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="p.svg"
src="/p.svg"
alt=""
class="h-[25px]"
>
Expand All @@ -103,7 +103,7 @@ import { ArrowRightIcon } from '@heroicons/vue/solid'
target="_blank"
>
<img
src="factom.svg"
src="/factom.svg"
alt=""
class="h-[25px]"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/pages/index/whitepaper/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ArrowLeftIcon , DownloadIcon } from '@heroicons/vue/outline'
<div class="">
<div class="relative">
<img
src="blob.svg"
src="/blob.svg"
alt=""
class="absolute -top-20 right-0 -z-1 w-[75%]"
>
Expand Down
2 changes: 2 additions & 0 deletions common/lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
12 changes: 12 additions & 0 deletions common/lib/index.ts
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()
})
}
15 changes: 15 additions & 0 deletions common/lib/package.json
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"
}
}
31 changes: 31 additions & 0 deletions common/lib/tsconfig.json
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"
]
}
9 changes: 9 additions & 0 deletions infrastructure/cdk/.gitignore
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
6 changes: 6 additions & 0 deletions infrastructure/cdk/.npmignore
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
14 changes: 14 additions & 0 deletions infrastructure/cdk/README.md
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
12 changes: 12 additions & 0 deletions infrastructure/cdk/bin/index.ts
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}`)
33 changes: 33 additions & 0 deletions infrastructure/cdk/cdk.json
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"
]
}
}
8 changes: 8 additions & 0 deletions infrastructure/cdk/jest.config.js
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'
}
}
65 changes: 65 additions & 0 deletions infrastructure/cdk/lib/users/users-stack.ts
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
}
})

}
}
Loading

0 comments on commit 2b9dc0f

Please sign in to comment.