Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ef9bb8d
db - fix entities relationship, add label db, theme db
milyas122 Aug 11, 2023
f2bb1cf
db - added entities repositories
milyas122 Aug 11, 2023
f5718a8
fix - User object pending issue in passport-config
milyas122 Aug 13, 2023
74e0ca2
refactor - remove entity repositories dependencies
milyas122 Aug 14, 2023
3fbd6cf
feat - added create note api
milyas122 Aug 14, 2023
5885da2
fix - add label field in yup schema
milyas122 Aug 15, 2023
5722ebb
refactor - add onDelete Cascade and owner column in usernote entity
milyas122 Aug 16, 2023
8a75832
refactor - allow create note Api to mark the owner true
milyas122 Aug 16, 2023
98624d3
feat - added delete notes Api
milyas122 Aug 16, 2023
9259cc4
feat - added archive notes
milyas122 Aug 17, 2023
c2069c0
feat - added unarchive notes api
milyas122 Aug 17, 2023
e5b28ce
feat - added pin notes api
milyas122 Aug 17, 2023
83f362d
feat - added unpined notes api
milyas122 Aug 17, 2023
b76e7f3
refactor - change note route to notes
milyas122 Aug 17, 2023
64c89f4
feat - added create label api
milyas122 Aug 17, 2023
9b3a379
refactor - added many to many label support on note
milyas122 Aug 17, 2023
bf52e07
feat- added delete label api
milyas122 Aug 17, 2023
80bcfa5
feat - added update label api
milyas122 Aug 17, 2023
0d6be6b
feat - added get user labels api
milyas122 Aug 17, 2023
786b649
feat - added change notes label api
milyas122 Aug 18, 2023
c7a5483
refactor - change note route http methods
milyas122 Aug 18, 2023
4cc9d00
feat - added get all user notes
milyas122 Aug 18, 2023
edcd321
refactor - make pined notes unarchived and on archived make it unpin
milyas122 Aug 18, 2023
24a2f4f
feat - added add collaborator api
milyas122 Aug 21, 2023
515d3a3
refactor - added collaborator entity
milyas122 Aug 21, 2023
fc3e7ba
refactor - added owner as collaborator in create note api
milyas122 Aug 21, 2023
d89a4df
refactor - added collaborator record
milyas122 Aug 21, 2023
fc1f856
feat - added remove collaborator api
milyas122 Aug 21, 2023
2411cfa
refactor - allow multiple users as a collaborators at once
milyas122 Aug 22, 2023
3942174
refactor - add noteUserId in collorator entity and refactor its usage…
milyas122 Aug 22, 2023
f3eb4ec
refactor - added remove user Note in remove collaborator api
milyas122 Aug 22, 2023
6962caa
refactor - get usernotes with collaborators
milyas122 Aug 23, 2023
1948ddd
refactor - get usernotes with collaborators
milyas122 Aug 23, 2023
80a16c0
feat - added user note detail api
milyas122 Aug 23, 2023
ffa0b05
refactor - remove collaborator from notes when notes get deleted
milyas122 Aug 23, 2023
5556533
refactor - updated archive user note api
milyas122 Aug 23, 2023
e39c737
refactor - updated unarchive notes
milyas122 Aug 23, 2023
14f19ed
refactor - updated pin notes
milyas122 Aug 23, 2023
32b914f
refactor - updated unPinNotes Api
milyas122 Aug 23, 2023
5542e8c
refactor - modify change label api to accept user notes Id instead of…
milyas122 Aug 23, 2023
239d347
refactor - updated create Label api
milyas122 Aug 23, 2023
cabcb09
refactor - added reminder entity in design
milyas122 Aug 25, 2023
56c3cdf
feat - added note reminder api
milyas122 Aug 25, 2023
f031b02
refactor - added reminder on delete cascade
milyas122 Aug 25, 2023
17b76bf
feat - added remove note reminder api
milyas122 Aug 25, 2023
219d44c
refactor - allow only reminder at a time to note
milyas122 Aug 25, 2023
c76944a
feat - added update reminder api
milyas122 Aug 25, 2023
b1332df
migration: add fake migration
milyas122 Sep 5, 2023
79cf531
feat: dockerize app"
milyas122 Sep 8, 2023
2131482
Infra: Build infrastructure in AWS via CDK
milyas122 Sep 22, 2023
ac98df0
feat - add an s3 image upload api
milyas122 Oct 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.env.example
build
cfn

.gitignore

.Dockerfile

node_modules

6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
DB_PORT=
JWT_SECRET=
JWT_SECRET=
NODE_OPTIONS='-r tsconfig-paths/register'
ACCESS_KEY_ID=
SECRET_ACCESS_KEY=
BUCKET_NAME=
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:19-alpine



WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

EXPOSE 8000

CMD ["npm", "start"]
1 change: 1 addition & 0 deletions cfn/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_PASSWORD=<PasswordHere>
8 changes: 8 additions & 0 deletions cfn/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out
6 changes: 6 additions & 0 deletions cfn/.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
15 changes: 15 additions & 0 deletions cfn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Welcome to your CDK TypeScript project

You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`CfnStack`)
which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic.

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
32 changes: 32 additions & 0 deletions cfn/bin/cfn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env node
import * as cdk from "aws-cdk-lib";
import { EcrStack } from "../lib/EcrStack";
import { NetworkStack } from "../lib/NetworkStack";
import { RdsStack } from "../lib/RdsStack";
import { EcsBackendStack } from "../lib/EcsBackendStack";
import { ApiGWStack } from "../lib/ApiGWStack";

const app = new cdk.App();

const ecrStack = new EcrStack(app, "EcrStack", {});

const networkStack = new NetworkStack(app, "NetworkStack", {});

new ApiGWStack(app, "ApiGWStack", {
nlb: networkStack.nlb,
});

const rdsStack = new RdsStack(app, "RdsStack", {
rdsSubnets: networkStack.rdsSubnets,
vpc: networkStack.vpc,
rdsSG: networkStack.rdsSG,
});

new EcsBackendStack(app, "EcsBackendStack", {
ecrRepository: ecrStack.ecrRepository,
vpc: networkStack.vpc,
rdsInstance: rdsStack.rdsInstance,
ecsSG: networkStack.ecsSG,
containerPort: 8000,
nlb: networkStack.nlb,
});
5 changes: 5 additions & 0 deletions cfn/cdk.context.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"acknowledged-issue-numbers": [
27189
]
}
60 changes: 60 additions & 0 deletions cfn/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"app": "npx ts-node --prefer-ts-exts bin/cfn.ts",
"watch": {
"include": [
"**"
],
"exclude": [
"README.md",
"cdk*.json",
"**/*.d.ts",
"**/*.js",
"tsconfig.json",
"package*.json",
"yarn.lock",
"node_modules",
"test"
]
},
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": [
"aws",
"aws-cn"
],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true,
"@aws-cdk/aws-kms:aliasNameRef": true,
"@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig": true,
"@aws-cdk/core:includePrefixInUniqueNameGeneration": true,
"@aws-cdk/aws-efs:denyAnonymousAccess": true,
"@aws-cdk/aws-opensearchservice:enableOpensearchMultiAzWithStandby": true,
"@aws-cdk/aws-lambda-nodejs:useLatestRuntimeVersion": true,
"@aws-cdk/aws-efs:mountTargetOrderInsensitiveLogicalId": true
}
}
8 changes: 8 additions & 0 deletions cfn/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'
}
};
63 changes: 63 additions & 0 deletions cfn/lib/ApiGWStack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as elbv2 from "aws-cdk-lib/aws-elasticloadbalancingv2";
import * as apigateway from "aws-cdk-lib/aws-apigateway";

interface IApiGWStackProps extends StackProps {
nlb: elbv2.CfnLoadBalancer;
}

export class ApiGWStack extends Stack {
public readonly nlb: elbv2.CfnLoadBalancer;

constructor(scope: Construct, id: string, props: IApiGWStackProps) {
super(scope, id, props);

const INetworkLoadBalancer =
elbv2.NetworkLoadBalancer.fromNetworkLoadBalancerAttributes(
this,
"INetworkLoadBalancer",
{
loadBalancerDnsName: props.nlb.attrDnsName,
loadBalancerArn: props.nlb.ref,
}
);

// Create a VPC Link
const link = new apigateway.VpcLink(this, "VpcLink", {
vpcLinkName: "KeepNotesVpcLink",
targets: [INetworkLoadBalancer],
});

// Create a Regional REST API
const restApi = new apigateway.RestApi(this, "Api", {
restApiName: "KeepNotesApi",
endpointTypes: [apigateway.EndpointType.REGIONAL],
});

const integration = new apigateway.Integration({
type: apigateway.IntegrationType.HTTP_PROXY,
integrationHttpMethod: "ANY",
options: {
connectionType: apigateway.ConnectionType.VPC_LINK,
vpcLink: link,
requestParameters: {
"integration.request.path.proxy": "method.request.path.proxy",
},
},
uri: `http://${INetworkLoadBalancer.loadBalancerDnsName}:8000/{proxy}`,
});
const proxyResource = restApi.root.addResource("{proxy+}", {
defaultCorsPreflightOptions: {
allowOrigins: apigateway.Cors.ALL_ORIGINS,
allowMethods: apigateway.Cors.ALL_METHODS,
},
});
proxyResource.addMethod("ANY", integration, {
authorizationType: apigateway.AuthorizationType.NONE,
requestParameters: {
"method.request.path.proxy": true,
},
});
}
}
16 changes: 16 additions & 0 deletions cfn/lib/EcrStack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Stack, StackProps, RemovalPolicy } from "aws-cdk-lib";
import { Construct } from "constructs";
import * as ecr from "aws-cdk-lib/aws-ecr";

export class EcrStack extends Stack {
public readonly ecrRepository: ecr.Repository;

constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);

this.ecrRepository = new ecr.Repository(this, "EcrRepository", {
repositoryName: "keep-notes-api",
removalPolicy: RemovalPolicy.DESTROY,
});
}
}
Loading