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 pull
to get the latest environment variables
- Run
pnpm run setup
to 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 unused
You'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.local
file.
Vercel Postgres
- Go to your dashboard at vercel.com.
- Navigate to the Storage tab and click the
Create Database
button. - Choose
Postgres
from theBrowse Storage
menu. - Copy your environment variables from the
Quickstart
.env.local
tab.
Anthropic
- Go to your dashboard at anthropic.com and grab your API Key.
Stripe
- Go to your
Developers
dashboard at stripe.com. - Turn on
Test mode
. - Go to the
API Keys
tab 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 dev
Open http://localhost:3000 in your browser to see the app in action.
To run unit tests:
pnpm vitest
When 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:
shortest
or use the pnpm
command:
pnpm test
To test Github MFA login in a browser, you need to register Shortest as an OTP provider and add the OTP secret to your .env.local
file:
- Go to your repository settings
- Navigate to "Password and Authentication"
- Click on "Authenticator App"
- Select "Use your authenticator app"
- Click "Setup key" to obtain the OTP secret
- Add the OTP secret to your
.env.local
file or use the Shortest CLI to add it - Enter the 2FA code displayed in your terminal into Github's Authenticator setup page to complete the process
shortest --github-code --secret=<OTP_SECRET>
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