Skip to content

Commit b03c57f

Browse files
committed
0.1.0v
Stable
1 parent 328b46b commit b03c57f

File tree

168 files changed

+24032
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+24032
-0
lines changed

.dockerignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
4+
node_modules
5+
.pnp
6+
.pnp.js
7+
8+
# Testing
9+
coverage
10+
11+
# Turbo
12+
.turbo
13+
14+
# Vercel
15+
.vercel
16+
17+
# Build Outputs
18+
.next/
19+
out/
20+
build
21+
dist
22+
23+
# Data
24+
data
25+
26+
27+
# Debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
32+
# Misc
33+
.DS_Store
34+
*.pem

.github/workflows/ci-action.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Continuous Integration Action
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- production
7+
- bugfix/global
8+
pull_request:
9+
branches:
10+
- main
11+
- production
12+
- bugfix/global
13+
jobs:
14+
build:
15+
name: Build and test
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
- name: Set up Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: 20
25+
- name: Install dependencies
26+
run: npm install
27+
- name: Run build
28+
run: npm run build

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# Dependencies
4+
node_modules
5+
.pnp
6+
.pnp.js
7+
8+
# Local env files
9+
.env
10+
.env.local
11+
.env.development.local
12+
.env.test.local
13+
.env.production.local
14+
15+
# Testing
16+
coverage
17+
18+
# Turbo
19+
.turbo
20+
21+
# Vercel
22+
.vercel
23+
24+
# Build Outputs
25+
.next/
26+
out/
27+
build
28+
dist
29+
30+
# Data
31+
data
32+
33+
34+
# Debug
35+
npm-debug.log*
36+
yarn-debug.log*
37+
yarn-error.log*
38+
39+
# Misc
40+
.DS_Store
41+
*.pem

README.md

Whitespace-only changes.

apps/backend/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "backend",
3+
"version": "0.1.0",
4+
"scripts": {
5+
"build": "npx tsc -b",
6+
"dev:production": "node --trace-warnings ./dist/server.js",
7+
"dev": "concurrently \"tsc -w\" \"nodemon dist/server.js\""
8+
},
9+
"type": "module",
10+
"dependencies": {
11+
"@repo/postgres_db": "*",
12+
"axios": "^1.11.0",
13+
"cors": "^2.8.5",
14+
"cron": "^4.3.3",
15+
"dotenv": "^16.0.3",
16+
"express": "^5.1.0",
17+
"googleapis": "^158.0.0",
18+
"ioredis": "^5.7.0",
19+
"node-mailjet": "^6.0.9",
20+
"ollama": "^0.5.17",
21+
"prisma": "^6.14.0",
22+
"prom-client": "^15.1.3"
23+
},
24+
"devDependencies": {
25+
"@repo/typescript-config": "*",
26+
"@repo/eslint-config": "*",
27+
"@repo/types": "*",
28+
"@types/cors": "^2.8.19",
29+
"@types/express": "^5.0.3",
30+
"@types/node": "^22.17.2",
31+
"concurrently": "^9.2.1",
32+
"nodemon": "^3.1.10",
33+
"ts-node": "^10.9.2",
34+
"typescript": "^5.9.2"
35+
}
36+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import express, { Request, Response } from "express";
2+
3+
const Router = express.Router();
4+
5+
Router.get("/", async (req: Request, res: Response): Promise<any> => {
6+
res.status(200).send("Yet to implement!")
7+
});
8+
9+
export default Router;
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
import express, { Request, Response } from "express";
2+
import { CustomError, Result } from "@repo/types/backend";
3+
import { prisma } from "@repo/postgres_db/prisma";
4+
import axios from "axios";
5+
import { getUserCookie } from "../endpoints.js";
6+
import { UserDetails } from "@repo/types/web";
7+
import { platform } from "os";
8+
import { totalErrors } from "../server.js";
9+
10+
const Router = express.Router();
11+
12+
Router.get("/", async (req: Request, res: Response): Promise<any> => {
13+
try {
14+
const { userId } = res.locals;
15+
if (!userId) {
16+
throw new CustomError(
17+
"Passed authentication and userId is missing.",
18+
"Server Error!"
19+
);
20+
}
21+
22+
const userData = await prisma.user.findUnique({
23+
where: {
24+
id: userId,
25+
},
26+
select: {
27+
firstName: true,
28+
lastName: true,
29+
email: true,
30+
contact: true,
31+
},
32+
});
33+
34+
return res.status(200).json(
35+
new Result({
36+
success: true,
37+
data: {
38+
"First Name": userData?.firstName,
39+
"Last Name": userData?.lastName,
40+
Email: userData?.email,
41+
Contact: userData?.contact,
42+
},
43+
})
44+
);
45+
} catch (error: any) {
46+
console.warn(error);
47+
totalErrors.inc();
48+
return res.status(500).json(
49+
new Result({
50+
success: false,
51+
})
52+
);
53+
}
54+
});
55+
56+
Router.put("/", async (req: Request, res: Response): Promise<any> => {
57+
try {
58+
const { userId } = res.locals;
59+
const { "First Name": firstName, "Last Name": lastName } = req.body;
60+
61+
if (!userId || !firstName || !lastName) {
62+
throw new CustomError(
63+
"Kindly provide all the required parameters.",
64+
"Invalid credentials!"
65+
);
66+
}
67+
68+
const userData = await prisma.user.update({
69+
where: {
70+
id: userId,
71+
},
72+
data: {
73+
firstName,
74+
lastName,
75+
},
76+
});
77+
78+
return res.status(200).json(
79+
new Result({
80+
success: true,
81+
data: {
82+
userData,
83+
},
84+
})
85+
);
86+
} catch (error: any) {
87+
console.warn(error);
88+
totalErrors.inc();
89+
return res.status(500).json(
90+
new Result({
91+
success: false,
92+
})
93+
);
94+
}
95+
});
96+
97+
export default Router;
98+
99+
Router.get(
100+
"/userDetails",
101+
async (req: Request, res: Response): Promise<any> => {
102+
try {
103+
const cookie = getUserCookie(req);
104+
105+
const result = await axios({
106+
url: "https://seller.indiamart.com/miscreact/ajaxrequest/seller/UserDetails/?sourcescreen=BusinessProfile",
107+
headers: {
108+
accept: "*/*",
109+
"accept-language": "en-US,en;q=0.6",
110+
"cache-control": "no-cache",
111+
"content-type": "application/json",
112+
pragma: "no-cache",
113+
priority: "u=1, i",
114+
"sec-ch-ua":
115+
'"Not)A;Brand";v="8", "Chromium";v="138", "Brave";v="138"',
116+
"sec-ch-ua-mobile": "?0",
117+
"sec-ch-ua-platform": platform(),
118+
"sec-fetch-dest": "empty",
119+
"sec-fetch-mode": "cors",
120+
"sec-fetch-site": "same-origin",
121+
"sec-gpc": "1",
122+
cookie,
123+
Referer: "https://seller.indiamart.com/companyprofile/manageprofile/",
124+
},
125+
method: "POST",
126+
});
127+
128+
const userDetails: UserDetails = {
129+
firstName: result.data.ceo_fname,
130+
lastName: result.data.ceo_lname,
131+
glid: result.data.glid,
132+
country: result.data.country,
133+
companyName: result.data.company_name,
134+
phoneNumber: result.data.glusr_usr_ph_mobile,
135+
image: result.data.image,
136+
};
137+
138+
return res.status(200).json(
139+
new Result({
140+
success: true,
141+
data: userDetails,
142+
})
143+
);
144+
} catch (error: any) {
145+
console.warn(error);
146+
totalErrors.inc();
147+
return res.status(500).json(
148+
new Result({
149+
success: false,
150+
})
151+
);
152+
}
153+
}
154+
);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import express, { Request, Response } from "express";
2+
import { prisma } from "@repo/postgres_db/prisma";
3+
import { Result } from "@repo/types/backend";
4+
import { totalErrors } from "../server.js";
5+
6+
const Router = express.Router();
7+
8+
Router.delete("/", async (req: Request, res: Response): Promise<any> => {
9+
try {
10+
const { userId } = res.locals;
11+
12+
await prisma.user.delete({
13+
where: {
14+
id: userId,
15+
},
16+
});
17+
18+
req.headers.cookie?.split("; ").forEach((v) => {
19+
const cookieName = v.split("=");
20+
res.clearCookie(cookieName[0]!);
21+
});
22+
23+
return res.status(204).json(
24+
new Result({
25+
success: true,
26+
info: "Account deleted successfully!",
27+
redirectUrl: "/auth/login",
28+
})
29+
);
30+
} catch (error: any) {
31+
console.warn(error);
32+
totalErrors.inc();
33+
res.status(500).json(
34+
new Result({
35+
success: false,
36+
})
37+
);
38+
}
39+
});
40+
41+
export default Router;

0 commit comments

Comments
 (0)