Giter Site home page Giter Site logo

ejazahm3d / fullstack-turborepo-starter Goto Github PK

View Code? Open in Web Editor NEW
454.0 6.0 54.0 247 KB

Fullstack Turborepo starter. Typescript, Nestjs, Nextjs, Tailwind, Prisma, Github Actions, Docker, And Reverse proxy configured

License: MIT License

JavaScript 37.70% Dockerfile 12.99% TypeScript 48.87% CSS 0.44%

fullstack-turborepo-starter's Introduction

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 as a package manager. It includes the following packages/apps:

Apps and Packages

  • api: a NestJS app
  • web: a Next.js 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.jsons used throughout the monorepo

Each package/app is 100% TypeScript.

Utilities

This turborepo has some additional tools already setup for you:

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.

fullstack-turborepo-starter's People

Contributors

ejazahm3d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

fullstack-turborepo-starter's Issues

Good docker image for production? (remove source code)

Hello. I have noticed you haven't removed the source code for minimum image size. Here is my Dockerfile, do you think the find command is a good idea? Also, how would you go about removing source after building them to js from package dependencies or app dependencies in "packages" folder or "apps" folder?

FROM node:18-alpine as deps
RUN apk add --no-cache libc6-compat
RUN apk update

RUN npm i -g turbo pnpm

FROM node:18-alpine As base
RUN apk add --no-cache libc6-compat

RUN apk update

RUN npm i -g turbo 

WORKDIR /app

COPY . .

RUN turbo prune --scope=api --docker

FROM deps as development

WORKDIR /app

# First install the dependencies (as they change less often)
COPY .gitignore .gitignore
COPY turbo.json turbo.json
COPY --from=base /app/out/json/ .
COPY --from=base /app/out/pnpm-lock.yaml ./pnpm-lock.yaml

RUN pnpm install 

# # Build the project
COPY --from=base /app/out/full/ .

CMD ["turbo", "dev"]


FROM deps as builder

WORKDIR /app

COPY --from=development --chown=node:node /app .

RUN pnpm turbo run build --filter=api... 

RUN pnpm install --prod

WORKDIR /app/apps/api

RUN find . ! -name dist ! -name node_modules ! -name .env -maxdepth 1 -mindepth 1 -exec rm -rf {} +

FROM node:18-alpine As production

WORKDIR /app

COPY --chown=node:node --from=builder /app .

WORKDIR /app/apps/api

CMD [ "node", "./dist/src/main.js" ]

Nps prepare fails

Hi, I cloned this repo and ran

npm i -g nps

Afterwards I went to the root of the project's directory and ran

nps prepare

But I get following error:

nps prepare
nps is executing `prepare` : nps prepare.web prepare.api
nps is executing `prepare.web` : yarn
/bin/sh: yarn: command not found
The script called "prepare.web" which runs "yarn" failed with exit code 127 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code
The script called "prepare" which runs "nps prepare.web prepare.api" failed with exit code 127 https://github.com/sezna/nps/blob/master/other/ERRORS_AND_WARNINGS.md#failed-with-exit-code

Any ideas about what this is related to?

NestJS doesen't restart when I modify scripts in the packages folder

Hello,
I made a similar project like yours and I have an issue with what I mentioned in the title of that issue. My tsconfigs are the same like yours. I made a simple common package into the packages folder, and I installed like it should be when work with workspaces. In the NextJS project it works well, so when I make modification in that common package the NextJS detect it and restart the application, but the NestJS doesent detect it, I have to restart manually, and it is very inconvenient. In that common package also there is a dev script in the package json, so when I run turbo run dev, the ts files are transpiled into js file automatically, and also it watching the changes.
So I don't know why is happenning, maybe you know what is the solution. I hope I explaind understandable.

I link my repo, so you can check it: https://github.com/kisstamasj/nextjs-nestjs-pnpm
After clone the repo, you sould switch to the turbo_test branch

You don't have to do anything with the infra folder, except you have to copy the env.example, but I still just testing without docker and db.
I would pretiate your help.
Have a nice day/evening.

how to split prisma into its own packages?

Hi there!

This is a really cool repo, thanks for creating this.. at the moment I have a similar setup to yours, but the difference is i want to split the prisma into its own package to reuse the type definition between client and server.

At the moment I can't seem to make it work with the server since it says:

core:dev: /home/robertwt7/Development/hublr/packages/database/src/index.ts:1
core:dev: export * from "@prisma/client";
core:dev: ^^^^^^
core:dev: 
core:dev: SyntaxError: Unexpected token 'export'

However for the client it works fine, I am using very similar setup to yours for the tsconfig.json and was hoping to get your insights if you have. do i need to build the database package before using it with NestJS? weirdly it works just fine for the NextJS app

Newbie question

I'm pretty new to this kind of project structure and I'm wondering how I can test those endpoints I created.
I added several endpoints to the backend repo (inside api directory), but couldn't manage to test them on any of these platforms (postman, curl, chrome-browser...).

What is the URL of the backend running?

(I guess, we could have a Discussion section on this repo, so that we can share our experience and ideas) 🙏

Newbie question #2

Can you please show me how to add npm/yarn packages? I am trying to install packages in nestjs apps/api folder but it not working

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.