From 1d8657f5b366dd92fee8b3875693448c7659c45f Mon Sep 17 00:00:00 2001 From: Harsh Mahadev Duche Date: Thu, 1 Aug 2024 13:49:51 +0530 Subject: [PATCH] dockerizing user-app --- apps/merchant-app/app/api/user/route.ts | 17 ----- apps/user-app/components/HomeChart.tsx | 17 ++--- apps/user-app/components/OnRampTrans.tsx | 6 +- apps/user-app/components/P2pTransfer.tsx | 86 +++++++++++++----------- docker/Dockerfile.user | 18 +++++ package-lock.json | 4 +- package.json | 4 +- 7 files changed, 79 insertions(+), 73 deletions(-) delete mode 100644 apps/merchant-app/app/api/user/route.ts create mode 100644 docker/Dockerfile.user diff --git a/apps/merchant-app/app/api/user/route.ts b/apps/merchant-app/app/api/user/route.ts deleted file mode 100644 index 3e5d35b..0000000 --- a/apps/merchant-app/app/api/user/route.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { NextResponse } from "next/server" -import { PrismaClient } from "@repo/db/client"; - -const client = new PrismaClient(); - - -export const GET = async () => { - await client.user.create({ - data: { - email: "", - name: "" - } - }) - return NextResponse.json({ - message: "hi there" - }) -} \ No newline at end of file diff --git a/apps/user-app/components/HomeChart.tsx b/apps/user-app/components/HomeChart.tsx index 7d536bb..87137ab 100644 --- a/apps/user-app/components/HomeChart.tsx +++ b/apps/user-app/components/HomeChart.tsx @@ -1,22 +1,20 @@ -"use client" +"use client"; -import { TrendingUp } from "lucide-react" -import { CartesianGrid, Line, LineChart, XAxis } from "recharts" +import { CartesianGrid, Line, LineChart, XAxis } from "recharts"; import { Card, CardContent, CardDescription, - CardFooter, CardHeader, CardTitle, -} from "./ui/card" +} from "./ui/card"; import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, -} from "./ui/chart" +} from "./ui/chart"; const chartData = [ { month: "January", expenses: 186 }, { month: "February", expenses: 305 }, @@ -24,14 +22,14 @@ const chartData = [ { month: "April", expenses: 73 }, { month: "May", expenses: 209 }, { month: "June", expenses: 214 }, -] +]; const chartConfig = { expenses: { label: "Expenses", color: "purple", }, -} satisfies ChartConfig +} satisfies ChartConfig; export function ChartComp() { return ( @@ -72,7 +70,6 @@ export function ChartComp() { - - ) + ); } diff --git a/apps/user-app/components/OnRampTrans.tsx b/apps/user-app/components/OnRampTrans.tsx index 5af448d..9d66067 100644 --- a/apps/user-app/components/OnRampTrans.tsx +++ b/apps/user-app/components/OnRampTrans.tsx @@ -1,10 +1,6 @@ import { Card, CardContent, CardDescription, CardTitle, CardHeader } from "./ui/card"; -enum TransactionType { - Deposit = 'Deposit', - Withdrawal = 'Withdrawal', - Transfer = 'Transfer', -} + export default function OnRampTransCard({ diff --git a/apps/user-app/components/P2pTransfer.tsx b/apps/user-app/components/P2pTransfer.tsx index c7d882b..70bd9a5 100644 --- a/apps/user-app/components/P2pTransfer.tsx +++ b/apps/user-app/components/P2pTransfer.tsx @@ -1,47 +1,57 @@ -"use client" +"use client"; -import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./ui/card" -import { Button } from "@repo/ui/button" -import { Input } from "./ui/input" -import { Select } from "./ui/select" -import { useState } from "react" -import { CreateP2PTransaction } from "../app/lib/actions/P2pTxnsAction" +import { Card, CardContent, CardHeader, CardTitle } from "./ui/card"; +import { Button } from "@repo/ui/button"; +import { Input } from "./ui/input"; +import { useState } from "react"; +import { CreateP2PTransaction } from "../app/lib/actions/P2pTxnsAction"; export default function P2pTransfer() { - const [amount, setAmount] = useState(0) - const [peerPhn, setPeerPhn] = useState("") - return( - + const [amount, setAmount] = useState(0); + const [peerPhn, setPeerPhn] = useState(""); + return ( + + Send amount - - -
-

Phone No.

- { - setPeerPhn(e.target.value) - }} placeholder='Peers phone no. ' /> -
-

Amount

- { - setAmount(Number(e.target.value)) - }} placeholder='Enter Amount' /> -
+ +
+

Phone No.

+ { + setPeerPhn(e.target.value); + }} + placeholder="Peers phone no. " + /> +
+

Amount

+ { + setAmount(Number(e.target.value)); + }} + placeholder="Enter Amount" + /> +
-
- -
- +
+
+ +
-
- - + - ) -} \ No newline at end of file + ); +} diff --git a/docker/Dockerfile.user b/docker/Dockerfile.user new file mode 100644 index 0000000..d8cde5b --- /dev/null +++ b/docker/Dockerfile.user @@ -0,0 +1,18 @@ +FROM node:20.12.0-alpine3.19 + +WORKDIR /usr/src/app + +COPY package.json package-lock.json turbo.json tsconfig.json ./ + +COPY apps ./apps +COPY packages ./packages + +# Install dependencies +RUN npm install +# Can you add a script to the global package.json that does this? +RUN npm run db:generate + +# Can you filter the build down to just one app? +RUN npm run build + +CMD ["npm", "run", "start-user-app"] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b618385..c300303 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,8 @@ "packages/*" ], "dependencies": { - "axios": "^1.7.2" + "axios": "^1.7.2", + "bcrypt": "^5.0.1" }, "devDependencies": { "@repo/eslint-config": "*", @@ -4090,6 +4091,7 @@ "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", "integrity": "sha512-AGBHOG5hPYZ5Xl9KXzU5iKq9516yEmvCKDg3ecP5kX2aB6UqTeXZxk2ELnDgDm6BQSMlLt9rDB4LoSMx0rYwww==", "hasInstallScript": true, + "license": "MIT", "dependencies": { "@mapbox/node-pre-gyp": "^1.0.11", "node-addon-api": "^5.0.0" diff --git a/package.json b/package.json index ea5e350..ebccb6f 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "dev": "turbo dev", "lint": "turbo lint", "format": "prettier --write \"**/*.{ts,tsx,md}\"", - "db:generate":"cd packages/db && npx prisma generate" - + "db:generate": "cd packages/db && npx prisma generate", + "start-user-app": "cd ./apps/user-app && npm run start" }, "devDependencies": { "@repo/eslint-config": "*",