A simple Kanban board app to help you stay organized anywhere.
-
Install the dependencies:
pnpm install
-
Create environment files:
.env.development.local
used fornext dev
..env
should mimic.env.development.local
for the most part.- Prisma and Playwright prefer
.env
so it can be modified accordingly.
- Prisma and Playwright prefer
.env.test.local
used forvitest
. Check SQLite Local Database section for more info..env.production.local
used fornext start
. Check SQLite Database from Turso section for more info.
-
Add environment variables to environment files following
.env.example
.- For
DATASOURCE_URL
andDATABASE_URL
see:- SQLite Local Database section.
- SQLite Database from Turso section.
- For
DATABASE_AUTH_TOKEN
see:- SQLite Database from Turso section.
- For
UNSPLASH_ACCESS_KEY
see: - For
DISCORD_CLIENT_ID
andDISCORD_CLIENT_SECRET
see: - For
NEXT_AUTH_SECRET
see:
- For
-
Sync DB with prisma schema
pnpm db:push
-
Run the application:
pnpm dev
pnpm install
Builds the app for production.
pnpm build
Runs the app in development mode. Opens http://localhost:3000/ to view it in the browser.
pnpm dev
Locally preview the production build. Open http://localhost:3000/ to view it in the browser.
pnpm start
Runs eslint to fix linting errors.
pnpm lint
Format the application with prettier.
pnpm format
Sync the database with the prisma schema.
pnpm db:push
Opens Prisma studio on http://localhost:5555
pnpm db:studio
Runs all test.
pnpm test
Runs unit/integration tests.
pnpm test:unit
Runs e2e tests.
pnpm test:e2e
For development and testing a local database can be use with a *.sqlite
file.
Assign credentials to the environment variables inside .env
and .env.development.local
.
DATASOURCE_URL="file:./db.sqlite"
DATABASE_URL="file:./prisma/db.sqlite"
Assign credentials to the environment variables inside .env.test.local
.
DATASOURCE_URL="file:./test.sqlite"
DATABASE_URL="file:./prisma/test.sqlite"
DATABASE_AUTH_TOKEN
is not needed for local development or testing.
SQLite Database from Turso 🫎
Turso is a SQLite-compatible database built on libSQL, the Open Contribution fork of SQLite.
If you don't have an existing database, you can provision a database by running the following command:
turso db create <DATABASE_NAME>
-
Get the database URL:
turso db show --url <DATABASE_NAME>
-
Get the database authentication token:
turso db tokens create <DATABASE_NAME>
-
Assign credentials to the environment variables inside
.env.production.local
.DATASOURCE_URL="file:./dev.db" DATABASE_URL="<TURSO_DATABASE_URL>" DATABASE_AUTH_TOKEN="<TURSO_AUTH_TOKEN>"
-
Generate Prisma Client
pnpm dlx prisma generate
-
Make an migration to sync with the Prisma schema.
turso db shell <DATABASE_NAME> < <MIGRATION_FILE_PATH>
-
Make a production build:
pnpm build
-
Run the production build, connected to Turso database:
pnpm start
Turso doesn't support Prisma Migrate. To update your database schema:
-
Generate a migration file using prisma migrate dev against a local SQLite database:
npx prisma migrate dev --name <NAME>
-
Apply the migration using Turso's CLI:
turso db shell <DATABASE_NAME> < ./prisma/migrations/<DATE_NAME>/migration.sql
For subsequent migrations, repeat the above steps to apply changes to your database.
Setting up the default DiscordProvider
- Head to the Applications section in the Discord Developer Portal, and click on “New Application”.
- In the settings menu, go to “OAuth2 => General”.
-
Copy the Client ID and paste it in
DISCORD_CLIENT_ID
in.env
. -
Under Client Secret, click “Reset Secret” and copy that string to
DISCORD_CLIENT_SECRET
in.env
. Be careful as you won’t be able to see this secret again, and resetting it will cause the existing one to expire. -
Click “Add Redirect” and paste in
<app url>/api/auth/callback/discord
. (ex. for local development:http://localhost:3000/api/auth/callback/discord
) -
Save your changes.
-
It is possible, but not recommended, to use the same Discord Application for both development and production. You could also consider Mocking the Provider during development.
More on NextAuth with T3...
More on Discord OAuth2...
Unit/Integration testing uses Vitest.
Vitest aims for compatibility with Jest.
This project uses dotenv to load the .env.test.local
file in the vitest.config.ts
file.
- Create
.env.test.local
file. Following.env.example
template. - Set
DATABASE_URL
to"file:./prisma/test.sqlite"
in.env.test.local
. - Set
DATASOURCE_URL
tofile:./test.sqlite
inpretest
script inpackage.json
. - Set
NODE_ENV
totest
in.env.test.local
.
-
For the first time, use:
pnpm test
This will run the
pretest
script first and thentest
script. Or run directly:pnpm pretest pnpm vitest src
The
pretest
script syncs the database with the Prisma schema.Pretest
uses theDATABASE_URL
explicitly since prisma cli would only read.env
file. (prisma/prisma#3865). Also the difference betweenDATABASE_URL
in.env.test.local
andpretest
script comes from where they load the datasourceurl
.pretest
usesschema.prisma
location but everything else use theroot
. -
Subsequently, tests can be run simply using:
pnpm vitest src
or use:
pnpm test:unit
Add files for testing with *.test.{ts|tsx}
pattern.
If you wish to change the name file for the test database, you need to change the DATABASE_URL
value in:
- The
.env.test.local
file. - The
pretest
script in thepackage.json
file.
End-to-end testing is done using Playwright.
To install browsers run:
npx playwright install
To run only the e2e tests, use:
npx playwright test
or, use:
pnpm test:e2e
Add files to e2e
folder with *.spec.{ts}
pattern.
To run all tests use:
pnpm test
- Integration testing with Prisma
- Sample Integration Test with T3
- Vitest
- Vitest test api
- Vitest CLI
- Playwright Browsers
Deployed to Vercel
- Click Add New Project.
- Import
github repo
to Vercel. - Set
FRAMEWORK PRESET
to Next.js. - Set
ROOT DIRECTORY
as./
. - Add environment variables.
- Click Deploy.
This is a T3 Stack project bootstrapped with create-t3-app
.