-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: update apps and packages list and add installation instructions * docs: add commands for database migration, HTTP client generation, and email template generation * chore: update testing scripts and configurations * docs: update email template generation path in README
- Loading branch information
1 parent
6fd0cd5
commit f958efe
Showing
3 changed files
with
93 additions
and
52 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,81 +1,118 @@ | ||
# Turborepo starter | ||
### Apps and Packages | ||
|
||
- apps | ||
- `api`: a NestJS backend application working as API | ||
- `web`: a Vite Remix SPA | ||
- `reverse-proxy`: for domains and https during development | ||
- packages | ||
- `email-templates`: a package for email templates | ||
- `eslint-config`: a package for eslint configuration | ||
- `typescript-config`: a package for typescript configuration | ||
|
||
This is an official starter Turborepo. | ||
### Install | ||
|
||
## Using this example | ||
To start with the setup make sure you have the correct NodeJS version stated in [.tool-versions](./.tool-versions). | ||
For the node versioning we recommend [asdf](https://asdf-vm.com/). At the time of writing this readme the version is `20.15.0` | ||
|
||
Run the following command: | ||
After these steps, run the following command | ||
|
||
```sh | ||
npx create-turbo@latest | ||
pnpm install | ||
``` | ||
|
||
## What's inside? | ||
Now to configure our reverse proxy we need to install [Caddy](https://caddyserver.com/docs/install#homebrew-mac). You | ||
can do this using `homebrew` on mac. | ||
|
||
This Turborepo includes the following packages/apps: | ||
> [!IMPORTANT] | ||
> First run has to be run by hand to configure caddy. Later on it will automatically | ||
> start with the app start script. | ||
### Apps and Packages | ||
To do that proceed with the following | ||
|
||
- `docs`: a [Next.js](https://nextjs.org/) app | ||
- `web`: another [Next.js](https://nextjs.org/) app | ||
- `@repo/ui`: a stub React component library shared by both `web` and `docs` applications | ||
- `@repo/eslint-config`: `eslint` configurations (includes `eslint-config-next` and `eslint-config-prettier`) | ||
- `@repo/typescript-config`: `tsconfig.json`s used throughout the monorepo | ||
|
||
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/). | ||
```sh | ||
cd ./apps/reverse-proxy | ||
caddy run | ||
``` | ||
|
||
### Utilities | ||
After running caddy proceed with the on screen instructions. | ||
|
||
This Turborepo has some additional tools already setup for you: | ||
Last step is to go our NestJS app and configure its environmental variables and docker. | ||
So being in `guidebook/apps/api` run the following command | ||
|
||
- [TypeScript](https://www.typescriptlang.org/) for static type checking | ||
- [ESLint](https://eslint.org/) for code linting | ||
- [Prettier](https://prettier.io) for code formatting | ||
```sh | ||
cp .env.example .env | ||
docker-compose up -d | ||
``` | ||
|
||
### Build | ||
### Migrations | ||
|
||
To build all apps and packages, run the following command: | ||
Once the docker is up and running we need to run the migrations. To do that run the following command | ||
|
||
``` | ||
cd my-turborepo | ||
pnpm build | ||
```sh | ||
pnpm db:migrate | ||
``` | ||
|
||
### Develop | ||
|
||
To develop all apps and packages, run the following command: | ||
Now in the main directory once you run `pnpm dev` it will run everything in parallel | ||
and you should be abble to acces your app on the following adresses! | ||
|
||
``` | ||
cd my-turborepo | ||
pnpm dev | ||
``` | ||
| Service | URL | | ||
| ------- | ---------------------------------------------------------------------------- | | ||
| Web app | [ https://app.guidebook.localhost ](https://app.guidebook.localhost) | | ||
| Api | [https://api.guidebook.localhost ](https://api.guidebook.localhost) | | ||
| Swagger | [ https://api.guidebook.localhost/api ](https://api.guidebook.localhost/api) | | ||
|
||
### Remote Caching | ||
### Commands | ||
|
||
Turborepo can use a technique known as [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) to share cache artifacts across machines, enabling you to share build caches with your team and CI/CD pipelines. | ||
- #### Database | ||
|
||
By default, Turborepo will cache locally. To enable Remote Caching you will need an account with Vercel. If you don't have an account you can [create one](https://vercel.com/signup), then enter the following commands: | ||
- generate migration | ||
|
||
``` | ||
cd my-turborepo | ||
npx turbo login | ||
``` | ||
```sh | ||
pnpm db:generate | ||
``` | ||
|
||
This will authenticate the Turborepo CLI with your [Vercel account](https://vercel.com/docs/concepts/personal-accounts/overview). | ||
- run migrations | ||
```sh | ||
pnpm db:migrate | ||
``` | ||
> [!IMPORTANT] | ||
> Once migration is generated chagne its name to something more descriptive. | ||
> Also make sure to change the migration name in [\_journal.json](apps/api/src/storage/migrations/meta/_journal.json) file under the `tag` key. | ||
|
||
Next, you can link your Turborepo to your Remote Cache by running the following command from the root of your Turborepo: | ||
- #### HTTP Client | ||
|
||
``` | ||
npx turbo link | ||
``` | ||
To generate the http client run the following command. | ||
|
||
```sh | ||
pnpm generate:client | ||
``` | ||
|
||
This command automates the process of creating a TypeScript client for the API based on the Swagger specification. | ||
|
||
- #### Email Templates | ||
|
||
Email templates are generated on every start of turborepo. To generate them manually run the following command in `packages/email-templates`. | ||
|
||
## Useful Links | ||
```sh | ||
pnpm build | ||
``` | ||
|
||
Learn more about the power of Turborepo: | ||
The mailhog service is available at [mailbox.guidebook.localhost](mailbox.guidebook.localhost) | ||
|
||
- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks) | ||
- [Caching](https://turbo.build/repo/docs/core-concepts/caching) | ||
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching) | ||
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering) | ||
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration) | ||
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference) | ||
- #### Testing | ||
- **Frontend**: | ||
```sh | ||
pnpm test:web | ||
``` | ||
```sh | ||
pnpm test:web:e2e | ||
``` | ||
- **Backend**: | ||
```sh | ||
pnpm test:api | ||
``` | ||
```sh | ||
pnpm test:api:e2e | ||
``` |
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