This is an official starter turborepo.
Run the following command:
npx create-turbo@latest -e with-prismaThis turborepo includes the following packages/apps:
web: a Next.js app@repo/eslint-config:eslintconfigurations (includeseslint-config-nextandeslint-config-prettier)@repo/database: Prisma ORM wrapper to manage & access your database@rekindle/typescript-config:tsconfig.jsons used throughout the monorepo
Each package/app is 100% TypeScript.
This turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
- Prisma for database ORM
- Docker Compose for local database
We use Prisma to manage & access our database. As such you will need a database for this project, either locally or hosted in the cloud.
To make this process easier, we offer a docker-compose.yml file to deploy a MySQL server locally with a new database named turborepo (To change this update the MYSQL_DATABASE environment variable in the docker-compose.yml file):
cd my-turborepo
docker-compose up -dOnce deployed you will need to copy the .env.example file to .env in order for Prisma to have a DATABASE_URL environment variable to access.
cp .env.example .envIf you added a custom database name, or use a cloud based database, you will need to update the DATABASE_URL in your .env accordingly.
Once deployed & up & running, you will need to create & deploy migrations to your database to add the necessary tables. This can be done using Prisma Migrate:
npx prisma migrate devIf you need to push any existing migrations to the database, you can use either the Prisma db push or the Prisma migrate deploy command(s):
yarn run db:push
# OR
yarn run db:migrate:deployThere is slight difference between the two commands & Prisma offers a breakdown on which command is best to use.
An optional additional step is to seed some initial or fake data to your database using Prisma's seeding functionality.
To do this update check the seed script located in packages/database/src/seed.ts & add or update any users you wish to seed to the database.
Once edited run the following command to run tell Prisma to run the seed script defined in the Prisma configuration:
yarn run db:seedFor further more information on migrations, seeding & more, we recommend reading through the Prisma Documentation.
To build all apps and packages, run the following command:
yarn run buildTo develop all apps and packages, run the following command:
yarn run devLearn more about the power of Turborepo: