Repository: ejazahm3d/fullstack-turborepo-starter
Branch: master
Commit: 56ac4e120202
Files: 70
Total size: 34.4 KB
Directory structure:
gitextract_s_o25e31/
├── .dockerignore
├── .github/
│ └── workflows/
│ ├── api.yaml
│ └── web.yaml
├── .gitignore
├── LICENSE
├── README.md
├── apps/
│ ├── api/
│ │ ├── .eslintrc.js
│ │ ├── .prettierrc
│ │ ├── Dockerfile
│ │ ├── README.md
│ │ ├── nest-cli.json
│ │ ├── package.json
│ │ ├── prisma/
│ │ │ ├── migrations/
│ │ │ │ ├── 20220307034109_initial_migrate/
│ │ │ │ │ └── migration.sql
│ │ │ │ └── migration_lock.toml
│ │ │ └── schema.prisma
│ │ ├── src/
│ │ │ ├── app.controller.spec.ts
│ │ │ ├── app.controller.ts
│ │ │ ├── app.module.ts
│ │ │ ├── app.service.ts
│ │ │ ├── config/
│ │ │ │ └── environment-variables.ts
│ │ │ ├── main.ts
│ │ │ └── persistence/
│ │ │ ├── persistence.module.ts
│ │ │ └── prisma/
│ │ │ ├── prisma.service.spec.ts
│ │ │ └── prisma.service.ts
│ │ ├── test/
│ │ │ ├── app.e2e-spec.ts
│ │ │ └── jest-e2e.json
│ │ ├── tsconfig.build.json
│ │ ├── tsconfig.json
│ │ └── webpack-hmr.config.js
│ └── web/
│ ├── .eslintrc.js
│ ├── Dockerfile
│ ├── README.md
│ ├── jest.config.js
│ ├── jest.setup.js
│ ├── next-env.d.ts
│ ├── next.config.js
│ ├── package.json
│ ├── pages/
│ │ ├── _app.tsx
│ │ └── index.tsx
│ ├── postcss.config.js
│ ├── src/
│ │ ├── common/
│ │ │ └── .gitkeep
│ │ ├── screens/
│ │ │ ├── admin/
│ │ │ │ └── .gitkeep
│ │ │ ├── auth/
│ │ │ │ └── login/
│ │ │ │ ├── login.test.tsx
│ │ │ │ └── login.tsx
│ │ │ ├── common/
│ │ │ │ └── .gitkeep
│ │ │ └── employee/
│ │ │ └── .gitkeep
│ │ ├── store/
│ │ │ ├── index.ts
│ │ │ └── services/
│ │ │ └── api.ts
│ │ └── styles/
│ │ └── global.css
│ ├── tailwind.config.js
│ └── tsconfig.json
├── docker-compose.yml
├── package-scripts.js
├── package.json
├── packages/
│ ├── config/
│ │ ├── eslint-preset.js
│ │ ├── nginx.conf
│ │ ├── package.json
│ │ ├── postcss.config.js
│ │ └── tailwind.config.js
│ ├── tsconfig/
│ │ ├── README.md
│ │ ├── base.json
│ │ ├── nestjs.json
│ │ ├── nextjs.json
│ │ ├── package.json
│ │ └── react-library.json
│ └── ui/
│ ├── components/
│ │ └── Button/
│ │ └── Button.tsx
│ ├── index.tsx
│ ├── package.json
│ └── tsconfig.json
└── turbo.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .dockerignore
================================================
**/node_modules
**/.next
**/dist
**/.turbo
================================================
FILE: .github/workflows/api.yaml
================================================
# This is a basic workflow to help you get started with Actions
name: api-ci
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
paths:
- "apps/api/**"
pull_request:
branches: [master]
paths:
- "apps/api/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
DATABASE_URL: "postgresql://test:test@localhost:5432/pm"
# Steps represent a sequence of tasks that will be executed as part of the job
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn global add turbo
- run: npx nps prepare.ci.api
- run: npx nps build.ci.api
- run: npx nps test.ci.api
================================================
FILE: .github/workflows/web.yaml
================================================
# This is a basic workflow to help you get started with Actions
name: web-ci
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [master]
paths:
- "apps/web/**"
pull_request:
branches: [master]
paths:
- "apps/web/**"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node modules
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn global add turbo
- run: npx nps prepare.ci.web
- run: npx nps build.ci.web
- run: npx nps test.ci.web
================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
node_modules
.pnp
.pnp.js
# testing
coverage
# next.js
.next/
out/
build
**/dist
**/.env
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*
# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
# turbo
.turbo
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2022 Ejaz Ahmed
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Turborepo (NestJS + Prisma + NextJS + Tailwind + Typescript + Jest) Starter
This is fullstack turborepo starter. It comes with the following features.
- ✅ Turborepo
- ✅ Nestjs
- ✅ Env Config with Validation
- ✅ Prisma
- ✅ NextJS
- ✅ Tailwind
- ✅ Redux Toolkit Query
- ✅ Testing using Jest
- ✅ Github Actions
- ✅ Reverse Proxy using Nginx
- ✅ Docker Integration
- ✅ Postgres Database
- ✅ Package scripts using NPS
## What's inside?
This turborepo uses [Yarn](https://classic.yarnpkg.com/lang/en/) as a package manager. It includes the following packages/apps:
### Apps and Packages
- `api`: a [NestJS](https://nestjs.com/) app
- `web`: a [Next.js](https://nextjs.org) app
- `ui`: a stub React component library used by `web`.
- `config`: `eslint`, `nginx` and `tailwind` (includes `eslint-config-next` and `eslint-config-prettier`)
- `tsconfig`: `tsconfig.json`s used throughout the monorepo
Each package/app is 100% [TypeScript](https://www.typescriptlang.org/).
### Utilities
This turborepo has some additional tools already setup for you:
- [Node Package Scripts](https://github.com/sezna/nps#readme) for automation scripts
- [TypeScript](https://www.typescriptlang.org/) for static type checking
- [ESLint](https://eslint.org/) for code linting
- [Prettier](https://prettier.io) for code formatting
## Setup
This starter kit is using turborepo and yarn workspaces for monorepo workflow.
### Prerequisites
- Install nps by running
```
npm i -g nps
```
- Make sure docker and docker-compose are
installed. Refer to docs for your operating system.
### Configure Environment
- Frontend
- `cd apps/web && cp .env.example .env`
- Backend
- `cd apps/api && cp .env.example .env`
### Install Dependencies
Make sure you are at root of the project and just run
```
nps prepare
```
### Build
To build all apps and packages, run the following command at the root of project:
```
nps build
```
### Develop
To develop all apps and packages, run the following command at the root of project:
```
nps dev
```
The app should be running at `http://localhost` with reverse proxy configured.
## Other available commands
Run `nps` in the terminal to see list of all available commands.
================================================
FILE: apps/api/.eslintrc.js
================================================
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module',
tsconfigRootDir: __dirname,
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
================================================
FILE: apps/api/.prettierrc
================================================
{
"singleQuote": true,
"trailingComma": "all"
}
================================================
FILE: apps/api/Dockerfile
================================================
FROM node:16-alpine AS builder
RUN apk update
# Set working directory
WORKDIR /app
RUN yarn global add turbo
COPY . .
RUN turbo prune --scope=api --docker
# Add lockfile and package.json's of isolated subworkspace
FROM node:16-alpine AS installer
RUN apk update
WORKDIR /app
COPY --from=builder /app/out/json/ .
COPY --from=builder /app/out/yarn.lock ./yarn.lock
COPY --from=builder /app/turbo.json ./turbo.json
COPY --from=builder /app/apps/api/prisma ./prisma
RUN yarn install --frozen-lockfile
RUN yarn prisma generate
FROM node:16-alpine AS sourcer
WORKDIR /app
COPY --from=installer /app/ .
COPY --from=builder /app/out/full/ .
COPY .gitignore .gitignore
RUN yarn turbo run build --scope=api --include-dependencies --no-deps
FROM node:16-alpine as runner
WORKDIR /app
COPY --from=sourcer /app/ .
CMD [ "node", "apps/api/dist/main.js" ]
================================================
FILE: apps/api/README.md
================================================