Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeSinLiang committed Mar 31, 2024
1 parent 8b600d3 commit b54283e
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 25 deletions.
23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,48 @@
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@solana/pay": "^0.2.5",
"@solana/wallet-adapter-base": "^0.9.5",
"@solana/wallet-adapter-react": "^0.15.4",
"@solana/wallet-adapter-react-ui": "^0.9.6",
"@solana/wallet-adapter-wallets": "^0.19.32",
"@solana/web3.js": "^1.91.1",
"@tanstack/react-query": "4.36.1",
"@trpc/client": "^10.45.2",
"@trpc/next": "^10.45.2",
"@trpc/react-query": "^10.45.2",
"@trpc/server": "^10.45.2",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"body-parser": "^1.20.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cross-env": "^7.0.3",
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"escape-html": "^1.0.3",
"express": "^4.19.1",
"lucide-react": "^0.363.0",
"next": "14.1.4",
"nodemailer": "^6.9.13",
"payload": "^2.11.2",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.51.2",
"react-hook-form": "^7.51.1",
"sonner": "^1.4.41",
"swiper": "^11.1.0",
"swiper": "^11.0.7",
"tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7",
"ts-node": "^10.9.2",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},
"devDependencies": {
"@types/escape-html": "^1.0.4",
"@types/express": "^4.17.21",
"@types/node": "^20",
"@types/nodemailer": "^6.4.14",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"copyfiles": "^2.4.1",
"eslint": "^8.57.0",
"eslint": "^8",
"eslint-config-next": "14.1.4",
"nodemon": "^3.1.0",
"postcss": "^8",
Expand Down
70 changes: 70 additions & 0 deletions package2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "cna",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "cross-env PAYLOAD_CONFIG_PATH=src/payload-config.ts nodemon",
"generate:types": "cross-env PAYLOAD_CONFIG_PATH=src/payload-config.ts payload generate:types",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@payloadcms/bundler-webpack": "^1.0.6",
"@payloadcms/db-mongodb": "^1.4.3",
"@payloadcms/richtext-lexical": "^0.7.0",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@solana/pay": "^0.2.5",
"@solana/wallet-adapter-base": "^0.9.5",
"@solana/wallet-adapter-react": "^0.15.4",
"@solana/wallet-adapter-react-ui": "^0.9.6",
"@solana/wallet-adapter-wallets": "^0.19.32",
"@solana/web3.js": "^1.91.1",
"@tanstack/react-query": "4.36.1",
"@trpc/client": "^10.45.2",
"@trpc/next": "^10.45.2",
"@trpc/react-query": "^10.45.2",
"@trpc/server": "^10.45.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"cross-env": "^7.0.3",
"dotenv": "^16.4.5",
"escape-html": "^1.0.3",
"express": "^4.19.1",
"lucide-react": "^0.363.0",
"next": "14.1.4",
"nodemailer": "^6.9.13",
"payload": "^2.11.2",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.51.1",
"sonner": "^1.4.41",
"swiper": "^11.0.7",
"tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7",
"ts-node": "^10.9.2",
"zod": "^3.22.4",
"zustand": "^4.5.2"
},
"devDependencies": {
"@types/escape-html": "^1.0.4",
"@types/express": "^4.17.21",
"@types/node": "^20",
"@types/nodemailer": "^6.4.14",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.4",
"nodemon": "^3.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
11 changes: 0 additions & 11 deletions src/get-payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,11 @@ import dotenv from 'dotenv'
import path from 'path'
import type { InitOptions } from 'payload/config'
import payload, { Payload } from 'payload'
import nodemailer from 'nodemailer'

dotenv.config({
path: path.resolve(__dirname, '../.env'),
})

const transporter = nodemailer.createTransport({
host: 'smtp.resend.com',
secure: true,
port: 465,
auth: {
user: 'resend',
pass: process.env.RESEND_API_KEY,
},
})

let cached = (global as any).payload

if (!cached) {
Expand Down
12 changes: 6 additions & 6 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ const start = async () => {
return
}

const cartRouter = express.Router()
const checkoutRouter = express.Router()

cartRouter.use(payload.authenticate)
checkoutRouter.use(payload.authenticate)

cartRouter.get('/', (req, res) => {
checkoutRouter.get('/', (req, res) => {
const request = req as PayloadRequest

if (!request.user)
return res.redirect('/sign-in?origin=cart')
return res.redirect('/sign-in?origin=checkout')

const parsedUrl = parse(req.url, true)
const { query } = parsedUrl

return nextApp.render(req, res, '/cart', query)
return nextApp.render(req, res, '/checkout', query)
})

app.use('/cart', cartRouter)
app.use('/checkout', checkoutRouter)

app.use(
"/api/trpc",
Expand Down

0 comments on commit b54283e

Please sign in to comment.