diff --git a/.vscode/settings.json b/.vscode/settings.json index 2cb759a..3a9a8fe 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,7 +4,12 @@ "**/node_modules": true, "**/.next": true, "**/dist": true, - "**/yarn.lock": true + "**/yarn.lock": true, + "**/bun.lockb": true }, - "eslint.workingDirectories": ["./apps/storefront", "./apps/admin", "./apps/storefront/.react-email"] + "eslint.workingDirectories": [ + "./apps/storefront", + "./apps/admin", + "./apps/storefront/.react-email" + ] } diff --git a/README.md b/README.md index d6c1387..5258b4a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,14 @@ Welcome to the open-source Next.js E-Commerce Storefront with Admin Panel projec - [x] [**Next Metadata API**](https://nextjs.org/docs/api-reference/metadata) for SEO handling. - [ ] Comprehensive implementations for i18n. +## 2️⃣ Why are there 2 apps in the app folder? + +This project is made up of 2 separate apps ( admin and storefront ) which should be deployed separately. If you are deploying with Vercel you should create 2 different apps. + +![image](https://github.com/Accretence/next-prisma-tailwind-ecommerce/assets/45223699/f5adc1ac-9dbb-46cb-bb6e-a8db15883348) + +Under the general tab there is a Root Directory option, for the admin app you should put in "apps/admin" and for the storefront app you should put in "apps/storefront". + ## 🔐 Authentication The authentication is handled using JWT tokens stored in cookies and verified inside the `middleware.ts` file. The middleware function takes in the HTTP request, reads the `token` cookie and if the JWT is successfully verified, it sets the `X-USER-ID` header with the userId as the value, otherwise the request is sent back with 401 status. @@ -58,26 +66,26 @@ cp .env.example .env Get all dependencies sorted. ```sh -yarn install +bun install ``` Bring your database to life with pushing the database schema. ```bash -yarn db:push +bun run db:push ``` ```sh -yarn dev +bun run dev ``` ## 🔑 Database Prisma ORM can use any PostgreSQL database. [Supabase is the easiest to work with.](https://www.prisma.io/docs/guides/database/supabase) Simply set `DATABASE_URL` in your `.env` file to work. -### `yarn db` +### `bun run db` -This project exposes a package.json script for accessing prisma via `yarn db:`. You should always try to use this script when interacting with prisma locally. +This project exposes a package.json script for accessing prisma via `bun run db:`. You should always try to use this script when interacting with prisma locally. ### Making changes to the database schema diff --git a/apps/admin/package.json b/apps/admin/package.json index 31d0626..3702401 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -3,7 +3,6 @@ "version": "0.1.0", "private": true, "scripts": { - "yarn": "yarn", "dev": "next dev -p 8888", "build": "next build", "start": "next start", diff --git a/apps/storefront/.react-email/package.json b/apps/storefront/.react-email/package.json index c123065..1bd3b2e 100644 --- a/apps/storefront/.react-email/package.json +++ b/apps/storefront/.react-email/package.json @@ -4,7 +4,6 @@ "description": "The React Email preview application", "license": "MIT", "scripts": { - "yarn": "yarn", "dev": "next dev", "build": "next build", "start": "next start", diff --git a/apps/storefront/Dockerfile b/apps/storefront/Dockerfile index 6591915..a28d872 100644 --- a/apps/storefront/Dockerfile +++ b/apps/storefront/Dockerfile @@ -5,17 +5,17 @@ FROM node:18-alpine AS builder WORKDIR /app # Install dependencies -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile +COPY package.json bun.lockb ./ +RUN bun install --frozen-lockfile # Copy the rest of the application code COPY . . # Generate Prisma client -RUN yarn prisma generate +RUN bun prisma generate # Build the Next.js application -RUN yarn build +RUN bun run build # Stage 2: Run the application FROM node:18-alpine AS runner @@ -27,8 +27,8 @@ ENV NODE_ENV=production WORKDIR /app # Install only production dependencies -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile --production +COPY package.json bun.lockb ./ +RUN bun install --frozen-lockfile --production # Copy built application from the builder stage COPY --from=builder /app/.next ./.next @@ -40,4 +40,4 @@ COPY --from=builder /app/node_modules ./node_modules EXPOSE 3000 # Start the Next.js application -CMD ["yarn", "start"] +CMD ["bun", "run", "start"] diff --git a/apps/storefront/package.json b/apps/storefront/package.json index 1b758ce..6cd719d 100644 --- a/apps/storefront/package.json +++ b/apps/storefront/package.json @@ -6,7 +6,6 @@ }, "license": "MIT", "scripts": { - "yarn": "yarn", "dev": "next dev -p 7777", "build": "next build", "start": "next start", diff --git a/package.json b/package.json index 643b8ea..bd97be0 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,27 @@ { - "name": "next-prisma-tailwind-ecommerce", - "version": "1.0.0", - "scripts": { - "prepare": "husky install", - "update": "npx npm-check-updates -u" - }, - "author": { - "name": "Sesto", - "url": "https://github.com/sesto-dev" - }, - "license": "MIT", - "devDependencies": { - "@commitlint/cli": "^19.5.0", - "@commitlint/config-conventional": "^19.5.0", - "@trivago/prettier-plugin-sort-imports": "^4.3.0", - "@typescript-eslint/eslint-plugin": "^8.8.1", - "@typescript-eslint/parser": "^8.8.1", - "eslint": "^9.12.0", - "eslint-config-next": "^14.2.15", - "eslint-plugin-react": "^7.37.1", - "husky": "^9.1.6", - "lint-staged": "^15.2.10", - "prettier": "^3.3.3", - "prettier-plugin-tailwindcss": "^0.6.8" - }, - "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" + "name": "next-prisma-tailwind-ecommerce", + "version": "1.0.0", + "scripts": { + "prepare": "husky install", + "update": "npx npm-check-updates -u" + }, + "author": { + "name": "Sesto", + "url": "https://github.com/sesto-dev" + }, + "license": "MIT", + "devDependencies": { + "@commitlint/cli": "^19.5.0", + "@commitlint/config-conventional": "^19.5.0", + "@trivago/prettier-plugin-sort-imports": "^4.3.0", + "@typescript-eslint/eslint-plugin": "^8.8.1", + "@typescript-eslint/parser": "^8.8.1", + "eslint": "^9.12.0", + "eslint-config-next": "^14.2.15", + "eslint-plugin-react": "^7.37.1", + "husky": "^9.1.6", + "lint-staged": "^15.2.10", + "prettier": "^3.3.3", + "prettier-plugin-tailwindcss": "^0.6.8" + } } diff --git a/packages/regex/package.json b/packages/regex/package.json index ab37837..b96c0bf 100644 --- a/packages/regex/package.json +++ b/packages/regex/package.json @@ -4,7 +4,6 @@ "description": "Regex Package.", "main": "dist/index.js", "scripts": { - "yarn": "yarn", "publish": "npm publish --access public", "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/packages/rng/package.json b/packages/rng/package.json index f9e0b43..19b6baf 100644 --- a/packages/rng/package.json +++ b/packages/rng/package.json @@ -4,7 +4,6 @@ "description": "RNG Package.", "main": "dist/index.js", "scripts": { - "yarn": "yarn", "publish": "npm publish --access public", "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/packages/slugify/package.json b/packages/slugify/package.json index 1ef3103..4e5b411 100644 --- a/packages/slugify/package.json +++ b/packages/slugify/package.json @@ -4,7 +4,6 @@ "description": "Slugify Package.", "main": "dist/index.js", "scripts": { - "yarn": "yarn", "publish": "npm publish --access public", "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/packages/sms/package.json b/packages/sms/package.json index 7fff18b..fc2e771 100644 --- a/packages/sms/package.json +++ b/packages/sms/package.json @@ -4,7 +4,6 @@ "description": "SMS Package.", "main": "dist/index.js", "scripts": { - "yarn": "yarn", "publish": "npm publish --access public", "build": "tsc", "test": "echo \"Error: no test specified\" && exit 1"