generated from t3-oss/create-t3-turbo
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from noxify/refactor-repo
Repo refactoring
- Loading branch information
Showing
220 changed files
with
13,959 additions
and
7,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
# The database URL is used to connect to your database. | ||
DB_HOST='localhost' | ||
DB_PORT=5432 | ||
DB_NAME='turbo_stack_db' | ||
DB_USERNAME='turbo_stack' | ||
DB_PASSWORD='turbo_stack' | ||
|
||
# OAUTH Configuration | ||
AUTH_GITHUB_ID='' | ||
AUTH_GITHUB_SECRET='' | ||
|
||
AUTH_DISCORD_ID='' | ||
AUTH_DISCORD_SECRET='' | ||
# frontend | ||
NEXT_TELEMETRY_DISABLED=1 | ||
|
||
# Database | ||
RDS_ENGINE="postgres" | ||
RDS_HOST="localhost" | ||
RDS_PORT=5432 | ||
RDS_USERNAME="postgres" | ||
RDS_PASSWORD="postgres" | ||
RDS_DBNAME="turbo_lucia_starter" | ||
|
||
# Logging | ||
LOG_LEVEL="debug" | ||
|
||
# OAuth Providers | ||
GITHUB_CLIENT_ID="" | ||
GITHUB_CLIENT_SECRET="" | ||
DISCORD_CLIENT_ID="" | ||
DISCORD_CLIENT_SECRET="" | ||
|
||
# OAuth Mock | ||
OAUTH_MOCK_ENABLED=false | ||
#OAUTH_MOCK_ENDPOINT="http://localhost" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20.12 | ||
22.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,121 +1,97 @@ | ||
# t3-turbo-lucia | ||
# Turbo Lucia Starter | ||
|
||
> The stack originates from [create-t3-turbo](https://github.com/t3-oss/create-t3-turbo). | ||
## Requirements | ||
|
||
## Features | ||
- Node >= 22.11 - https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating | ||
- Postgres >= 16 - https://postgresapp.com/ | ||
- pnpm >= 9.15.0 - https://pnpm.io/installation | ||
|
||
- Monorepo via turborepo | ||
- NextJS 14 | ||
- TRPC ( with RSC support ) | ||
- Lucia Auth with multi provider support | ||
- i18n support ( with support for i18n-ally ) | ||
- tailwind with shadcn-ui | ||
## Getting started | ||
|
||
## Installation | ||
1. Clone the repo | ||
2. Open the repo in VSC | ||
3. Install the recommended extensions ( use `@recommended` inside the VSC Extensions search bar ) | ||
4. Run `cp .env.example .env` to create a `.env` file | ||
5. Update the `.env` file with your values | ||
6. Run `pnpm install` to install dependencies | ||
7. Run `pnpm db:migrate:dev` to create the tables in the database | ||
8. Run `pnpm dev` to start the app in development mode | ||
9. Start coding | ||
|
||
Use Turbo's CLI to init your project (use PNPM as package manager): | ||
## About this template | ||
|
||
```bash | ||
npx create-turbo@latest -e https://github.com/noxify/t3-turbo-lucia | ||
``` | ||
|
||
## About | ||
|
||
It uses [Turborepo](https://turborepo.org) and contains: | ||
|
||
```text | ||
.vscode | ||
└─ Recommended extensions and settings for VSCode users | ||
apps | ||
└─ next.js | ||
├─ Next.js 14 | ||
├─ React 18 | ||
├─ Tailwind CSS | ||
└─ E2E Typesafe API Server & Client | ||
packages | ||
├─ api | ||
| └─ tRPC v11 router definition | ||
├─ auth | ||
| └─ Authentication using lucia-auth@v3 | ||
├─ db | ||
| └─ Typesafe db calls using Drizzle & postgres | ||
├─ locales | ||
| └─ type-safe internationalization | ||
├─ validators | ||
| └─ shared zod schemas for trpc and forms | ||
└─ ui | ||
└─ Start of a UI package for the webapp using shadcn-ui | ||
tooling | ||
├─ eslint | ||
| └─ shared, fine-grained, eslint presets | ||
├─ prettier | ||
| └─ shared prettier configuration | ||
├─ tailwind | ||
| └─ shared tailwind configuration | ||
└─ typescript | ||
└─ shared tsconfig you can extend from | ||
``` | ||
This template was original a copy from [t3-oss/create-t3-turbo](https://github.com/t3-oss/create-t3-turbo). | ||
|
||
> In this template, we use `@acme` as a placeholder for package names. As a user, you might want to replace it with your own organization or project name. You can use find-and-replace to change all the instances of `@acme` to something like `@my-company` or `@project-name`. | ||
We just replaced AuthJS with LuciaAuth. | ||
|
||
## Quick Start | ||
We're using this template internally and found out that some parts are not needed for a "web" monorepo ( = without expo ). | ||
|
||
To get it running, follow the steps below. | ||
So we updated it to be more like a "web" monorepo and removed all unnecessary stuff. | ||
This was mainly the `trpc` package with `tanstack/query`. | ||
|
||
The db is currently configured for `postgres`. | ||
Why? With all the nextjs updates, we think, most usecases don't need the extra layer to get the data. | ||
|
||
Feel free to change it. | ||
The template will use nextjs directly to fetch the data. ( https://nextjs.org/docs/app/building-your-application/data-fetching/fetching ) | ||
|
||
```bash | ||
# Install dependencies | ||
pnpm i | ||
## Project structure | ||
|
||
# Configure environment variables | ||
# There is an `.env.example` in the root directory you can use for reference | ||
cp .env.example .env | ||
This project is a monorepo based on turborepo. | ||
|
||
# Push the Drizzle schema to the database | ||
pnpm db:push | ||
|
||
# Let's get the party stared | ||
pnpm dev | ||
``` | ||
├── apps | ||
│ └── frontend - Contains the logic for the site | ||
├── packages | ||
│ ├── auth - Based on lucia-auth.com / same as we have at itaps monorepo | ||
│ ├── db - Contains all the database related stuff ( prisma schema, migrations, seeds etc. ) | ||
│ ├── helpers - Helper functions 🤷♂️ | ||
│ ├── locales - contains the translations for the `frontend` app | ||
│ ├── logging - Contains the logging wrapper ( via LogLayer ) | ||
│ ├── search-params - Contains the search params for the `frontend` app ( e.g. pagination, sorting etc. for the datatable ) | ||
│ └── ui - Contains all ui components ( based on shadcn/ui) | ||
└── tooling | ||
├── eslint - Contains the config files for eslint | ||
├── github - Contains the configuration for github actions | ||
├── playwright - Contains the config file for playwright | ||
├── prettier - Contains the config file for prettier | ||
├── tailwind - Contains the config files for tailwind w/ db ui colors | ||
└── typescript - Contains the config files for typescript | ||
``` | ||
|
||
## i18n | ||
|
||
This packages uses [next-international](https://github.com/quiiBz/next-international) for type-safe translations. | ||
|
||
This setup is a bit different to the original docs. | ||
We're using `json` files and generating the `ts` files from them. | ||
|
||
Why? Using json files allows us to use the vsc extension [`i18n ally`](https://github.com/lokalise/i18n-ally), which makes it a lot easier to manage the translations. | ||
|
||
> Note: If you don't need / use the i18n-ally extension, you could simply import the typescript files directly ( without using the json files). | ||
> Unfortunately the i18n-ally doesn't support writing `.ts` files. | ||
**Example:** | ||
|
||
Inside a component you write something like `{t('new.translation.key')}`. If you have the vsc extension installed, everything is pre-configured and you only have to hover over the `new.translation.key` and you will see a popover from `i18n ally` which helps you to generate the translations. | ||
## What's currently included? | ||
|
||
If you save the translation, it will update the `json` files inside `packages/locales/src/lang`. | ||
- The frontend app is configured to use the latest nextjs version (15.1) | ||
- Auth page is working | ||
- Redirect for unauthorized users to login page | ||
- Empty dashboard ( authorized users only ) | ||
- Initial playwright tests exists ( login tests ) | ||
- Auth is already configured for Github, Discord | ||
- Supports also mock users | ||
- 18n is configured with `next-intl` | ||
|
||
Last step what you have to do is to run `pnpm lang:gen` from your project root to (re-)generate the `ts` files ( which are located in `packages/locales/src/generated` ). | ||
## Helpful commands | ||
|
||
> Note: Thanks to dBianchii, he provided a PR which automates the re-generation 🫡 | ||
> So, while running `pnpm dev` the `generated/[lang].ts` files are (re-)generated after updating the json files automagically. | ||
- `pnpm dev` - Runs all apps & packages in dev mode. ( if they have a `dev` script ) | ||
- `pnpm build` - Builds all apps & packages. ( if they have a `build` script ) | ||
- `pnpm test` - Runs all tests ( if they have a `test` script ) | ||
- `pnpm lint` - Lints all files in all apps & packages ( if they have a `lint` script ) | ||
- `pnpm format:fix` - Formats all files. ( if they have a `format` script ) | ||
- `pnpm typecheck` - Runs the typescript type check on all apps & packages. ( if they have a `typecheck` script ) | ||
- `pnpm db:generate` - Runs the drizzle generate command: https://orm.drizzle.team/docs/drizzle-kit-generate | ||
- `pnpm db:migrate` - Runs the drizzle migrate command: https://orm.drizzle.team/docs/drizzle-kit-migrate | ||
- `pnpm db:push` - Runs the drizzle push command: https://orm.drizzle.team/docs/drizzle-kit-push | ||
- `pnpm db:seed` - Seeds some data - Uses the drizzle seed command: https://orm.drizzle.team/docs/seed-overview | ||
- `pnpm db:studio` - Opens the drizzle studio: https://orm.drizzle.team/docs/drizzle-kit-studio | ||
|
||
The vsc extension includes also some other features. | ||
## Todos | ||
|
||
Visit their [wiki](https://github.com/lokalise/i18n-ally/wiki) to learn more about it. | ||
- [ ] Add unit tests | ||
- [ ] Add more docs ( like how to activate/use mock users ) | ||
- [ ] Integrate https://github.com/sadmann7/shadcn-table to have an example | ||
- [ ] Maybe: Adding a RBAC solution ( maybe via casl? ) | ||
- [ ] Add a contribution guide | ||
|
||
## Credits / Special thanks | ||
## Credits | ||
|
||
- https://github.com/shadcn-ui | ||
- https://github.com/juliusmarminge | ||
- https://github.com/dBianchii | ||
- https://github.com/t3-oss | ||
- https://github.com/QuiiBz | ||
- https://github.com/HamedBahram | ||
- https://github.com/lucia-auth | ||
Without the amazing work of the [T3 OSS Community](https://github.com/t3-oss), this project wouldn't exists. | ||
|
||
If you like what you see, feel free to support one or all of them via their sponsoring options ( if available ). | ||
Also a big thanks to [dBianchii](https://github.com/dBianchii) for his awesome work and help to migrate the auth package ( previously we used V3, now we run "our own" auth package ) and the locales package ( migrating from `next-international` to `next-intl` ). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.