Skip to content

Commit 49c0bf0

Browse files
committed
initial construct template
1 parent 8e72ae2 commit 49c0bf0

File tree

9 files changed

+103
-0
lines changed

9 files changed

+103
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Be very careful editing this file. It is crafted to work around [this issue](https://github.com/npm/npm/issues/4479)
2+
3+
# First ignore everything
4+
**/*
5+
6+
# Then add back in transpiled js and ts declaration files
7+
!lib/**/*.js
8+
!lib/**/*.d.ts
9+
10+
# Then ignore test js and ts declaration files
11+
*.test.js
12+
*.test.d.ts
13+
14+
# This leaves us with including only js and ts declaration files of functional code
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Description
2+
3+
Replace with a description of this package
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../api-extractor.base.json"
3+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "@aws-amplify/rest-api-construct",
3+
"version": "0.1.0",
4+
"type": "module",
5+
"publishConfig": {
6+
"access": "public"
7+
},
8+
"exports": {
9+
".": {
10+
"types": "./lib/index.d.ts",
11+
"import": "./lib/index.js",
12+
"require": "./lib/index.js"
13+
}
14+
},
15+
"types": "lib/index.d.ts",
16+
"scripts": {
17+
"update:api": "api-extractor run --local"
18+
},
19+
"license": "Apache-2.0",
20+
"peerDependencies": {
21+
"aws-cdk-lib": "^2.158.0",
22+
"constructs": "^10.0.0"
23+
}
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { describe, it } from 'node:test';
2+
import { AmplifyConstruct } from './construct.js';
3+
import { App, Stack } from 'aws-cdk-lib';
4+
import { Template } from 'aws-cdk-lib/assertions';
5+
6+
void describe('AmplifyConstruct', () => {
7+
void it('creates a queue if specified', () => {
8+
const app = new App();
9+
const stack = new Stack(app);
10+
new AmplifyConstruct(stack, 'test', {
11+
includeQueue: true,
12+
});
13+
const template = Template.fromStack(stack);
14+
template.resourceCountIs('AWS::SQS::Queue', 1);
15+
});
16+
17+
void it('does nothing if queue is false', () => {
18+
const app = new App();
19+
const stack = new Stack(app);
20+
new AmplifyConstruct(stack, 'test', {
21+
includeQueue: false,
22+
});
23+
const template = Template.fromStack(stack);
24+
template.resourceCountIs('AWS::SQS::Queue', 0);
25+
});
26+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Construct } from 'constructs';
2+
import { aws_sqs as sqs } from 'aws-cdk-lib';
3+
4+
export type ConstructCognitoProps = {
5+
includeQueue?: boolean;
6+
};
7+
8+
/**
9+
* Hello world construct implementation
10+
*/
11+
export class AmplifyConstruct extends Construct {
12+
/**
13+
* Create a new AmplifyConstruct
14+
*/
15+
constructor(scope: Construct, id: string, props: ConstructCognitoProps = {}) {
16+
super(scope, id);
17+
18+
if (props.includeQueue) {
19+
new sqs.Queue(this, 'placeholder');
20+
}
21+
}
22+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './construct.js';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "lib"
6+
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"entryPoints": ["src/index.ts"]
3+
}

0 commit comments

Comments
 (0)