Skip to content

Commit

Permalink
update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sesto-dev committed Oct 13, 2024
1 parent f5c1da0 commit e0fad5d
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 47 deletions.
9 changes: 7 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:<command>`. 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:<command>`. You should always try to use this script when interacting with prisma locally.

### Making changes to the database schema

Expand Down
1 change: 0 additions & 1 deletion apps/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"version": "0.1.0",
"private": true,
"scripts": {
"yarn": "yarn",
"dev": "next dev -p 8888",
"build": "next build",
"start": "next start",
Expand Down
1 change: 0 additions & 1 deletion apps/storefront/.react-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"description": "The React Email preview application",
"license": "MIT",
"scripts": {
"yarn": "yarn",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand Down
14 changes: 7 additions & 7 deletions apps/storefront/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"]
1 change: 0 additions & 1 deletion apps/storefront/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
},
"license": "MIT",
"scripts": {
"yarn": "yarn",
"dev": "next dev -p 7777",
"build": "next build",
"start": "next start",
Expand Down
51 changes: 25 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]+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"
}
}
1 change: 0 additions & 1 deletion packages/regex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/rng/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/slugify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion packages/sms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e0fad5d

Please sign in to comment.