Skip to content

Commit

Permalink
fix: move example-architecture into src and setup tsconfig for build
Browse files Browse the repository at this point in the history
  • Loading branch information
SolP-Aleios committed Oct 19, 2023
1 parent 8f6fe25 commit 33b53f3
Show file tree
Hide file tree
Showing 33 changed files with 41 additions and 23 deletions.
4 changes: 0 additions & 4 deletions example-architecture/tsconfig.json

This file was deleted.

8 changes: 4 additions & 4 deletions src/classes/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
type PutEventsResponse,
type PutEventsResultEntry,
} from "@aws-sdk/client-eventbridge";
import { Contract, Detail } from "src/types/Contract";
import { Contract, Detail } from "types/Contract";

export const eventBridge = new EventBridgeClient({});

Expand Down Expand Up @@ -44,7 +44,7 @@ export class Event implements Contract {

publish = async (
eventBusArn: string,
eventSource: string,
eventSource: string
): Promise<PutEventsResponse> => {
const params = {
Entries: [
Expand All @@ -58,13 +58,13 @@ export class Event implements Contract {
};

const eventBridgeResponse = await eventBridge.send(
new PutEventsCommand(params),
new PutEventsCommand(params)
);
if (eventBridgeResponse.Entries === undefined) {
console.error("Error publishing event to event bus");
} else {
eventBridgeResponse.Entries.forEach((entry) =>
logResponseOnPublishFailure(entry),
logResponseOnPublishFailure(entry)
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/classes/__tests__/Event.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PutEventsCommand } from "@aws-sdk/client-eventbridge";
import { Event } from "src/classes";
import { Contract, Detail } from "src/types";
import { Event } from "classes";
import { Contract, Detail } from "types";
import { describe, expect, it, vi } from "vitest";

type MockDataDetail = {
Expand Down Expand Up @@ -73,7 +73,7 @@ describe("Given an Event class", () => {
await event.publish("MOCK_EVENT_BUS_ARN", "mockSource");
expect(mockSend).toHaveBeenCalled();
expect(consoleMock).toHaveBeenCalledWith(
"Error publishing event to event bus",
"Error publishing event to event bus"
);
});

Expand All @@ -90,7 +90,7 @@ describe("Given an Event class", () => {
{
ErrorCode: "mockErrorCode",
ErrorMessage: "mockErrorMessage",
},
}
);
});
});
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { App } from "aws-cdk-lib";

import { ConsumerStack } from "../lib/consumerStack";
import { ConsumerStack } from "example-architecture/consumer/lib/consumerStack";

const app = new App();
new ConsumerStack(app, "ConsumerStack");
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, PutCommand } from "@aws-sdk/lib-dynamodb";
import { getEnvVariable } from "example-architecture/helpers/getEnvVariable";
import { Contract } from "src/types/Contract";
import { Contract } from "types/Contract";

type EventBridgeConsumerEvent = {
id: string;
Expand All @@ -14,7 +14,7 @@ type EventBridgeConsumerEvent = {
} & Contract;

export const handler = async (
event: EventBridgeConsumerEvent,
event: EventBridgeConsumerEvent
): Promise<void> => {
const dynamoDB = DynamoDBDocumentClient.from(new DynamoDBClient());

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract } from "src/types";
import { Contract } from "types";
export interface PersonRegisteredContract extends Contract {
"detail-type": "PersonRegisteredContract";
detail: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract } from "src/types";
import { Contract } from "types";
export interface PersonRegisteredContract extends Contract {
"detail-type": "PersonRegisteredContract";
detail: {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mockPublish.mockReturnValue({
eventId: "mockEventId",
});

vi.mock("src/classes/Event", () => {
vi.mock("classes/Event", () => {
return {
Event: vi.fn().mockReturnValue({
publish: mockPublish,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type PutEventsResponse } from "@aws-sdk/client-eventbridge";
import { PersonRegisteredContract } from "example-architecture/events/contracts/personRegisteredContractV1";
import { getEnvVariable } from "example-architecture/helpers/getEnvVariable";
import { Event } from "src/classes/Event";
import { Event } from "classes/Event";

export const handler = async (): Promise<PutEventsResponse> => {
const contract: PersonRegisteredContract = {
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"baseUrl": ".",
"baseUrl": "src",
"esModuleInterop": true,
"declaration": true, // generate .d.ts files
"sourceMap": true, // show TS sourcemap
Expand All @@ -13,8 +13,7 @@
"strict": true,
"skipLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/*.test.ts"],
"include": ["**/*.ts"],
"ts-node": {
"compilerOptions": {
"module": "NodeNext"
Expand Down
24 changes: 24 additions & 0 deletions tsconfig.prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"baseUrl": "src",
"esModuleInterop": true,
"declaration": true, // generate .d.ts files
"sourceMap": true, // show TS sourcemap
"outDir": "./dist",
"types": ["node"],
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
},
"include": ["src"],
"exclude": ["**/*.test.ts", "src/example-architecture"],
"ts-node": {
"compilerOptions": {
"module": "NodeNext"
},
"require": ["tsconfig-paths/register"]
}
}

0 comments on commit 33b53f3

Please sign in to comment.