This guide will help you set up the Shortest web app for local development.
- Node.js
- pnpm
-
Clone the repository:
git clone https://github.com/gumroad/shortest.git cd shortest -
Install dependencies:
npm install -g pnpm pnpm install
- Run
vercel env pullto get the latest environment variables
- Run
pnpm run setupto configure the environment variables. - The setup wizard will ask you for information. Refer to "Services Configuration" section below for more details.
pnpm drizzle-kit generate
pnpm db:migrate
pnpm db:seed # creates stripe products, currently unusedYou'll need to set up the following services for local development. If you're not a Gumroad Vercel team member, you'll need to either run the setup wizard pnpm run setup or manually configure each of these services and add the corresponding environment variables to your .env.local file:
Clerk
- Go to clerk.com and create a new app.
- Name it whatever you like and disable all login methods except GitHub.
- Once created, copy the environment variables to your
.env.localfile.
Vercel Postgres
- Go to your dashboard at vercel.com.
- Navigate to the Storage tab and click the
Create Databasebutton. - Choose
Postgresfrom theBrowse Storagemenu. - Copy your environment variables from the
Quickstart.env.localtab.
Anthropic
- Go to your dashboard at anthropic.com and grab your API Key.
Stripe
- Go to your
Developersdashboard at stripe.com. - Turn on
Test mode. - Go to the
API Keystab and copy yourSecret key. - Go to the terminal of your project and type
pnpm run stripe:webhooks. It will prompt you to login with a code then give you yourSTRIPE_WEBHOOK_SECRET.
GitHub OAuth
-
Create a GitHub OAuth App:
- Go to your GitHub account settings.
- Navigate to
Developer settings>OAuth Apps>New OAuth App. - Fill in the application details:
-
Configure Clerk with GitHub OAuth:
Once you have set up the environment variables and installed dependencies, run the development server:
pnpm devOpen http://localhost:3000 in your browser to see the app in action.
To run unit tests:
pnpm vitestWhen running pnpm install in the root, the shortest package will be built and added in the node_modules folder. However, in order to use the cli, you need to setup the cli locally as follows:
pnpm install
### Setup Shortest CLI
```bash
# packages/shortest
cd packages/shortest
pnpm link --global
# root
cd ../..
pnpm link --global shortest
You can either run tests using the shortest cli:
shortestor use the pnpm command:
pnpm testIn order to test Github MFA login in browser you need to add register shortest as OTP provider and add the OTP secret to your .env.local file:
- Go to your repo settings
- Navigate to
Password and Authentication - Click on
Authenticator App - Choose
Use your authenticator app - Click on
Setup keyto grab the OTP secret - Add the OTP secret to your
.env.localfile or use theshortestcli to add it:
shortest --github-code --secret=<OTP_SECRET>- Laslty enter the 2FA code generated in terminal in your Github Authenticator editor
prerequisites:
- Add ANTHROPIC_API_KEY to your repo secrets
- Connect your repo to Vercel
- Go to your repo settings
- Navigate to
Security - Click
Add secret - Add the ANTHROPIC_API_KEY environment variable