Lambda-oriented authentication service following a hexagonal architecture. Each Lambda lives in lambdas/ with shared utilities under lambdas/shared/.
- Install deps per Lambda:
cd lambdas/<lambda> && npm install(auth-registerandauth-loginship identical scripts). - Build handler bundle:
npm run build. - Run tests:
npm test(compiles specs with TypeScript and runs them via Node’s test runner; shared adapters are linked automatically for alias resolution). - Local entrypoint (
npm start) builds and invokesdist/index.js, auto-setting:USERS_TABLE_NAME=auth-users-local(unless already defined)AWS_REGION=us-east-1(unless already defined)AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEYdummy values for local useDYNAMODB_ENDPOINT=http://localhost:8000(unless already defined)
- Debug with WebStorm: run the
start:debugnpm script (see below) so breakpoints on.tsfiles map correctly via the emitted source map.
- Ensure Docker is running.
- Launch DynamoDB Local:
docker run --name dynamodb-local -p 8000:8000 amazon/dynamodb-local - Keep the container running while you exercise the Lambda locally.
- Download the archive:
curl -O https://s3.us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz - Extract the files:
tar -xzf dynamodb_local_latest.tar.gz - Start DynamoDB Local (from the extracted directory):
java -Djava.library.path=./DynamoDBLocal_lib -jar DynamoDBLocal.jar -sharedDb -port 8000
Both options expose DynamoDB Local on
http://localhost:8000, matching the defaults used bynpm start. SetDYNAMODB_ENDPOINTif you need a custom host/port.
Create the users table once per environment (default name: auth-users-local):
aws dynamodb create-table \
--table-name auth-users-local \
--attribute-definitions AttributeName=email,AttributeType=S \
--key-schema AttributeName=email,KeyType=HASH \
--billing-mode PAY_PER_REQUEST \
--endpoint-url http://localhost:8000 \
--region us-east-1
You can verify it with:
aws dynamodb list-tables --endpoint-url http://localhost:8000 --region us-east-1
- Use the
npm run start:debugscript to launch the handler with Node’s inspector (--inspect-brk) and source-map support. WebStorm can attach automatically when you run that npm script in Debug mode. - Breakpoints set in
src/**/*.tsresolve correctly because the esbuild bundle now ships source maps. - You can also create a WebStorm “Node.js” run configuration targeting
dist/index.js, passing--enable-source-mapsand (optionally)--inspect-brk=9229, if you prefer not to go through npm scripts.