Skip to content

Commit 8debe1d

Browse files
committed
Update README.md
1 parent 0e51bee commit 8debe1d

File tree

1 file changed

+67
-2
lines changed

1 file changed

+67
-2
lines changed

README.md

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ mkdir -p ~/Documents/daemon-labs/docker-aws-lambda
8181

8282
> [!TIP]
8383
> If you are using VSCode, we can now do everything from within the code editor.
84-
> You can open the terminal window via Terminal -> New Terminal.
84+
> You can open the terminal pane via Terminal -> New Terminal.
8585
8686
### Create the code subdirectory
8787

@@ -93,7 +93,7 @@ mkdir nodejs
9393

9494
### Create the `Dockerfile`
9595

96-
Create the file at `nodejs/Dockerfile` (inside the subdirectory).
96+
Create the file at `./nodejs/Dockerfile` (inside the subdirectory).
9797

9898
```Dockerfile
9999
FROM public.ecr.aws/lambda/nodejs:24
@@ -118,3 +118,68 @@ docker compose run -it --rm --entrypoint /bin/sh -v ./nodejs:/var/task lambda
118118
```
119119

120120
---
121+
122+
## 2. The application
123+
124+
**Goal:** Initialise a TypeScript Node.js project.
125+
126+
### Initialise the project
127+
128+
Inside the container shell:
129+
130+
```shell
131+
npm init -y
132+
```
133+
134+
### Install dependencies
135+
136+
```shell
137+
npm add --save-dev @types/node@24 @types/aws-lambda @tsconfig/recommended typescript
138+
```
139+
140+
### Exit the container
141+
142+
```shell
143+
exit
144+
```
145+
146+
### Configure TypeScript
147+
148+
Create `./nodejs/tsconfig.json` locally:
149+
150+
```json
151+
{
152+
"extends": "@tsconfig/recommended/tsconfig.json",
153+
"compilerOptions": {
154+
"outDir": "./build"
155+
}
156+
}
157+
```
158+
159+
### Create the handler
160+
161+
Create `nodejs/src/index.ts`:
162+
163+
```typescript
164+
import { Handler } from "aws-lambda";
165+
166+
export const handler: Handler = (event, context) => {
167+
console.log("Hello world!");
168+
console.log({ event, context });
169+
170+
return {
171+
statusCode: 200,
172+
body: "Hello World!"
173+
};
174+
};
175+
```
176+
177+
### Add build script
178+
179+
Update `./nodejs/package.json` scripts:
180+
181+
```json
182+
"scripts": {
183+
"build": "tsc"
184+
},
185+
```

0 commit comments

Comments
 (0)