To contribute you will first need to fork the repo and make some adjustments to get it up and running on your local machine. Below are the steps to follow for you to get TypeHero to run on your local machine.
Provide your values as needed.
You can either use PlanetScale or a local Docker container to run your database. Use either 2.a or 2.b for the next step.
Starting the docker container
docker compose up -d
Follow the PlanetScale quick start guide to get started
After creating an account and creating a database using the steps above:
-
Click either the big "Connect" button or the "connect to your database" Link.
-
Select "Connect with Prisma" and copy the
DATABASE_URL
for your.env
Follow this link to create a new app filling the following required details on creation:
Homepage URL: http://localhost:3000
Authorization callback URL: http://localhost:3000/api/auth/callback/github
Once completed, you will be redirected to the application page settings, from
there create the client secret by clicking on Generate a new client secret
button.
Next, copy the client secret generated and the client ID into the .env
file,
replacing <client_id>
and <client_secret>
, respectively:
GITHUB_ID=<client_id>
GITHUB_SECRET=<client_secret>
Go to uploadthing.com and create a project,
then copy in the secrets into your .env
.
In the end your local .env
file should look something like the following
DATABASE_URL="mysql://dev:dev@localhost/typehero"
GITHUB_ID=very_real_github_id
GITHUB_SECRET=very_real_secret
UPLOADTHING_SECRET="very_real_uploadthing_secret"
UPLOADTHING_APP_ID="very_real_uploadthing_app_id"
# Next Auth
# You can generate a new secret on the command line with:
# openssl rand -base64 32
# https://next-auth.js.org/configuration/options#secret
NEXTAUTH_SECRET="for local use you can just use a garble of letters"
NEXTAUTH_URL="http://localhost:3000"
Use pnpm
to install dependencies.
pnpm install
pnpm db:push
pnpm db:seed
Finally, you can run the dev server:
pnpm dev
Once the server is running you can seed and sync data
- Navigate to http://localhost:3000/api/auth/github to authenticate with GitHub OAuth.
-
Ensure you have logged into your local instance atleast once
-
Run
pnpm db:studio
- to open Prisma Studio -
Click on the
User
table from the list of models -
Locate your username and open record in new tab to modify Role
UI Library: shadcn
pnpm test:e2e:install
You can use the production server or the dev server to run the e2e tests.
Warning
The dev server may cause tests to timeout.
Playwright will automatically start the production server
pnpm build && pnpm test:e2e
Open two separate terminals and run the following commands in each one:
Terminal 1:
pnpm dev
Terminal 2:
pnpm test:e2e
How do I totally rebuild and re-seed the database?
Run the command
pnpm refresh
This will cause Prisma to force reset the database through the db:reset
command and then run db:seed
.
What if I run into errors with that command?
If you are using the docker setup for your local environment then get into the container withdocker exec -it typehero-db bash
# we are in the container from here on
$ mysql -u dev -p -h 127.0.0.1 typehero
> drop database typehero;
Exit out of the container and then run
pnpm refresh
This tends to resolve the issue as it entirely destroys and rebuilds + reseeds the database.
How do I use the `@vercel/toolbar` locally?
If you have access to the vercel project then you can run `vercel link` (make sure you have the vercel CLI).Follow the interactive CLI to link it to the Trash Company/typehero project.
From there on out you should be able to read and make comments while on local host for that branch.