A TypeScript AWS Lambda service backed by MongoDB Atlas, with a GitHub Actions pipeline for CI and deployment. It was originally built as the backend authentication service for Find My Roommates, a roommate-matching web product. It is kept here as a code sample.
The Lambda handler (src/index.ts) implements user registration and login:
POST /registration— validates input with Joi, checks for an existing user in MongoDB, sends a confirmation email via SendGrid, and hashes the password with bcrypt before storing the new user.POST /login— verifies credentials and issues a JWT access token.
- TypeScript
- AWS Lambda (Node.js 18)
- MongoDB Atlas (
mongodbdriver) - SendGrid (
@sendgrid/mail) for transactional email - Joi for request validation
- bcryptjs for password hashing
- jsonwebtoken for auth tokens
- Gulp for the build (TypeScript compile + asset copy)
- GitHub Actions for CI and deployment to AWS Lambda via S3
src/
index.ts # Lambda handler: registration and login routes
sendgrid.service.ts # Sends confirmation emails via SendGrid
crypto.service.ts # Password hashing and comparison (bcrypt)
helper.ts # writeLog — structured console logging with a request hash
.github/workflows/
ci.yml # Runs npm ci + build on pull requests
main.yml # Builds, zips, and deploys to Lambda via S3 on push to main
gulpfile.js # Build pipeline: clean -> compile -> copy deps -> copy env files
nvm use # Node 18.17.1, see .nvmrc
npm install
cp .env.example .env # fill in real values, see table below
npm run build # compiles src/ to dist/ with gulpThere is no local HTTP server here. The dist/ build output is what the
GitHub Actions workflow zips and uploads to AWS Lambda; to exercise the
handler locally, invoke handler from dist/index.js with a mock event.
| Variable | Description |
|---|---|
MONGO_DB_PASSWORD |
Password for the roommates MongoDB Atlas user |
SENDGRID_API_KEY |
API key used to send confirmation emails via SendGrid |
DOMAIN |
Base URL used to build the email confirmation link |
PASSPORT_SECRET |
Secret used to sign JWT access tokens on login |
In CI, these are injected from GitHub Actions secrets (main.yml).
Find My Roommates is no longer in production. This repository is preserved as a code sample and is not actively deployed.