Skip to content

Repository files navigation

Rask Rask API

Serverless REST API powering rask.rguixaro.dev, a URL shortener built on AWS Lambda and API Gateway.

Tech Stack

Python 3.11 | Serverless Framework v4 | AWS Lambda + API Gateway | MongoDB | PyJWT | bcrypt

Endpoints

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

Getting Started

Prerequisites and setup

Prerequisites

  • Node.js 20+
  • Python 3.11
  • AWS account with appropriate IAM permissions
  • MongoDB instance

Setup

  1. 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
  2. Copy the environment template and fill in the values:

    cp .env.template .env.local
    Variable Description
    DB_URL MongoDB connection string
    ENCRYPTION_KEY Secret key used for JWT signing
    CORS_ORIGIN Allowed CORS origin (e.g. http://localhost:3000)
    COOKIE_DOMAIN Cookie domain (e.g. localhost)
  3. Deploy to AWS:

    npm run deploy

Testing

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/ -v

CI/CD

Deploys 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

License

GPL-3.0

About

Serverless REST API powering rask.rguixaro.dev

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages