Skip to content

Commit

Permalink
fix: dto controller type
Browse files Browse the repository at this point in the history
Add workaround to avoid error: Resource of type 'AWS::DynamoDB::Table' with identifier '...' already exists
Extend integration tests timeout
  • Loading branch information
s4nt14go committed Oct 29, 2023
1 parent ba2d00b commit 856c92f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion createEnv.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ lambdas.map(async l => {
const tables = resources.filter(r => r.ResourceType === 'AWS::DynamoDB::Table');
tables.map(async t => {
const physicalResourceId = t.PhysicalResourceId;
const logicalName = physicalResourceId.split('-').pop() + 'Table';
const logicalNameArr = physicalResourceId.split('-');
logicalNameArr.pop(); // Get rid of suffix
const logicalName = logicalNameArr.pop() + 'Table';
await $`echo ${logicalName}=${physicalResourceId} >> ${envFile}`
});

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ switch (TEST_MODE) {
break;
case 'int':
options.testRegex = '\\.int' + testRegex;
options.testTimeout = 30000;
options.testTimeout = 35000;
break;
case 'e2e':
options.testRegex = '\\.e2e' + testRegex;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/core/SubscriberController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export abstract class SubscriberController<Request, Response> {
protected event!: Request;

protected abstract executeImpl(
dto: unknown | Request
dto: Request
): ControllerResult<Response>;

public async execute(event: Request): ExeResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/shared/infra/appsync/AppSyncController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const successfulCodes = [200, 201];

export abstract class AppSyncController<Request, Response> {
protected abstract executeImpl(
dto: unknown | Request
dto: Request
): ControllerResult<Response>;
public async execute(event: AppSyncResolverEvent<Request>): ExeResponse {
console.log(`${this.constructor.name}.execute`);
Expand Down
7 changes: 4 additions & 3 deletions stacks/MyStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ export async function MyStack({ stack, app }: StackContext) {
});
allowSubscribeToDomainEvents(someWork, 'someWork');

const DBretryTable = new Table(stack, 'DBretry', {
const tableSuffix = 2; // Create new tables to avoid error: Resource of type 'AWS::DynamoDB::Table' with identifier '...' already exists
const DBretryTable = new Table(stack, `DBretry-${tableSuffix}`, {
fields: {
retryToken: 'string',
},
Expand Down Expand Up @@ -97,7 +98,7 @@ export async function MyStack({ stack, app }: StackContext) {
});
DBretryable(getAccountByUserId);

const notificationsTable = new Table(stack, 'Notifications', {
const notificationsTable = new Table(stack, `Notifications-${tableSuffix}`, {
fields: {
target: 'string', // e.g. FE
type: 'string', // e.g. TransactionCreated
Expand Down Expand Up @@ -202,7 +203,7 @@ export async function MyStack({ stack, app }: StackContext) {
});
allowSubscribeToDomainEvents(notifyFE, 'notifyFE');

const storageTable = new Table(stack, 'Storage', {
const storageTable = new Table(stack, `Storage-${tableSuffix}`, {
fields: {
// Keys
type: 'string', // UserCreatedEventStored | TransactionCreatedEventStored
Expand Down

0 comments on commit 856c92f

Please sign in to comment.