Skip to content

Commit

Permalink
Quickly setting up the initial base project
Browse files Browse the repository at this point in the history
  • Loading branch information
mim-Armand committed Feb 8, 2022
0 parents commit 0cd0d34
Show file tree
Hide file tree
Showing 12 changed files with 17,418 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out

# Intellijerk
.idea
6 changes: 6 additions & 0 deletions .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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

> This is a simple Agora token gen backend to be used with a front-end to use Agora services
- Create an audio and video app using agora quick start guide
- Add in call stats
- add group chat
- discuss how it works in detail
- demonstrate how it runs.


## 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

* `cdk --version` To get the current version of the CDK
* `aws sts get-caller-identity --profile fff` to get the account number of the currently selected profile

## To deploy:
- `cd CDK/lambda` and then run `npm i` there
- Run `cdk bootstrap --profile fff` // only run once, for the first time.
- Run `cdk diff --profile fff` // to see the recent changes before deploying them.
- Run `cdk deploy --profile fff`
- Run `cdk deploy --hotswap --profile fff` For a fast re-deploy ( DON'T USE IN PRODUCTION! )
- Run `npm run watch` for continous hot-swap ( if needed edit `package.json` to include / exclude files in the watch )
6 changes: 6 additions & 0 deletions bin/agora-cdk.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env node
import * as cdk from '@aws-cdk/core';
import { AgoraCdkStack } from '../lib/agora-cdk-stack';

const app = new cdk.App();
new AgoraCdkStack(app, 'argoStack');
18 changes: 18 additions & 0 deletions cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"app": "npx ts-node --prefer-ts-exts bin/agora-cdk.ts",
"context": {
"@aws-cdk/aws-apigateway:usagePlanKeyOrderInsensitiveId": true,
"@aws-cdk/core:enableStackNameDuplicates": "true",
"aws-cdk:enableDiffNoFail": "true",
"@aws-cdk/core:stackRelativeExports": "true",
"@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
"@aws-cdk/aws-secretsmanager:parseOwnedSecretName": true,
"@aws-cdk/aws-kms:defaultKeyPolicies": true,
"@aws-cdk/aws-s3:grantWriteWithoutAcl": true,
"@aws-cdk/aws-ecs-patterns:removeDefaultDesiredCount": true,
"@aws-cdk/aws-rds:lowercaseDbIdentifier": true,
"@aws-cdk/aws-efs:defaultEncryptionAtRest": true,
"@aws-cdk/aws-lambda:recognizeVersionProps": true,
"@aws-cdk/aws-cloudfront:defaultSecurityPolicyTLSv1.2_2021": true
}
}
8 changes: 8 additions & 0 deletions 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'
}
};
30 changes: 30 additions & 0 deletions lambda/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions lambda/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "agora-cdk",
"version": "1.0.0",
"description": "This is the Lambda directory for the backend project",
"main": "agoraGetToken.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "mim. Armand",
"dependencies": {
"uuid": "^8.3.2"
}
}
32 changes: 32 additions & 0 deletions lib/agora-cdk-stack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as cdk from '@aws-cdk/core';
import * as lambda from '@aws-cdk/aws-lambda';
import * as apigw from '@aws-cdk/aws-apigateway';

export class AgoraCdkStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const agoraGetToken = new lambda.Function(this, 'agoraGetToken', {
runtime: lambda.Runtime.NODEJS_14_X,
code: lambda.Code.fromAsset('lambda'),
handler: 'agoraGetToken.handler',
environment: {
key: 'value'
}
})

const api = new apigw.RestApi(this, 'argoApis', {
restApiName: "agora-cdk APIs",
description: "APIs for the application."
})

const getCalendarIntegration = new apigw.LambdaIntegration(agoraGetToken, {
requestTemplates: { "application/json": '{"statusCode": "200"}'},
})

api.root.addMethod("GET", getCalendarIntegration, {
operationName: "Get New Token",
})

}
}
Loading

0 comments on commit 0cd0d34

Please sign in to comment.