Skip to content

Commit cae3e93

Browse files
author
remote-swe-app[bot]
committed
docs: remove code examples and add CDK entry point override explanation
1 parent f6687a6 commit cae3e93

1 file changed

Lines changed: 9 additions & 37 deletions

File tree

webapp/README.md

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ This project uses type-safe server actions with authentication:
190190

191191
Asynchronous jobs are Lambda functions that handle long-running or background tasks. The `job.Dockerfile` builds all TypeScript files in `src/jobs/` into separate Lambda handlers using `esbuild src/jobs/*.ts --bundle`.
192192

193-
**Project structure:**
193+
**File structure:**
194194

195195
For simple jobs, place a single file directly under `src/jobs/`:
196196

@@ -209,44 +209,16 @@ webapp/src/jobs/
209209
└── translate.ts # Job implementation
210210
```
211211

212-
**Example implementation:**
212+
**Deployment:**
213213

214-
```typescript
215-
// webapp/src/jobs/async-job-runner.ts
216-
import { translateJobHandler, translateJobSchema } from '@/jobs/async-job/translate';
217-
import { Handler } from 'aws-lambda';
218-
import { z } from 'zod';
219-
220-
const jobPayloadPropsSchema = z.discriminatedUnion('type', [
221-
translateJobSchema,
222-
// Add more job types here
223-
]);
224-
225-
export const handler: Handler<unknown> = async (event) => {
226-
const { data: payload, error } = jobPayloadPropsSchema.safeParse(event);
227-
if (error) throw new Error(error.toString());
228-
229-
switch (payload.type) {
230-
case 'translate':
231-
await translateJobHandler(payload);
232-
break;
233-
}
234-
};
235-
```
214+
All jobs share the same `job.Dockerfile`. The CDK stack overrides the entry point using the `cmd` parameter in `DockerImageCode.fromImageAsset()`:
236215

237216
```typescript
238-
// webapp/src/jobs/async-job/translate.ts
239-
import { z } from 'zod';
240-
241-
export const translateJobSchema = z.object({
242-
type: z.literal('translate'),
243-
todoItemId: z.string(),
244-
userId: z.string(),
245-
});
246-
247-
export const translateJobHandler = async (params: z.infer<typeof translateJobSchema>) => {
248-
// Job implementation
249-
};
217+
// Example from cdk/lib/constructs/async-job.ts
218+
code: DockerImageCode.fromImageAsset(join('..', 'webapp'), {
219+
cmd: ['async-job-runner.handler'], // Override the default CMD
220+
file: 'job.Dockerfile',
221+
})
250222
```
251223

252-
**Note:** All jobs share the same `job.Dockerfile`. No individual Dockerfiles are needed. To deploy jobs, configure them in the CDK stack (see `cdk/lib/constructs/async-job.ts`).
224+
This allows multiple Lambda functions to use the same Docker image with different handlers.

0 commit comments

Comments
 (0)