Serverless REST API powering rask.rguixaro.dev, a URL shortener built on AWS Lambda and API Gateway.
Python 3.11 | Serverless Framework v4 | AWS Lambda + API Gateway | MongoDB | PyJWT | bcrypt
| Method | Path | Description |
|---|---|---|
POST |
/auth |
Create or refresh a cookie-based session |
POST |
/link-create |
Create a new short link |
GET |
/link-check/{slug} |
Resolve a slug and increment visit count |
GET |
/links-list |
List all links for the current session |
Prerequisites and setup
- Node.js 20+
- Python 3.11
- AWS account with appropriate IAM permissions
- MongoDB instance
-
Clone the repository and install dependencies:
git clone https://github.com/rguixaro/rask-api.git cd rask-api npm install pip install -r requirements.txt -
Copy the environment template and fill in the values:
cp .env.template .env.local
Variable Description DB_URLMongoDB connection string ENCRYPTION_KEYSecret key used for JWT signing CORS_ORIGINAllowed CORS origin (e.g. http://localhost:3000)COOKIE_DOMAINCookie domain (e.g. localhost) -
Deploy to AWS:
npm run deploy
Unit tests run automatically on every push to main via
GitHub Actions and block deployment on failure.
pip install -r requirements-dev.txt
pytest tests/ -vDeploys to AWS on every push to main using OIDC authentication, no stored AWS
credentials. Required GitHub Secrets:
| Secret | Description |
|---|---|
AWS_ACCOUNT_ID |
AWS account ID |
DB_URL |
MongoDB connection string |
ENCRYPTION_KEY |
JWT signing key |
CORS_ORIGIN |
Allowed CORS origin |
COOKIE_DOMAIN |
Cookie domain |