Antaram commited on
Commit
9eab1a6
ยท
verified ยท
1 Parent(s): 54e81c6

Upload 18 files

Browse files
.dockerignore ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Ignore node_modules
2
+ node_modules/
3
+
4
+ # Ignore development files
5
+ .env
6
+ .env.local
7
+ .env.development
8
+
9
+ # Ignore git
10
+ .git/
11
+ .gitignore
12
+
13
+ # Ignore logs
14
+ *.log
15
+ npm-debug.log*
16
+
17
+ # Ignore test files
18
+ *.test.js
19
+ test/
20
+
21
+ # Ignore documentation
22
+ README.md
23
+ docs/
24
+
25
+ # Ignore database scripts (no seeding/reset)
26
+ src/db/seed.js
27
+ src/db/reset.js
.gitattributes CHANGED
@@ -1,35 +1,35 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ node_modules/
2
+ .env
3
+ *.log
4
+ .DS_Store
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use lightweight Node.js Alpine image
2
+ FROM node:18-alpine
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Copy package files
8
+ COPY package*.json ./
9
+
10
+ # Install production dependencies only
11
+ RUN npm ci --only=production
12
+
13
+ # Copy source code
14
+ COPY src ./src
15
+
16
+ # Expose Hugging Face port
17
+ EXPOSE 7860
18
+
19
+ # Set NODE_ENV to production
20
+ ENV NODE_ENV=production
21
+ ENV PORT=7860
22
+
23
+ # Start the server
24
+ CMD ["node", "src/server.js"]
QUICKSTART.md ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quick Start Guide
2
+
3
+ ## โœ… Backend is Ready!
4
+
5
+ Your complete Express.js backend with PostgreSQL is now running on **http://localhost:4000**
6
+
7
+ ## ๐Ÿš€ What's Been Done
8
+
9
+ 1. โœ… **Database Setup**
10
+ - Created 7 tables with proper relationships
11
+ - Added indexes for performance
12
+ - Seeded with sample data
13
+
14
+ 2. โœ… **API Endpoints Working**
15
+ - Parties API: `/api/parties`
16
+ - Mirchi Types API: `/api/mirchi-types`
17
+ - Lots API: `/api/lots`
18
+ - Transactions API: `/api/transactions`
19
+
20
+ 3. โœ… **Sample Data Loaded**
21
+ - 5 Parties (Ramesh Traders, Suresh & Co, etc.)
22
+ - 5 Mirchi Types (Teja, Byadgi, Guntur Sannam, etc.)
23
+ - 3 Active Lots with stock
24
+ - 1 Sample Transaction
25
+
26
+ ## ๐Ÿ”ง Available Commands
27
+
28
+ ```bash
29
+ cd backend
30
+
31
+ # Start server (currently running)
32
+ npm start
33
+
34
+ # Development mode with auto-reload
35
+ npm run dev
36
+
37
+ # Database management
38
+ npm run migrate # Create tables
39
+ npm run seed # Add sample data
40
+ npm run reset # Drop all tables (โš ๏ธ use with caution)
41
+ ```
42
+
43
+ ## ๐Ÿ“ก Test the API
44
+
45
+ **Health Check:**
46
+ ```bash
47
+ curl http://localhost:4000/health
48
+ ```
49
+
50
+ **Get All Parties:**
51
+ ```bash
52
+ curl http://localhost:4000/api/parties
53
+ ```
54
+
55
+ **Get All Mirchi Types:**
56
+ ```bash
57
+ curl http://localhost:4000/api/mirchi-types
58
+ ```
59
+
60
+ **Get All Transactions:**
61
+ ```bash
62
+ curl http://localhost:4000/api/transactions
63
+ ```
64
+
65
+ ## ๐Ÿ”— Connect Frontend
66
+
67
+ Update your frontend's `db.ts` file:
68
+ - The API_BASE is already set to `http://localhost:4000/api`
69
+ - All endpoints are ready to use
70
+ - No changes needed in frontend code!
71
+
72
+ ## ๐Ÿ“Š Database Schema
73
+
74
+ **Tables:**
75
+ 1. `parties` - Customer/supplier management
76
+ 2. `mirchi_types` - Chili pepper varieties
77
+ 3. `lots` - Inventory with stock tracking
78
+ 4. `transactions` - Purchase/sales bills
79
+ 5. `transaction_items` - Line items
80
+ 6. `expenses` - Transaction expenses
81
+ 7. `payments` - Payment records
82
+
83
+ ## ๐ŸŽฏ Next Steps
84
+
85
+ 1. Keep the backend server running
86
+ 2. Start your frontend: `cd frontend && npm run dev`
87
+ 3. Test the complete application!
88
+
89
+ ## ๐Ÿ’ก Features
90
+
91
+ - โœ… Full CRUD operations for all entities
92
+ - โœ… Automatic stock management (lots)
93
+ - โœ… Party balance tracking
94
+ - โœ… Payment tracking with multiple modes
95
+ - โœ… Support for returns (purchase/sales)
96
+ - โœ… Transaction filtering by party, type, etc.
97
+ - โœ… Proper error handling and validation
98
+
99
+ ## ๐Ÿ› Troubleshooting
100
+
101
+ **Server not starting?**
102
+ - Check if port 4000 is available
103
+ - Verify PostgreSQL connection in `.env`
104
+
105
+ **Database errors?**
106
+ - Run `npm run reset` then `npm run migrate` and `npm run seed`
107
+
108
+ **API not responding?**
109
+ - Check server logs in terminal
110
+ - Verify server is running on port 4000
package-lock.json ADDED
@@ -0,0 +1,1406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "pattanshetty-backend",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "pattanshetty-backend",
9
+ "version": "1.0.0",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "cors": "^2.8.5",
13
+ "dotenv": "^16.3.1",
14
+ "express": "^4.18.2",
15
+ "pg": "^8.11.3",
16
+ "uuid": "^9.0.1"
17
+ },
18
+ "devDependencies": {
19
+ "nodemon": "^3.0.1"
20
+ }
21
+ },
22
+ "node_modules/accepts": {
23
+ "version": "1.3.8",
24
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
25
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
26
+ "license": "MIT",
27
+ "dependencies": {
28
+ "mime-types": "~2.1.34",
29
+ "negotiator": "0.6.3"
30
+ },
31
+ "engines": {
32
+ "node": ">= 0.6"
33
+ }
34
+ },
35
+ "node_modules/anymatch": {
36
+ "version": "3.1.3",
37
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
38
+ "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
39
+ "dev": true,
40
+ "license": "ISC",
41
+ "dependencies": {
42
+ "normalize-path": "^3.0.0",
43
+ "picomatch": "^2.0.4"
44
+ },
45
+ "engines": {
46
+ "node": ">= 8"
47
+ }
48
+ },
49
+ "node_modules/array-flatten": {
50
+ "version": "1.1.1",
51
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
52
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
53
+ "license": "MIT"
54
+ },
55
+ "node_modules/balanced-match": {
56
+ "version": "1.0.2",
57
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
58
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
59
+ "dev": true,
60
+ "license": "MIT"
61
+ },
62
+ "node_modules/binary-extensions": {
63
+ "version": "2.3.0",
64
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
65
+ "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
66
+ "dev": true,
67
+ "license": "MIT",
68
+ "engines": {
69
+ "node": ">=8"
70
+ },
71
+ "funding": {
72
+ "url": "https://github.com/sponsors/sindresorhus"
73
+ }
74
+ },
75
+ "node_modules/body-parser": {
76
+ "version": "1.20.3",
77
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
78
+ "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
79
+ "license": "MIT",
80
+ "dependencies": {
81
+ "bytes": "3.1.2",
82
+ "content-type": "~1.0.5",
83
+ "debug": "2.6.9",
84
+ "depd": "2.0.0",
85
+ "destroy": "1.2.0",
86
+ "http-errors": "2.0.0",
87
+ "iconv-lite": "0.4.24",
88
+ "on-finished": "2.4.1",
89
+ "qs": "6.13.0",
90
+ "raw-body": "2.5.2",
91
+ "type-is": "~1.6.18",
92
+ "unpipe": "1.0.0"
93
+ },
94
+ "engines": {
95
+ "node": ">= 0.8",
96
+ "npm": "1.2.8000 || >= 1.4.16"
97
+ }
98
+ },
99
+ "node_modules/brace-expansion": {
100
+ "version": "1.1.12",
101
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
102
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
103
+ "dev": true,
104
+ "license": "MIT",
105
+ "dependencies": {
106
+ "balanced-match": "^1.0.0",
107
+ "concat-map": "0.0.1"
108
+ }
109
+ },
110
+ "node_modules/braces": {
111
+ "version": "3.0.3",
112
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
113
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
114
+ "dev": true,
115
+ "license": "MIT",
116
+ "dependencies": {
117
+ "fill-range": "^7.1.1"
118
+ },
119
+ "engines": {
120
+ "node": ">=8"
121
+ }
122
+ },
123
+ "node_modules/bytes": {
124
+ "version": "3.1.2",
125
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
126
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
127
+ "license": "MIT",
128
+ "engines": {
129
+ "node": ">= 0.8"
130
+ }
131
+ },
132
+ "node_modules/call-bind-apply-helpers": {
133
+ "version": "1.0.2",
134
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
135
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
136
+ "license": "MIT",
137
+ "dependencies": {
138
+ "es-errors": "^1.3.0",
139
+ "function-bind": "^1.1.2"
140
+ },
141
+ "engines": {
142
+ "node": ">= 0.4"
143
+ }
144
+ },
145
+ "node_modules/call-bound": {
146
+ "version": "1.0.4",
147
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
148
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
149
+ "license": "MIT",
150
+ "dependencies": {
151
+ "call-bind-apply-helpers": "^1.0.2",
152
+ "get-intrinsic": "^1.3.0"
153
+ },
154
+ "engines": {
155
+ "node": ">= 0.4"
156
+ },
157
+ "funding": {
158
+ "url": "https://github.com/sponsors/ljharb"
159
+ }
160
+ },
161
+ "node_modules/chokidar": {
162
+ "version": "3.6.0",
163
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
164
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
165
+ "dev": true,
166
+ "license": "MIT",
167
+ "dependencies": {
168
+ "anymatch": "~3.1.2",
169
+ "braces": "~3.0.2",
170
+ "glob-parent": "~5.1.2",
171
+ "is-binary-path": "~2.1.0",
172
+ "is-glob": "~4.0.1",
173
+ "normalize-path": "~3.0.0",
174
+ "readdirp": "~3.6.0"
175
+ },
176
+ "engines": {
177
+ "node": ">= 8.10.0"
178
+ },
179
+ "funding": {
180
+ "url": "https://paulmillr.com/funding/"
181
+ },
182
+ "optionalDependencies": {
183
+ "fsevents": "~2.3.2"
184
+ }
185
+ },
186
+ "node_modules/concat-map": {
187
+ "version": "0.0.1",
188
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
189
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
190
+ "dev": true,
191
+ "license": "MIT"
192
+ },
193
+ "node_modules/content-disposition": {
194
+ "version": "0.5.4",
195
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
196
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
197
+ "license": "MIT",
198
+ "dependencies": {
199
+ "safe-buffer": "5.2.1"
200
+ },
201
+ "engines": {
202
+ "node": ">= 0.6"
203
+ }
204
+ },
205
+ "node_modules/content-type": {
206
+ "version": "1.0.5",
207
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
208
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
209
+ "license": "MIT",
210
+ "engines": {
211
+ "node": ">= 0.6"
212
+ }
213
+ },
214
+ "node_modules/cookie": {
215
+ "version": "0.7.1",
216
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
217
+ "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
218
+ "license": "MIT",
219
+ "engines": {
220
+ "node": ">= 0.6"
221
+ }
222
+ },
223
+ "node_modules/cookie-signature": {
224
+ "version": "1.0.6",
225
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
226
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
227
+ "license": "MIT"
228
+ },
229
+ "node_modules/cors": {
230
+ "version": "2.8.5",
231
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
232
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
233
+ "license": "MIT",
234
+ "dependencies": {
235
+ "object-assign": "^4",
236
+ "vary": "^1"
237
+ },
238
+ "engines": {
239
+ "node": ">= 0.10"
240
+ }
241
+ },
242
+ "node_modules/debug": {
243
+ "version": "2.6.9",
244
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
245
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
246
+ "license": "MIT",
247
+ "dependencies": {
248
+ "ms": "2.0.0"
249
+ }
250
+ },
251
+ "node_modules/depd": {
252
+ "version": "2.0.0",
253
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
254
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
255
+ "license": "MIT",
256
+ "engines": {
257
+ "node": ">= 0.8"
258
+ }
259
+ },
260
+ "node_modules/destroy": {
261
+ "version": "1.2.0",
262
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
263
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
264
+ "license": "MIT",
265
+ "engines": {
266
+ "node": ">= 0.8",
267
+ "npm": "1.2.8000 || >= 1.4.16"
268
+ }
269
+ },
270
+ "node_modules/dotenv": {
271
+ "version": "16.6.1",
272
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz",
273
+ "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==",
274
+ "license": "BSD-2-Clause",
275
+ "engines": {
276
+ "node": ">=12"
277
+ },
278
+ "funding": {
279
+ "url": "https://dotenvx.com"
280
+ }
281
+ },
282
+ "node_modules/dunder-proto": {
283
+ "version": "1.0.1",
284
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
285
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
286
+ "license": "MIT",
287
+ "dependencies": {
288
+ "call-bind-apply-helpers": "^1.0.1",
289
+ "es-errors": "^1.3.0",
290
+ "gopd": "^1.2.0"
291
+ },
292
+ "engines": {
293
+ "node": ">= 0.4"
294
+ }
295
+ },
296
+ "node_modules/ee-first": {
297
+ "version": "1.1.1",
298
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
299
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
300
+ "license": "MIT"
301
+ },
302
+ "node_modules/encodeurl": {
303
+ "version": "2.0.0",
304
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
305
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
306
+ "license": "MIT",
307
+ "engines": {
308
+ "node": ">= 0.8"
309
+ }
310
+ },
311
+ "node_modules/es-define-property": {
312
+ "version": "1.0.1",
313
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
314
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
315
+ "license": "MIT",
316
+ "engines": {
317
+ "node": ">= 0.4"
318
+ }
319
+ },
320
+ "node_modules/es-errors": {
321
+ "version": "1.3.0",
322
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
323
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
324
+ "license": "MIT",
325
+ "engines": {
326
+ "node": ">= 0.4"
327
+ }
328
+ },
329
+ "node_modules/es-object-atoms": {
330
+ "version": "1.1.1",
331
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
332
+ "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
333
+ "license": "MIT",
334
+ "dependencies": {
335
+ "es-errors": "^1.3.0"
336
+ },
337
+ "engines": {
338
+ "node": ">= 0.4"
339
+ }
340
+ },
341
+ "node_modules/escape-html": {
342
+ "version": "1.0.3",
343
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
344
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
345
+ "license": "MIT"
346
+ },
347
+ "node_modules/etag": {
348
+ "version": "1.8.1",
349
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
350
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
351
+ "license": "MIT",
352
+ "engines": {
353
+ "node": ">= 0.6"
354
+ }
355
+ },
356
+ "node_modules/express": {
357
+ "version": "4.21.2",
358
+ "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
359
+ "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
360
+ "license": "MIT",
361
+ "dependencies": {
362
+ "accepts": "~1.3.8",
363
+ "array-flatten": "1.1.1",
364
+ "body-parser": "1.20.3",
365
+ "content-disposition": "0.5.4",
366
+ "content-type": "~1.0.4",
367
+ "cookie": "0.7.1",
368
+ "cookie-signature": "1.0.6",
369
+ "debug": "2.6.9",
370
+ "depd": "2.0.0",
371
+ "encodeurl": "~2.0.0",
372
+ "escape-html": "~1.0.3",
373
+ "etag": "~1.8.1",
374
+ "finalhandler": "1.3.1",
375
+ "fresh": "0.5.2",
376
+ "http-errors": "2.0.0",
377
+ "merge-descriptors": "1.0.3",
378
+ "methods": "~1.1.2",
379
+ "on-finished": "2.4.1",
380
+ "parseurl": "~1.3.3",
381
+ "path-to-regexp": "0.1.12",
382
+ "proxy-addr": "~2.0.7",
383
+ "qs": "6.13.0",
384
+ "range-parser": "~1.2.1",
385
+ "safe-buffer": "5.2.1",
386
+ "send": "0.19.0",
387
+ "serve-static": "1.16.2",
388
+ "setprototypeof": "1.2.0",
389
+ "statuses": "2.0.1",
390
+ "type-is": "~1.6.18",
391
+ "utils-merge": "1.0.1",
392
+ "vary": "~1.1.2"
393
+ },
394
+ "engines": {
395
+ "node": ">= 0.10.0"
396
+ },
397
+ "funding": {
398
+ "type": "opencollective",
399
+ "url": "https://opencollective.com/express"
400
+ }
401
+ },
402
+ "node_modules/fill-range": {
403
+ "version": "7.1.1",
404
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
405
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
406
+ "dev": true,
407
+ "license": "MIT",
408
+ "dependencies": {
409
+ "to-regex-range": "^5.0.1"
410
+ },
411
+ "engines": {
412
+ "node": ">=8"
413
+ }
414
+ },
415
+ "node_modules/finalhandler": {
416
+ "version": "1.3.1",
417
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
418
+ "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
419
+ "license": "MIT",
420
+ "dependencies": {
421
+ "debug": "2.6.9",
422
+ "encodeurl": "~2.0.0",
423
+ "escape-html": "~1.0.3",
424
+ "on-finished": "2.4.1",
425
+ "parseurl": "~1.3.3",
426
+ "statuses": "2.0.1",
427
+ "unpipe": "~1.0.0"
428
+ },
429
+ "engines": {
430
+ "node": ">= 0.8"
431
+ }
432
+ },
433
+ "node_modules/forwarded": {
434
+ "version": "0.2.0",
435
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
436
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
437
+ "license": "MIT",
438
+ "engines": {
439
+ "node": ">= 0.6"
440
+ }
441
+ },
442
+ "node_modules/fresh": {
443
+ "version": "0.5.2",
444
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
445
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
446
+ "license": "MIT",
447
+ "engines": {
448
+ "node": ">= 0.6"
449
+ }
450
+ },
451
+ "node_modules/fsevents": {
452
+ "version": "2.3.3",
453
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
454
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
455
+ "dev": true,
456
+ "hasInstallScript": true,
457
+ "license": "MIT",
458
+ "optional": true,
459
+ "os": [
460
+ "darwin"
461
+ ],
462
+ "engines": {
463
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
464
+ }
465
+ },
466
+ "node_modules/function-bind": {
467
+ "version": "1.1.2",
468
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
469
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
470
+ "license": "MIT",
471
+ "funding": {
472
+ "url": "https://github.com/sponsors/ljharb"
473
+ }
474
+ },
475
+ "node_modules/get-intrinsic": {
476
+ "version": "1.3.0",
477
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
478
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
479
+ "license": "MIT",
480
+ "dependencies": {
481
+ "call-bind-apply-helpers": "^1.0.2",
482
+ "es-define-property": "^1.0.1",
483
+ "es-errors": "^1.3.0",
484
+ "es-object-atoms": "^1.1.1",
485
+ "function-bind": "^1.1.2",
486
+ "get-proto": "^1.0.1",
487
+ "gopd": "^1.2.0",
488
+ "has-symbols": "^1.1.0",
489
+ "hasown": "^2.0.2",
490
+ "math-intrinsics": "^1.1.0"
491
+ },
492
+ "engines": {
493
+ "node": ">= 0.4"
494
+ },
495
+ "funding": {
496
+ "url": "https://github.com/sponsors/ljharb"
497
+ }
498
+ },
499
+ "node_modules/get-proto": {
500
+ "version": "1.0.1",
501
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
502
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
503
+ "license": "MIT",
504
+ "dependencies": {
505
+ "dunder-proto": "^1.0.1",
506
+ "es-object-atoms": "^1.0.0"
507
+ },
508
+ "engines": {
509
+ "node": ">= 0.4"
510
+ }
511
+ },
512
+ "node_modules/glob-parent": {
513
+ "version": "5.1.2",
514
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
515
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
516
+ "dev": true,
517
+ "license": "ISC",
518
+ "dependencies": {
519
+ "is-glob": "^4.0.1"
520
+ },
521
+ "engines": {
522
+ "node": ">= 6"
523
+ }
524
+ },
525
+ "node_modules/gopd": {
526
+ "version": "1.2.0",
527
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
528
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
529
+ "license": "MIT",
530
+ "engines": {
531
+ "node": ">= 0.4"
532
+ },
533
+ "funding": {
534
+ "url": "https://github.com/sponsors/ljharb"
535
+ }
536
+ },
537
+ "node_modules/has-flag": {
538
+ "version": "3.0.0",
539
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
540
+ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
541
+ "dev": true,
542
+ "license": "MIT",
543
+ "engines": {
544
+ "node": ">=4"
545
+ }
546
+ },
547
+ "node_modules/has-symbols": {
548
+ "version": "1.1.0",
549
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
550
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
551
+ "license": "MIT",
552
+ "engines": {
553
+ "node": ">= 0.4"
554
+ },
555
+ "funding": {
556
+ "url": "https://github.com/sponsors/ljharb"
557
+ }
558
+ },
559
+ "node_modules/hasown": {
560
+ "version": "2.0.2",
561
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
562
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
563
+ "license": "MIT",
564
+ "dependencies": {
565
+ "function-bind": "^1.1.2"
566
+ },
567
+ "engines": {
568
+ "node": ">= 0.4"
569
+ }
570
+ },
571
+ "node_modules/http-errors": {
572
+ "version": "2.0.0",
573
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
574
+ "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
575
+ "license": "MIT",
576
+ "dependencies": {
577
+ "depd": "2.0.0",
578
+ "inherits": "2.0.4",
579
+ "setprototypeof": "1.2.0",
580
+ "statuses": "2.0.1",
581
+ "toidentifier": "1.0.1"
582
+ },
583
+ "engines": {
584
+ "node": ">= 0.8"
585
+ }
586
+ },
587
+ "node_modules/iconv-lite": {
588
+ "version": "0.4.24",
589
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
590
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
591
+ "license": "MIT",
592
+ "dependencies": {
593
+ "safer-buffer": ">= 2.1.2 < 3"
594
+ },
595
+ "engines": {
596
+ "node": ">=0.10.0"
597
+ }
598
+ },
599
+ "node_modules/ignore-by-default": {
600
+ "version": "1.0.1",
601
+ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
602
+ "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
603
+ "dev": true,
604
+ "license": "ISC"
605
+ },
606
+ "node_modules/inherits": {
607
+ "version": "2.0.4",
608
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
609
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
610
+ "license": "ISC"
611
+ },
612
+ "node_modules/ipaddr.js": {
613
+ "version": "1.9.1",
614
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
615
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
616
+ "license": "MIT",
617
+ "engines": {
618
+ "node": ">= 0.10"
619
+ }
620
+ },
621
+ "node_modules/is-binary-path": {
622
+ "version": "2.1.0",
623
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
624
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
625
+ "dev": true,
626
+ "license": "MIT",
627
+ "dependencies": {
628
+ "binary-extensions": "^2.0.0"
629
+ },
630
+ "engines": {
631
+ "node": ">=8"
632
+ }
633
+ },
634
+ "node_modules/is-extglob": {
635
+ "version": "2.1.1",
636
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
637
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
638
+ "dev": true,
639
+ "license": "MIT",
640
+ "engines": {
641
+ "node": ">=0.10.0"
642
+ }
643
+ },
644
+ "node_modules/is-glob": {
645
+ "version": "4.0.3",
646
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
647
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
648
+ "dev": true,
649
+ "license": "MIT",
650
+ "dependencies": {
651
+ "is-extglob": "^2.1.1"
652
+ },
653
+ "engines": {
654
+ "node": ">=0.10.0"
655
+ }
656
+ },
657
+ "node_modules/is-number": {
658
+ "version": "7.0.0",
659
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
660
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
661
+ "dev": true,
662
+ "license": "MIT",
663
+ "engines": {
664
+ "node": ">=0.12.0"
665
+ }
666
+ },
667
+ "node_modules/math-intrinsics": {
668
+ "version": "1.1.0",
669
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
670
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
671
+ "license": "MIT",
672
+ "engines": {
673
+ "node": ">= 0.4"
674
+ }
675
+ },
676
+ "node_modules/media-typer": {
677
+ "version": "0.3.0",
678
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
679
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
680
+ "license": "MIT",
681
+ "engines": {
682
+ "node": ">= 0.6"
683
+ }
684
+ },
685
+ "node_modules/merge-descriptors": {
686
+ "version": "1.0.3",
687
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
688
+ "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
689
+ "license": "MIT",
690
+ "funding": {
691
+ "url": "https://github.com/sponsors/sindresorhus"
692
+ }
693
+ },
694
+ "node_modules/methods": {
695
+ "version": "1.1.2",
696
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
697
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
698
+ "license": "MIT",
699
+ "engines": {
700
+ "node": ">= 0.6"
701
+ }
702
+ },
703
+ "node_modules/mime": {
704
+ "version": "1.6.0",
705
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
706
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
707
+ "license": "MIT",
708
+ "bin": {
709
+ "mime": "cli.js"
710
+ },
711
+ "engines": {
712
+ "node": ">=4"
713
+ }
714
+ },
715
+ "node_modules/mime-db": {
716
+ "version": "1.52.0",
717
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
718
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
719
+ "license": "MIT",
720
+ "engines": {
721
+ "node": ">= 0.6"
722
+ }
723
+ },
724
+ "node_modules/mime-types": {
725
+ "version": "2.1.35",
726
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
727
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
728
+ "license": "MIT",
729
+ "dependencies": {
730
+ "mime-db": "1.52.0"
731
+ },
732
+ "engines": {
733
+ "node": ">= 0.6"
734
+ }
735
+ },
736
+ "node_modules/minimatch": {
737
+ "version": "3.1.2",
738
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
739
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
740
+ "dev": true,
741
+ "license": "ISC",
742
+ "dependencies": {
743
+ "brace-expansion": "^1.1.7"
744
+ },
745
+ "engines": {
746
+ "node": "*"
747
+ }
748
+ },
749
+ "node_modules/ms": {
750
+ "version": "2.0.0",
751
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
752
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
753
+ "license": "MIT"
754
+ },
755
+ "node_modules/negotiator": {
756
+ "version": "0.6.3",
757
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
758
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
759
+ "license": "MIT",
760
+ "engines": {
761
+ "node": ">= 0.6"
762
+ }
763
+ },
764
+ "node_modules/nodemon": {
765
+ "version": "3.1.11",
766
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.11.tgz",
767
+ "integrity": "sha512-is96t8F/1//UHAjNPHpbsNY46ELPpftGUoSVNXwUfMk/qdjSylYrWSu1XavVTBOn526kFiOR733ATgNBCQyH0g==",
768
+ "dev": true,
769
+ "license": "MIT",
770
+ "dependencies": {
771
+ "chokidar": "^3.5.2",
772
+ "debug": "^4",
773
+ "ignore-by-default": "^1.0.1",
774
+ "minimatch": "^3.1.2",
775
+ "pstree.remy": "^1.1.8",
776
+ "semver": "^7.5.3",
777
+ "simple-update-notifier": "^2.0.0",
778
+ "supports-color": "^5.5.0",
779
+ "touch": "^3.1.0",
780
+ "undefsafe": "^2.0.5"
781
+ },
782
+ "bin": {
783
+ "nodemon": "bin/nodemon.js"
784
+ },
785
+ "engines": {
786
+ "node": ">=10"
787
+ },
788
+ "funding": {
789
+ "type": "opencollective",
790
+ "url": "https://opencollective.com/nodemon"
791
+ }
792
+ },
793
+ "node_modules/nodemon/node_modules/debug": {
794
+ "version": "4.4.3",
795
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
796
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
797
+ "dev": true,
798
+ "license": "MIT",
799
+ "dependencies": {
800
+ "ms": "^2.1.3"
801
+ },
802
+ "engines": {
803
+ "node": ">=6.0"
804
+ },
805
+ "peerDependenciesMeta": {
806
+ "supports-color": {
807
+ "optional": true
808
+ }
809
+ }
810
+ },
811
+ "node_modules/nodemon/node_modules/ms": {
812
+ "version": "2.1.3",
813
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
814
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
815
+ "dev": true,
816
+ "license": "MIT"
817
+ },
818
+ "node_modules/normalize-path": {
819
+ "version": "3.0.0",
820
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
821
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
822
+ "dev": true,
823
+ "license": "MIT",
824
+ "engines": {
825
+ "node": ">=0.10.0"
826
+ }
827
+ },
828
+ "node_modules/object-assign": {
829
+ "version": "4.1.1",
830
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
831
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
832
+ "license": "MIT",
833
+ "engines": {
834
+ "node": ">=0.10.0"
835
+ }
836
+ },
837
+ "node_modules/object-inspect": {
838
+ "version": "1.13.4",
839
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
840
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
841
+ "license": "MIT",
842
+ "engines": {
843
+ "node": ">= 0.4"
844
+ },
845
+ "funding": {
846
+ "url": "https://github.com/sponsors/ljharb"
847
+ }
848
+ },
849
+ "node_modules/on-finished": {
850
+ "version": "2.4.1",
851
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
852
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
853
+ "license": "MIT",
854
+ "dependencies": {
855
+ "ee-first": "1.1.1"
856
+ },
857
+ "engines": {
858
+ "node": ">= 0.8"
859
+ }
860
+ },
861
+ "node_modules/parseurl": {
862
+ "version": "1.3.3",
863
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
864
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
865
+ "license": "MIT",
866
+ "engines": {
867
+ "node": ">= 0.8"
868
+ }
869
+ },
870
+ "node_modules/path-to-regexp": {
871
+ "version": "0.1.12",
872
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
873
+ "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
874
+ "license": "MIT"
875
+ },
876
+ "node_modules/pg": {
877
+ "version": "8.16.3",
878
+ "resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz",
879
+ "integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==",
880
+ "license": "MIT",
881
+ "dependencies": {
882
+ "pg-connection-string": "^2.9.1",
883
+ "pg-pool": "^3.10.1",
884
+ "pg-protocol": "^1.10.3",
885
+ "pg-types": "2.2.0",
886
+ "pgpass": "1.0.5"
887
+ },
888
+ "engines": {
889
+ "node": ">= 16.0.0"
890
+ },
891
+ "optionalDependencies": {
892
+ "pg-cloudflare": "^1.2.7"
893
+ },
894
+ "peerDependencies": {
895
+ "pg-native": ">=3.0.1"
896
+ },
897
+ "peerDependenciesMeta": {
898
+ "pg-native": {
899
+ "optional": true
900
+ }
901
+ }
902
+ },
903
+ "node_modules/pg-cloudflare": {
904
+ "version": "1.2.7",
905
+ "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz",
906
+ "integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==",
907
+ "license": "MIT",
908
+ "optional": true
909
+ },
910
+ "node_modules/pg-connection-string": {
911
+ "version": "2.9.1",
912
+ "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz",
913
+ "integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==",
914
+ "license": "MIT"
915
+ },
916
+ "node_modules/pg-int8": {
917
+ "version": "1.0.1",
918
+ "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
919
+ "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
920
+ "license": "ISC",
921
+ "engines": {
922
+ "node": ">=4.0.0"
923
+ }
924
+ },
925
+ "node_modules/pg-pool": {
926
+ "version": "3.10.1",
927
+ "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz",
928
+ "integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==",
929
+ "license": "MIT",
930
+ "peerDependencies": {
931
+ "pg": ">=8.0"
932
+ }
933
+ },
934
+ "node_modules/pg-protocol": {
935
+ "version": "1.10.3",
936
+ "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz",
937
+ "integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==",
938
+ "license": "MIT"
939
+ },
940
+ "node_modules/pg-types": {
941
+ "version": "2.2.0",
942
+ "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
943
+ "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
944
+ "license": "MIT",
945
+ "dependencies": {
946
+ "pg-int8": "1.0.1",
947
+ "postgres-array": "~2.0.0",
948
+ "postgres-bytea": "~1.0.0",
949
+ "postgres-date": "~1.0.4",
950
+ "postgres-interval": "^1.1.0"
951
+ },
952
+ "engines": {
953
+ "node": ">=4"
954
+ }
955
+ },
956
+ "node_modules/pgpass": {
957
+ "version": "1.0.5",
958
+ "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
959
+ "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
960
+ "license": "MIT",
961
+ "dependencies": {
962
+ "split2": "^4.1.0"
963
+ }
964
+ },
965
+ "node_modules/picomatch": {
966
+ "version": "2.3.1",
967
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
968
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
969
+ "dev": true,
970
+ "license": "MIT",
971
+ "engines": {
972
+ "node": ">=8.6"
973
+ },
974
+ "funding": {
975
+ "url": "https://github.com/sponsors/jonschlinkert"
976
+ }
977
+ },
978
+ "node_modules/postgres-array": {
979
+ "version": "2.0.0",
980
+ "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
981
+ "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
982
+ "license": "MIT",
983
+ "engines": {
984
+ "node": ">=4"
985
+ }
986
+ },
987
+ "node_modules/postgres-bytea": {
988
+ "version": "1.0.0",
989
+ "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
990
+ "integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
991
+ "license": "MIT",
992
+ "engines": {
993
+ "node": ">=0.10.0"
994
+ }
995
+ },
996
+ "node_modules/postgres-date": {
997
+ "version": "1.0.7",
998
+ "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
999
+ "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
1000
+ "license": "MIT",
1001
+ "engines": {
1002
+ "node": ">=0.10.0"
1003
+ }
1004
+ },
1005
+ "node_modules/postgres-interval": {
1006
+ "version": "1.2.0",
1007
+ "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
1008
+ "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
1009
+ "license": "MIT",
1010
+ "dependencies": {
1011
+ "xtend": "^4.0.0"
1012
+ },
1013
+ "engines": {
1014
+ "node": ">=0.10.0"
1015
+ }
1016
+ },
1017
+ "node_modules/proxy-addr": {
1018
+ "version": "2.0.7",
1019
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
1020
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
1021
+ "license": "MIT",
1022
+ "dependencies": {
1023
+ "forwarded": "0.2.0",
1024
+ "ipaddr.js": "1.9.1"
1025
+ },
1026
+ "engines": {
1027
+ "node": ">= 0.10"
1028
+ }
1029
+ },
1030
+ "node_modules/pstree.remy": {
1031
+ "version": "1.1.8",
1032
+ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
1033
+ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
1034
+ "dev": true,
1035
+ "license": "MIT"
1036
+ },
1037
+ "node_modules/qs": {
1038
+ "version": "6.13.0",
1039
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
1040
+ "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
1041
+ "license": "BSD-3-Clause",
1042
+ "dependencies": {
1043
+ "side-channel": "^1.0.6"
1044
+ },
1045
+ "engines": {
1046
+ "node": ">=0.6"
1047
+ },
1048
+ "funding": {
1049
+ "url": "https://github.com/sponsors/ljharb"
1050
+ }
1051
+ },
1052
+ "node_modules/range-parser": {
1053
+ "version": "1.2.1",
1054
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
1055
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
1056
+ "license": "MIT",
1057
+ "engines": {
1058
+ "node": ">= 0.6"
1059
+ }
1060
+ },
1061
+ "node_modules/raw-body": {
1062
+ "version": "2.5.2",
1063
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
1064
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
1065
+ "license": "MIT",
1066
+ "dependencies": {
1067
+ "bytes": "3.1.2",
1068
+ "http-errors": "2.0.0",
1069
+ "iconv-lite": "0.4.24",
1070
+ "unpipe": "1.0.0"
1071
+ },
1072
+ "engines": {
1073
+ "node": ">= 0.8"
1074
+ }
1075
+ },
1076
+ "node_modules/readdirp": {
1077
+ "version": "3.6.0",
1078
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
1079
+ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
1080
+ "dev": true,
1081
+ "license": "MIT",
1082
+ "dependencies": {
1083
+ "picomatch": "^2.2.1"
1084
+ },
1085
+ "engines": {
1086
+ "node": ">=8.10.0"
1087
+ }
1088
+ },
1089
+ "node_modules/safe-buffer": {
1090
+ "version": "5.2.1",
1091
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
1092
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
1093
+ "funding": [
1094
+ {
1095
+ "type": "github",
1096
+ "url": "https://github.com/sponsors/feross"
1097
+ },
1098
+ {
1099
+ "type": "patreon",
1100
+ "url": "https://www.patreon.com/feross"
1101
+ },
1102
+ {
1103
+ "type": "consulting",
1104
+ "url": "https://feross.org/support"
1105
+ }
1106
+ ],
1107
+ "license": "MIT"
1108
+ },
1109
+ "node_modules/safer-buffer": {
1110
+ "version": "2.1.2",
1111
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1112
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1113
+ "license": "MIT"
1114
+ },
1115
+ "node_modules/semver": {
1116
+ "version": "7.7.3",
1117
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
1118
+ "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
1119
+ "dev": true,
1120
+ "license": "ISC",
1121
+ "bin": {
1122
+ "semver": "bin/semver.js"
1123
+ },
1124
+ "engines": {
1125
+ "node": ">=10"
1126
+ }
1127
+ },
1128
+ "node_modules/send": {
1129
+ "version": "0.19.0",
1130
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
1131
+ "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
1132
+ "license": "MIT",
1133
+ "dependencies": {
1134
+ "debug": "2.6.9",
1135
+ "depd": "2.0.0",
1136
+ "destroy": "1.2.0",
1137
+ "encodeurl": "~1.0.2",
1138
+ "escape-html": "~1.0.3",
1139
+ "etag": "~1.8.1",
1140
+ "fresh": "0.5.2",
1141
+ "http-errors": "2.0.0",
1142
+ "mime": "1.6.0",
1143
+ "ms": "2.1.3",
1144
+ "on-finished": "2.4.1",
1145
+ "range-parser": "~1.2.1",
1146
+ "statuses": "2.0.1"
1147
+ },
1148
+ "engines": {
1149
+ "node": ">= 0.8.0"
1150
+ }
1151
+ },
1152
+ "node_modules/send/node_modules/encodeurl": {
1153
+ "version": "1.0.2",
1154
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
1155
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
1156
+ "license": "MIT",
1157
+ "engines": {
1158
+ "node": ">= 0.8"
1159
+ }
1160
+ },
1161
+ "node_modules/send/node_modules/ms": {
1162
+ "version": "2.1.3",
1163
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1164
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1165
+ "license": "MIT"
1166
+ },
1167
+ "node_modules/serve-static": {
1168
+ "version": "1.16.2",
1169
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
1170
+ "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
1171
+ "license": "MIT",
1172
+ "dependencies": {
1173
+ "encodeurl": "~2.0.0",
1174
+ "escape-html": "~1.0.3",
1175
+ "parseurl": "~1.3.3",
1176
+ "send": "0.19.0"
1177
+ },
1178
+ "engines": {
1179
+ "node": ">= 0.8.0"
1180
+ }
1181
+ },
1182
+ "node_modules/setprototypeof": {
1183
+ "version": "1.2.0",
1184
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
1185
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
1186
+ "license": "ISC"
1187
+ },
1188
+ "node_modules/side-channel": {
1189
+ "version": "1.1.0",
1190
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
1191
+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
1192
+ "license": "MIT",
1193
+ "dependencies": {
1194
+ "es-errors": "^1.3.0",
1195
+ "object-inspect": "^1.13.3",
1196
+ "side-channel-list": "^1.0.0",
1197
+ "side-channel-map": "^1.0.1",
1198
+ "side-channel-weakmap": "^1.0.2"
1199
+ },
1200
+ "engines": {
1201
+ "node": ">= 0.4"
1202
+ },
1203
+ "funding": {
1204
+ "url": "https://github.com/sponsors/ljharb"
1205
+ }
1206
+ },
1207
+ "node_modules/side-channel-list": {
1208
+ "version": "1.0.0",
1209
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
1210
+ "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
1211
+ "license": "MIT",
1212
+ "dependencies": {
1213
+ "es-errors": "^1.3.0",
1214
+ "object-inspect": "^1.13.3"
1215
+ },
1216
+ "engines": {
1217
+ "node": ">= 0.4"
1218
+ },
1219
+ "funding": {
1220
+ "url": "https://github.com/sponsors/ljharb"
1221
+ }
1222
+ },
1223
+ "node_modules/side-channel-map": {
1224
+ "version": "1.0.1",
1225
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
1226
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
1227
+ "license": "MIT",
1228
+ "dependencies": {
1229
+ "call-bound": "^1.0.2",
1230
+ "es-errors": "^1.3.0",
1231
+ "get-intrinsic": "^1.2.5",
1232
+ "object-inspect": "^1.13.3"
1233
+ },
1234
+ "engines": {
1235
+ "node": ">= 0.4"
1236
+ },
1237
+ "funding": {
1238
+ "url": "https://github.com/sponsors/ljharb"
1239
+ }
1240
+ },
1241
+ "node_modules/side-channel-weakmap": {
1242
+ "version": "1.0.2",
1243
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
1244
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
1245
+ "license": "MIT",
1246
+ "dependencies": {
1247
+ "call-bound": "^1.0.2",
1248
+ "es-errors": "^1.3.0",
1249
+ "get-intrinsic": "^1.2.5",
1250
+ "object-inspect": "^1.13.3",
1251
+ "side-channel-map": "^1.0.1"
1252
+ },
1253
+ "engines": {
1254
+ "node": ">= 0.4"
1255
+ },
1256
+ "funding": {
1257
+ "url": "https://github.com/sponsors/ljharb"
1258
+ }
1259
+ },
1260
+ "node_modules/simple-update-notifier": {
1261
+ "version": "2.0.0",
1262
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
1263
+ "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
1264
+ "dev": true,
1265
+ "license": "MIT",
1266
+ "dependencies": {
1267
+ "semver": "^7.5.3"
1268
+ },
1269
+ "engines": {
1270
+ "node": ">=10"
1271
+ }
1272
+ },
1273
+ "node_modules/split2": {
1274
+ "version": "4.2.0",
1275
+ "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
1276
+ "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
1277
+ "license": "ISC",
1278
+ "engines": {
1279
+ "node": ">= 10.x"
1280
+ }
1281
+ },
1282
+ "node_modules/statuses": {
1283
+ "version": "2.0.1",
1284
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
1285
+ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
1286
+ "license": "MIT",
1287
+ "engines": {
1288
+ "node": ">= 0.8"
1289
+ }
1290
+ },
1291
+ "node_modules/supports-color": {
1292
+ "version": "5.5.0",
1293
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
1294
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
1295
+ "dev": true,
1296
+ "license": "MIT",
1297
+ "dependencies": {
1298
+ "has-flag": "^3.0.0"
1299
+ },
1300
+ "engines": {
1301
+ "node": ">=4"
1302
+ }
1303
+ },
1304
+ "node_modules/to-regex-range": {
1305
+ "version": "5.0.1",
1306
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
1307
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
1308
+ "dev": true,
1309
+ "license": "MIT",
1310
+ "dependencies": {
1311
+ "is-number": "^7.0.0"
1312
+ },
1313
+ "engines": {
1314
+ "node": ">=8.0"
1315
+ }
1316
+ },
1317
+ "node_modules/toidentifier": {
1318
+ "version": "1.0.1",
1319
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
1320
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
1321
+ "license": "MIT",
1322
+ "engines": {
1323
+ "node": ">=0.6"
1324
+ }
1325
+ },
1326
+ "node_modules/touch": {
1327
+ "version": "3.1.1",
1328
+ "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
1329
+ "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
1330
+ "dev": true,
1331
+ "license": "ISC",
1332
+ "bin": {
1333
+ "nodetouch": "bin/nodetouch.js"
1334
+ }
1335
+ },
1336
+ "node_modules/type-is": {
1337
+ "version": "1.6.18",
1338
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
1339
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
1340
+ "license": "MIT",
1341
+ "dependencies": {
1342
+ "media-typer": "0.3.0",
1343
+ "mime-types": "~2.1.24"
1344
+ },
1345
+ "engines": {
1346
+ "node": ">= 0.6"
1347
+ }
1348
+ },
1349
+ "node_modules/undefsafe": {
1350
+ "version": "2.0.5",
1351
+ "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
1352
+ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
1353
+ "dev": true,
1354
+ "license": "MIT"
1355
+ },
1356
+ "node_modules/unpipe": {
1357
+ "version": "1.0.0",
1358
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
1359
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
1360
+ "license": "MIT",
1361
+ "engines": {
1362
+ "node": ">= 0.8"
1363
+ }
1364
+ },
1365
+ "node_modules/utils-merge": {
1366
+ "version": "1.0.1",
1367
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
1368
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
1369
+ "license": "MIT",
1370
+ "engines": {
1371
+ "node": ">= 0.4.0"
1372
+ }
1373
+ },
1374
+ "node_modules/uuid": {
1375
+ "version": "9.0.1",
1376
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz",
1377
+ "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
1378
+ "funding": [
1379
+ "https://github.com/sponsors/broofa",
1380
+ "https://github.com/sponsors/ctavan"
1381
+ ],
1382
+ "license": "MIT",
1383
+ "bin": {
1384
+ "uuid": "dist/bin/uuid"
1385
+ }
1386
+ },
1387
+ "node_modules/vary": {
1388
+ "version": "1.1.2",
1389
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
1390
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
1391
+ "license": "MIT",
1392
+ "engines": {
1393
+ "node": ">= 0.8"
1394
+ }
1395
+ },
1396
+ "node_modules/xtend": {
1397
+ "version": "4.0.2",
1398
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
1399
+ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
1400
+ "license": "MIT",
1401
+ "engines": {
1402
+ "node": ">=0.4"
1403
+ }
1404
+ }
1405
+ }
1406
+ }
package.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "pattanshetty-backend",
3
+ "version": "1.0.0",
4
+ "description": "Inventory Management Backend API",
5
+ "main": "src/server.js",
6
+ "scripts": {
7
+ "start": "node src/server.js",
8
+ "dev": "nodemon src/server.js",
9
+ "migrate": "node src/db/migrate.js",
10
+ "seed": "node src/db/seed.js",
11
+ "reset": "node src/db/reset.js"
12
+ },
13
+ "keywords": ["inventory", "express", "postgresql"],
14
+ "author": "",
15
+ "license": "ISC",
16
+ "dependencies": {
17
+ "express": "^4.18.2",
18
+ "pg": "^8.11.3",
19
+ "cors": "^2.8.5",
20
+ "dotenv": "^16.3.1",
21
+ "uuid": "^9.0.1"
22
+ },
23
+ "devDependencies": {
24
+ "nodemon": "^3.0.1"
25
+ }
26
+ }
src/db/ca.pem ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEUDCCArigAwIBAgIUfwNzc0s5wNLad9xuTq9aKHnTIckwDQYJKoZIhvcNAQEM
3
+ BQAwQDE+MDwGA1UEAww1ODg2NWZlZTEtOTIyMy00MTMxLWIwNjItYWJlNDg5YWMw
4
+ ZTFmIEdFTiAxIFByb2plY3QgQ0EwHhcNMjUxMTI2MTMwMjIzWhcNMzUxMTI0MTMw
5
+ MjIzWjBAMT4wPAYDVQQDDDU4ODY1ZmVlMS05MjIzLTQxMzEtYjA2Mi1hYmU0ODlh
6
+ YzBlMWYgR0VOIDEgUHJvamVjdCBDQTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCC
7
+ AYoCggGBALXpJK142iOT6sCj2zc820av/G8Yr69U9oowbRuMBH+fot0Brz3IxxZz
8
+ 4Eb+g3OGfbytvz2A39W4Gf7vM1qzYTpvQeb3I1WEp6ECJIxixPpeAwVr5FYCMPgw
9
+ Tp3hg6BOnMUFHmS10942WzHWpx8JajZFLYeFtk1VgR7cxqMZ1UEKZlc6SrA8HBqM
10
+ ok3E0VvgA1jw0iiJtPG7NTEI5G5HOJ10sFttpf1KdhqWiwVqG1tRpRTwQpVDKvU4
11
+ JEvBCAonZ2gxp2rf/11KOOEgS3Rk9KzCHNYJ4zcg+9ipcpwyaD5hNWQKxO0XLoIj
12
+ bJaXPcevfHXebad1dVD+3+sJYaTLNRaIuRs6AYm7/c0OxaetLplyzyafsw0mZAp/
13
+ ZswnS8XvOUuqKJke2QR3zpJSOZQ9qbHygziDgg3erLO0s/EimVj/j6QPZoUjKXkJ
14
+ 8dWoiF7kkF+USynIEEKN87VRHbi+lepuC32TgXdPGyuN2cmrg1mtS9Y/jDqUlfl8
15
+ ElmfFTRbPwIDAQABo0IwQDAdBgNVHQ4EFgQUWWJ7i7Zro8zA4tEwfzNQpF9+IP4w
16
+ EgYDVR0TAQH/BAgwBgEB/wIBADALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEMBQAD
17
+ ggGBAFYTDm036bi/0vOtLEP9jqDc51SMF1rWKf7Gy/wKsUTO9j7egEayy/lpvhKd
18
+ DY8ioyeBHtREMZ7RmOah165OnzQa6/gvfXQG78MSyo16HIBK/VrICK1gGVNPp/u5
19
+ wWx6wZ1fN709xKO7Q+nbYoCbxmlY+3BJq5xfvxcN7YFtTtEV5MSVUB76r7Mb+flk
20
+ fq+0HjTpUEV/VmEncKrQaN345L0v/b6gxUjiQjHdi9McDybM1x2JV0dqea3ZXySU
21
+ Igx168r1IQuiKTHvHTzibAEllulYj598YBtMeXaBnOEZm3JUkPBuyFpW2j/CyJQ9
22
+ 9y0UfOZkLqwDA3G5xatR6TAcGH7eByDrVqEKWXg1fgIJ7fmMijWyzXelLiOX0agl
23
+ pa43TlAP5KZfeR3GOtFfNAhiW448LhpZvKGi2q75G71uTopKtK2EdOuzjYJZCXxA
24
+ YU0EkC3KrKl/jzVOgvHz8kc+HWj5khW/pm6knWstpb3AUg7nD151ejVQuIuI8oJJ
25
+ rwCc8g==
26
+ -----END CERTIFICATE-----
src/db/config.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { Pool } = require('pg');
2
+ require('dotenv').config();
3
+
4
+ const config = {
5
+ user: process.env.DB_USER || "avnadmin",
6
+ password: process.env.DB_PASSWORD || "AVNS_8YN2lShyUCy56qezi-_",
7
+ // Updated Host
8
+ host: process.env.DB_HOST || "staging-photobrex-3b7a.j.aivencloud.com",
9
+ // Updated Port
10
+ port: parseInt(process.env.DB_PORT || "10838"),
11
+ database: process.env.DB_NAME || "defaultdb",
12
+ ssl: {
13
+ rejectUnauthorized: true,
14
+ // Updated CA Certificate (Hardcoded string as requested)
15
+ ca: `-----BEGIN CERTIFICATE-----
16
+ MIIEUDCCArigAwIBAgIUNcDCtq9UKVDahrOq1uPUfByWsZswDQYJKoZIhvcNAQEM
17
+ BQAwQDE+MDwGA1UEAww1NDM0MmMxOTktZWEzOC00ODZmLTg3ZmItNjkxMTQ0MTJh
18
+ YzQ4IEdFTiAxIFByb2plY3QgQ0EwHhcNMjUxMTI5MTMwODM5WhcNMzUxMTI3MTMw
19
+ ODM5WjBAMT4wPAYDVQQDDDU0MzQyYzE5OS1lYTM4LTQ4NmYtODdmYi02OTExNDQx
20
+ MmFjNDggR0VOIDEgUHJvamVjdCBDQTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCC
21
+ AYoCggGBAL4gSkKaQbOQz4eI1J3GfTTlG7BeFCQkxXD6M/ONZQY0CqLiOuIqQkcs
22
+ qucBnZVk8ZqWRMqJZel+FhpUkk7Ddyole1m/DNnUh+ofO53R0ZnfrNmgqFlUkolc
23
+ +VydiwgiprYUhne0G45Kjh87H4n73kbB+KsF5RkFXVwO4OO1AyrlUayUXhYyOzUg
24
+ dP/NMupxGlL2rIlvfA1aVbEGwODmOkyGCvUHIEkytymhrXdkti6KX/M+9eM/ggKG
25
+ zf4Ie4PTYXgWUxmRZsalwV1YlukUiwKS3X8SR0RhttWYopQmvVUhXYA0B8XHahcX
26
+ 4M57Wh2DIDHIMTRqK8cUvlLYEzMAmPW0SiYiMUITkdeqM7TgHr7qyPUzfurEQ4ew
27
+ 2RnZYbvBI/Yv5RG+2Wn5MDC1ccvfP6MXl+OdGf7GRcpCvJHaybzJy+7Hxj0LPc61
28
+ h4XawJxtwlzxpdmZKbue/McqC/N0nKOQeVQxylvLKRUH29kKyNvnduCsLfYfVq5i
29
+ iqOTrMQucwIDAQABo0IwQDAdBgNVHQ4EFgQUJmZTt7IsEdNVgLLHfDqMdm9F3mgw
30
+ EgYDVR0TAQH/BAgwBgEB/wIBADALBgNVHQ8EBAMCAQYwDQYJKoZIhvcNAQEMBQAD
31
+ ggGBALgLPFv1GMVta1W9O7ukFTqLFGAwDVG5FI7z+M6lSwhAoQat4gaSdpCc2NsS
32
+ JpsVnF2xd+N2DTkg/pJs4iq1HQ2s0OwyrcWd4Z+1T4h5YN4V1gWbwBatXHUNHPEB
33
+ 2/SrS4LSLFxiYmDseU8bvjYcsBy6GlUesA+EN6M6t5tk9IhZt4wLziq/0heMivHW
34
+ BMZGbVFJYqSFL/PVgqXCH5wCO5dSVhnkV6vFoGVYZCQPnQXC9DC84cUrX73P7rLj
35
+ mgO3O+iOwjy++G219WIn3Ek2TWINFsNBZUlLCWpuYsxCaRl06Z9v0bni7BneGWYw
36
+ smzdMUQWrprCD/czqse0BgXDHvbydj0lDFahixQ6Wt0PK5pcXwa+YouqiPecdflW
37
+ OSDAMYM5O8s9KLe2D7qGyxhBNT55ljsMx4hEbMmuoyYTYSrs0THknSFppso0407e
38
+ 7CK61QMJWHzszde0njyBMTTcysJ1Dv89826h22dMNd5z97hGCmexNlfLB9v8DsoK
39
+ Bj8KGw==
40
+ -----END CERTIFICATE-----`,
41
+ },
42
+ };
43
+
44
+ const pool = new Pool(config);
45
+
46
+ pool.on('connect', () => {
47
+ console.log('โœ… Connected to PostgreSQL database');
48
+ });
49
+
50
+ pool.on('error', (err) => {
51
+ console.error('โŒ Unexpected error on idle client', err);
52
+ process.exit(-1);
53
+ });
54
+
55
+ module.exports = pool;
src/db/migrate.js ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const pool = require('./config');
2
+
3
+ const createTables = async () => {
4
+ const client = await pool.connect();
5
+
6
+ try {
7
+ console.log('๐Ÿš€ Starting database migration...');
8
+
9
+ await client.query('BEGIN');
10
+
11
+ // 1. Create parties table
12
+ await client.query(`
13
+ CREATE TABLE IF NOT EXISTS parties (
14
+ id VARCHAR(50) PRIMARY KEY,
15
+ name VARCHAR(255) NOT NULL,
16
+ phone VARCHAR(20),
17
+ city VARCHAR(100),
18
+ party_type VARCHAR(20) NOT NULL CHECK (party_type IN ('awaak', 'jawaak', 'both')),
19
+ current_balance DECIMAL(12, 2) DEFAULT 0,
20
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
21
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
22
+ )
23
+ `);
24
+ console.log('โœ… Created table: parties');
25
+
26
+ // 2. Create mirchi_types table
27
+ await client.query(`
28
+ CREATE TABLE IF NOT EXISTS mirchi_types (
29
+ id VARCHAR(50) PRIMARY KEY,
30
+ name VARCHAR(100) NOT NULL UNIQUE,
31
+ current_rate DECIMAL(10, 2) DEFAULT 0,
32
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
33
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
34
+ )
35
+ `);
36
+ console.log('โœ… Created table: mirchi_types');
37
+
38
+ // 3. Create lots table
39
+ await client.query(`
40
+ CREATE TABLE IF NOT EXISTS lots (
41
+ id VARCHAR(50) PRIMARY KEY,
42
+ lot_number VARCHAR(100) NOT NULL UNIQUE,
43
+ mirchi_type_id VARCHAR(50) NOT NULL REFERENCES mirchi_types(id) ON DELETE CASCADE,
44
+ mirchi_name VARCHAR(100) NOT NULL,
45
+ total_quantity DECIMAL(10, 2) NOT NULL,
46
+ remaining_quantity DECIMAL(10, 2) NOT NULL,
47
+ purchase_date DATE NOT NULL,
48
+ status VARCHAR(20) NOT NULL CHECK (status IN ('active', 'sold_out')),
49
+ avg_rate DECIMAL(10, 2) NOT NULL,
50
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
51
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
52
+ )
53
+ `);
54
+ console.log('โœ… Created table: lots');
55
+
56
+ // 4. Create transactions table
57
+ await client.query(`
58
+ CREATE TABLE IF NOT EXISTS transactions (
59
+ id VARCHAR(50) PRIMARY KEY,
60
+ bill_number VARCHAR(100) NOT NULL UNIQUE,
61
+ bill_date DATE NOT NULL,
62
+ bill_type VARCHAR(20) NOT NULL CHECK (bill_type IN ('awaak', 'jawaak')),
63
+ is_return BOOLEAN DEFAULT FALSE,
64
+ party_id VARCHAR(50) NOT NULL REFERENCES parties(id) ON DELETE CASCADE,
65
+ party_name VARCHAR(255),
66
+ gross_weight_total DECIMAL(10, 2) DEFAULT 0,
67
+ net_weight_total DECIMAL(10, 2) DEFAULT 0,
68
+ subtotal DECIMAL(12, 2) DEFAULT 0,
69
+ total_expenses DECIMAL(12, 2) DEFAULT 0,
70
+ total_amount DECIMAL(12, 2) NOT NULL,
71
+ paid_amount DECIMAL(12, 2) DEFAULT 0,
72
+ balance_amount DECIMAL(12, 2) DEFAULT 0,
73
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
74
+ updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
75
+ )
76
+ `);
77
+ console.log('โœ… Created table: transactions');
78
+
79
+ // 5. Create transaction_items table
80
+ await client.query(`
81
+ CREATE TABLE IF NOT EXISTS transaction_items (
82
+ id VARCHAR(50) PRIMARY KEY,
83
+ transaction_id VARCHAR(50) NOT NULL REFERENCES transactions(id) ON DELETE CASCADE,
84
+ mirchi_type_id VARCHAR(50) NOT NULL REFERENCES mirchi_types(id),
85
+ mirchi_name VARCHAR(100),
86
+ quality VARCHAR(50),
87
+ lot_id VARCHAR(50) REFERENCES lots(id),
88
+ poti_weights TEXT,
89
+ gross_weight DECIMAL(10, 2) NOT NULL,
90
+ poti_count INTEGER NOT NULL,
91
+ total_potya DECIMAL(10, 2) DEFAULT 0,
92
+ net_weight DECIMAL(10, 2) NOT NULL,
93
+ rate_per_kg DECIMAL(10, 2) NOT NULL,
94
+ item_total DECIMAL(12, 2) NOT NULL,
95
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
96
+ )
97
+ `);
98
+ console.log('โœ… Created table: transaction_items');
99
+
100
+ // 6. Create expenses table
101
+ await client.query(`
102
+ CREATE TABLE IF NOT EXISTS expenses (
103
+ id SERIAL PRIMARY KEY,
104
+ transaction_id VARCHAR(50) NOT NULL REFERENCES transactions(id) ON DELETE CASCADE,
105
+ cess_percent DECIMAL(5, 2) DEFAULT 0,
106
+ cess_amount DECIMAL(10, 2) DEFAULT 0,
107
+ adat_percent DECIMAL(5, 2) DEFAULT 0,
108
+ adat_amount DECIMAL(10, 2) DEFAULT 0,
109
+ poti_rate DECIMAL(10, 2) DEFAULT 0,
110
+ poti_amount DECIMAL(10, 2) DEFAULT 0,
111
+ hamali_per_poti DECIMAL(10, 2) DEFAULT 0,
112
+ hamali_amount DECIMAL(10, 2) DEFAULT 0,
113
+ packaging_hamali_per_poti DECIMAL(10, 2) DEFAULT 0,
114
+ packaging_hamali_amount DECIMAL(10, 2) DEFAULT 0,
115
+ gaadi_bharni DECIMAL(10, 2) DEFAULT 0,
116
+ other_expenses DECIMAL(10, 2) DEFAULT 0,
117
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
118
+ )
119
+ `);
120
+ // Ensure column exists on existing databases as well
121
+ await client.query(`
122
+ ALTER TABLE expenses
123
+ ADD COLUMN IF NOT EXISTS other_expenses DECIMAL(10, 2) DEFAULT 0
124
+ `);
125
+ console.log('โœ… Created table: expenses');
126
+
127
+ // 7. Create payments table
128
+ await client.query(`
129
+ CREATE TABLE IF NOT EXISTS payments (
130
+ id SERIAL PRIMARY KEY,
131
+ transaction_id VARCHAR(50) NOT NULL REFERENCES transactions(id) ON DELETE CASCADE,
132
+ mode VARCHAR(20) NOT NULL CHECK (mode IN ('cash', 'online', 'cheque', 'due')),
133
+ amount DECIMAL(12, 2) NOT NULL,
134
+ reference VARCHAR(255),
135
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
136
+ )
137
+ `);
138
+ console.log('โœ… Created table: payments');
139
+
140
+ // Create indexes for better performance
141
+ await client.query(`
142
+ CREATE INDEX IF NOT EXISTS idx_transactions_party ON transactions(party_id);
143
+ CREATE INDEX IF NOT EXISTS idx_transactions_date ON transactions(bill_date);
144
+ CREATE INDEX IF NOT EXISTS idx_transaction_items_tx ON transaction_items(transaction_id);
145
+ CREATE INDEX IF NOT EXISTS idx_lots_mirchi ON lots(mirchi_type_id);
146
+ CREATE INDEX IF NOT EXISTS idx_lots_status ON lots(status);
147
+ `);
148
+ console.log('โœ… Created indexes');
149
+
150
+ await client.query('COMMIT');
151
+ console.log('โœ… Migration completed successfully!');
152
+
153
+ } catch (error) {
154
+ await client.query('ROLLBACK');
155
+ console.error('โŒ Migration failed:', error);
156
+ throw error;
157
+ } finally {
158
+ client.release();
159
+ await pool.end();
160
+ }
161
+ };
162
+
163
+ createTables().catch(err => {
164
+ console.error('Fatal error:', err);
165
+ process.exit(1);
166
+ });
src/db/reset.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const pool = require('./config');
2
+
3
+ const resetDatabase = async () => {
4
+ const client = await pool.connect();
5
+
6
+ try {
7
+ console.log('๐Ÿ”„ Resetting database...');
8
+
9
+ await client.query('BEGIN');
10
+
11
+ // Drop all tables in reverse order of dependencies
12
+ await client.query('DROP TABLE IF EXISTS payments CASCADE');
13
+ await client.query('DROP TABLE IF EXISTS expenses CASCADE');
14
+ await client.query('DROP TABLE IF EXISTS transaction_items CASCADE');
15
+ await client.query('DROP TABLE IF EXISTS transactions CASCADE');
16
+ await client.query('DROP TABLE IF EXISTS lots CASCADE');
17
+ await client.query('DROP TABLE IF EXISTS mirchi_types CASCADE');
18
+ await client.query('DROP TABLE IF EXISTS parties CASCADE');
19
+
20
+ await client.query('COMMIT');
21
+ console.log('โœ… Database reset completed!');
22
+ console.log('๐Ÿ’ก Run "npm run migrate" to recreate tables');
23
+ console.log('๐Ÿ’ก Run "npm run seed" to populate with sample data');
24
+
25
+ } catch (error) {
26
+ await client.query('ROLLBACK');
27
+ console.error('โŒ Reset failed:', error);
28
+ throw error;
29
+ } finally {
30
+ client.release();
31
+ await pool.end();
32
+ }
33
+ };
34
+
35
+ resetDatabase().catch(err => {
36
+ console.error('Fatal error:', err);
37
+ process.exit(1);
38
+ });
src/db/seed.js ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const pool = require('./config');
2
+ const { v4: uuidv4 } = require('uuid');
3
+
4
+ const seedData = async () => {
5
+ const client = await pool.connect();
6
+
7
+ try {
8
+ console.log('๐ŸŒฑ Starting database seeding...');
9
+
10
+ await client.query('BEGIN');
11
+
12
+ // 1. Seed Parties
13
+ const parties = [
14
+ { id: 'p1', name: 'Ramesh Traders', phone: '9876543210', city: 'Byadgi', party_type: 'both', current_balance: 0 },
15
+ { id: 'p2', name: 'Suresh & Co', phone: '9876543211', city: 'Guntur', party_type: 'jawaak', current_balance: 0 },
16
+ { id: 'p3', name: 'Kisan Vyapar', phone: '9876543212', city: 'Nagpur', party_type: 'awaak', current_balance: 0 },
17
+ { id: 'p4', name: 'Mahesh Enterprises', phone: '9876543213', city: 'Mumbai', party_type: 'both', current_balance: 0 },
18
+ { id: 'p5', name: 'Ganesh Trading Co', phone: '9876543214', city: 'Pune', party_type: 'jawaak', current_balance: 0 }
19
+ ];
20
+
21
+ for (const party of parties) {
22
+ await client.query(
23
+ `INSERT INTO parties (id, name, phone, city, party_type, current_balance)
24
+ VALUES ($1, $2, $3, $4, $5, $6)
25
+ ON CONFLICT (id) DO NOTHING`,
26
+ [party.id, party.name, party.phone, party.city, party.party_type, party.current_balance]
27
+ );
28
+ }
29
+ console.log(`โœ… Seeded ${parties.length} parties`);
30
+
31
+ // 2. Seed Mirchi Types
32
+ const mirchiTypes = [
33
+ { id: 'm1', name: 'Teja', current_rate: 180 },
34
+ { id: 'm2', name: 'Byadgi', current_rate: 220 },
35
+ { id: 'm3', name: 'Guntur Sannam', current_rate: 150 },
36
+ { id: 'm4', name: 'Kashmiri', current_rate: 300 },
37
+ { id: 'm5', name: 'Reshampatti', current_rate: 250 }
38
+ ];
39
+
40
+ for (const type of mirchiTypes) {
41
+ await client.query(
42
+ `INSERT INTO mirchi_types (id, name, current_rate)
43
+ VALUES ($1, $2, $3)
44
+ ON CONFLICT (name) DO NOTHING`,
45
+ [type.id, type.name, type.current_rate]
46
+ );
47
+ }
48
+ console.log(`โœ… Seeded ${mirchiTypes.length} mirchi types`);
49
+
50
+ // 3. Seed Lots
51
+ const lots = [
52
+ {
53
+ id: 'l1',
54
+ lot_number: 'LOT-TEJ-20241120-001',
55
+ mirchi_type_id: 'm1',
56
+ mirchi_name: 'Teja',
57
+ total_quantity: 500,
58
+ remaining_quantity: 200,
59
+ purchase_date: '2024-11-20',
60
+ status: 'active',
61
+ avg_rate: 175
62
+ },
63
+ {
64
+ id: 'l2',
65
+ lot_number: 'LOT-BYA-20241121-002',
66
+ mirchi_type_id: 'm2',
67
+ mirchi_name: 'Byadgi',
68
+ total_quantity: 1000,
69
+ remaining_quantity: 850,
70
+ purchase_date: '2024-11-21',
71
+ status: 'active',
72
+ avg_rate: 210
73
+ },
74
+ {
75
+ id: 'l3',
76
+ lot_number: 'LOT-GUN-20241122-003',
77
+ mirchi_type_id: 'm3',
78
+ mirchi_name: 'Guntur Sannam',
79
+ total_quantity: 750,
80
+ remaining_quantity: 600,
81
+ purchase_date: '2024-11-22',
82
+ status: 'active',
83
+ avg_rate: 145
84
+ }
85
+ ];
86
+
87
+ for (const lot of lots) {
88
+ await client.query(
89
+ `INSERT INTO lots (id, lot_number, mirchi_type_id, mirchi_name, total_quantity, remaining_quantity, purchase_date, status, avg_rate)
90
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
91
+ ON CONFLICT (lot_number) DO NOTHING`,
92
+ [lot.id, lot.lot_number, lot.mirchi_type_id, lot.mirchi_name, lot.total_quantity, lot.remaining_quantity, lot.purchase_date, lot.status, lot.avg_rate]
93
+ );
94
+ }
95
+ console.log(`โœ… Seeded ${lots.length} lots`);
96
+
97
+ // 4. Seed Sample Transactions
98
+ const tx1Id = 'tx1';
99
+ await client.query(
100
+ `INSERT INTO transactions (id, bill_number, bill_date, bill_type, is_return, party_id, party_name, gross_weight_total, net_weight_total, subtotal, total_expenses, total_amount, paid_amount, balance_amount)
101
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
102
+ ON CONFLICT (bill_number) DO NOTHING`,
103
+ [tx1Id, 'JAWAAK-2024-0001', '2024-11-20', 'jawaak', false, 'p3', 'Kisan Vyapar', 500, 500, 87500, 4375, 91875, 50000, 41875]
104
+ );
105
+
106
+ await client.query(
107
+ `INSERT INTO transaction_items (id, transaction_id, mirchi_type_id, mirchi_name, quality, lot_id, poti_weights, gross_weight, poti_count, total_potya, net_weight, rate_per_kg, item_total)
108
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)
109
+ ON CONFLICT (id) DO NOTHING`,
110
+ ['tx1-item1', tx1Id, 'm1', 'Teja', 'A+', 'l1', '[100,100,100,100,100]', 500, 5, 0, 500, 175, 87500]
111
+ );
112
+
113
+ await client.query(
114
+ `INSERT INTO expenses (transaction_id, cess_percent, cess_amount, adat_percent, adat_amount, hamali_per_poti, hamali_amount)
115
+ VALUES ($1, $2, $3, $4, $5, $6, $7)`,
116
+ [tx1Id, 2.0, 1750, 3.0, 2625, 0, 0]
117
+ );
118
+
119
+ await client.query(
120
+ `INSERT INTO payments (transaction_id, mode, amount, reference)
121
+ VALUES ($1, $2, $3, $4)`,
122
+ [tx1Id, 'cash', 50000, 'Initial payment']
123
+ );
124
+
125
+ console.log('โœ… Seeded sample transaction');
126
+
127
+ await client.query('COMMIT');
128
+ console.log('โœ… Seeding completed successfully!');
129
+
130
+ } catch (error) {
131
+ await client.query('ROLLBACK');
132
+ console.error('โŒ Seeding failed:', error);
133
+ throw error;
134
+ } finally {
135
+ client.release();
136
+ await pool.end();
137
+ }
138
+ };
139
+
140
+ seedData().catch(err => {
141
+ console.error('Fatal error:', err);
142
+ process.exit(1);
143
+ });
src/db/test-connection.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const pool = require('./config');
2
+
3
+ async function testConnection() {
4
+ try {
5
+ const client = await pool.connect();
6
+ console.log('โœ… Successfully connected to the database!');
7
+
8
+ const res = await client.query('SELECT VERSION()');
9
+ console.log('๐Ÿ“Š Database Version:', res.rows[0].version);
10
+
11
+ client.release();
12
+ } catch (err) {
13
+ console.error('โŒ Connection failed:', err);
14
+ } finally {
15
+ await pool.end();
16
+ }
17
+ }
18
+
19
+ testConnection();
src/routes/lots.js ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const pool = require('../db/config');
4
+
5
+ // GET all lots
6
+ router.get('/', async (req, res) => {
7
+ try {
8
+ const { status } = req.query;
9
+
10
+ let query = 'SELECT * FROM lots ORDER BY purchase_date DESC';
11
+ let params = [];
12
+
13
+ if (status) {
14
+ query = 'SELECT * FROM lots WHERE status = $1 ORDER BY purchase_date DESC';
15
+ params = [status];
16
+ }
17
+
18
+ const result = await pool.query(query, params);
19
+ res.json(result.rows);
20
+ } catch (error) {
21
+ console.error('Error fetching lots:', error);
22
+ res.status(500).json({ success: false, message: error.message });
23
+ }
24
+ });
25
+
26
+ // GET active lots with remaining quantity
27
+ router.get('/active', async (req, res) => {
28
+ try {
29
+ const result = await pool.query(
30
+ `SELECT * FROM lots
31
+ WHERE status = 'active' AND remaining_quantity > 0
32
+ ORDER BY purchase_date DESC`
33
+ );
34
+ res.json(result.rows);
35
+ } catch (error) {
36
+ console.error('Error fetching active lots:', error);
37
+ res.status(500).json({ success: false, message: error.message });
38
+ }
39
+ });
40
+
41
+ // GET lot by ID
42
+ router.get('/:id', async (req, res) => {
43
+ try {
44
+ const { id } = req.params;
45
+ const result = await pool.query(
46
+ 'SELECT * FROM lots WHERE id = $1',
47
+ [id]
48
+ );
49
+
50
+ if (result.rows.length === 0) {
51
+ return res.status(404).json({ success: false, message: 'Lot not found' });
52
+ }
53
+
54
+ res.json(result.rows[0]);
55
+ } catch (error) {
56
+ console.error('Error fetching lot:', error);
57
+ res.status(500).json({ success: false, message: error.message });
58
+ }
59
+ });
60
+
61
+ // GET lots by mirchi type
62
+ router.get('/mirchi/:mirchiTypeId', async (req, res) => {
63
+ try {
64
+ const { mirchiTypeId } = req.params;
65
+ const result = await pool.query(
66
+ `SELECT * FROM lots
67
+ WHERE mirchi_type_id = $1
68
+ ORDER BY purchase_date DESC`,
69
+ [mirchiTypeId]
70
+ );
71
+ res.json(result.rows);
72
+ } catch (error) {
73
+ console.error('Error fetching lots by mirchi type:', error);
74
+ res.status(500).json({ success: false, message: error.message });
75
+ }
76
+ });
77
+
78
+ // POST check if lot number is unique
79
+ router.post('/check-unique', async (req, res) => {
80
+ try {
81
+ const { lot_number } = req.body;
82
+
83
+ if (!lot_number) {
84
+ return res.status(400).json({ success: false, message: 'Lot number is required' });
85
+ }
86
+
87
+ const result = await pool.query(
88
+ 'SELECT id FROM lots WHERE lot_number = $1',
89
+ [lot_number]
90
+ );
91
+
92
+ res.json({ exists: result.rows.length > 0 });
93
+ } catch (error) {
94
+ console.error('Error checking lot uniqueness:', error);
95
+ res.status(500).json({ success: false, message: error.message });
96
+ }
97
+ });
98
+
99
+ // GET available lots for a mirchi type (with remaining quantity > 0)
100
+ router.get('/available/:mirchiTypeId', async (req, res) => {
101
+ try {
102
+ const { mirchiTypeId } = req.params;
103
+ const result = await pool.query(
104
+ `SELECT * FROM lots
105
+ WHERE mirchi_type_id = $1
106
+ AND status = 'active'
107
+ AND remaining_quantity > 0
108
+ ORDER BY purchase_date DESC`,
109
+ [mirchiTypeId]
110
+ );
111
+ res.json(result.rows);
112
+ } catch (error) {
113
+ console.error('Error fetching available lots:', error);
114
+ res.status(500).json({ success: false, message: error.message });
115
+ }
116
+ });
117
+
118
+ module.exports = router;
src/routes/mirchiTypes.js ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const pool = require('../db/config');
4
+ const { v4: uuidv4 } = require('uuid');
5
+
6
+ // GET all mirchi types
7
+ router.get('/', async (req, res) => {
8
+ try {
9
+ const result = await pool.query(
10
+ 'SELECT * FROM mirchi_types ORDER BY name ASC'
11
+ );
12
+ res.json(result.rows);
13
+ } catch (error) {
14
+ console.error('Error fetching mirchi types:', error);
15
+ res.status(500).json({ success: false, message: error.message });
16
+ }
17
+ });
18
+
19
+ // GET mirchi type by ID
20
+ router.get('/:id', async (req, res) => {
21
+ try {
22
+ const { id } = req.params;
23
+ const result = await pool.query(
24
+ 'SELECT * FROM mirchi_types WHERE id = $1',
25
+ [id]
26
+ );
27
+
28
+ if (result.rows.length === 0) {
29
+ return res.status(404).json({ success: false, message: 'Mirchi type not found' });
30
+ }
31
+
32
+ res.json(result.rows[0]);
33
+ } catch (error) {
34
+ console.error('Error fetching mirchi type:', error);
35
+ res.status(500).json({ success: false, message: error.message });
36
+ }
37
+ });
38
+
39
+ // POST create or update mirchi type
40
+ router.post('/', async (req, res) => {
41
+ const client = await pool.connect();
42
+
43
+ try {
44
+ const { id, name, current_rate } = req.body;
45
+
46
+ if (!name) {
47
+ return res.status(400).json({ success: false, message: 'Mirchi type name is required' });
48
+ }
49
+
50
+ const typeId = id || uuidv4();
51
+
52
+ await client.query('BEGIN');
53
+
54
+ // Check if type exists
55
+ const existing = await client.query('SELECT id FROM mirchi_types WHERE id = $1', [typeId]);
56
+
57
+ let result;
58
+ if (existing.rows.length > 0) {
59
+ // Update existing type
60
+ result = await client.query(
61
+ `UPDATE mirchi_types
62
+ SET name = $1, current_rate = $2, updated_at = CURRENT_TIMESTAMP
63
+ WHERE id = $3
64
+ RETURNING *`,
65
+ [name, current_rate || 0, typeId]
66
+ );
67
+ } else {
68
+ // Insert new type
69
+ result = await client.query(
70
+ `INSERT INTO mirchi_types (id, name, current_rate)
71
+ VALUES ($1, $2, $3)
72
+ RETURNING *`,
73
+ [typeId, name, current_rate || 0]
74
+ );
75
+ }
76
+
77
+ await client.query('COMMIT');
78
+
79
+ res.json({
80
+ success: true,
81
+ data: result.rows[0],
82
+ message: existing.rows.length > 0 ? 'Mirchi type updated successfully' : 'Mirchi type created successfully'
83
+ });
84
+
85
+ } catch (error) {
86
+ await client.query('ROLLBACK');
87
+ console.error('Error saving mirchi type:', error);
88
+
89
+ if (error.code === '23505') { // Unique constraint violation
90
+ return res.status(400).json({ success: false, message: 'Mirchi type with this name already exists' });
91
+ }
92
+
93
+ res.status(500).json({ success: false, message: error.message });
94
+ } finally {
95
+ client.release();
96
+ }
97
+ });
98
+
99
+ // DELETE mirchi type
100
+ router.delete('/:id', async (req, res) => {
101
+ try {
102
+ const { id } = req.params;
103
+
104
+ const result = await pool.query(
105
+ 'DELETE FROM mirchi_types WHERE id = $1 RETURNING *',
106
+ [id]
107
+ );
108
+
109
+ if (result.rows.length === 0) {
110
+ return res.status(404).json({ success: false, message: 'Mirchi type not found' });
111
+ }
112
+
113
+ res.json({ success: true, message: 'Mirchi type deleted successfully' });
114
+ } catch (error) {
115
+ console.error('Error deleting mirchi type:', error);
116
+ res.status(500).json({ success: false, message: error.message });
117
+ }
118
+ });
119
+
120
+ module.exports = router;
src/routes/parties.js ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const pool = require('../db/config');
4
+ const { v4: uuidv4 } = require('uuid');
5
+
6
+ // GET all parties
7
+ router.get('/', async (req, res) => {
8
+ try {
9
+ const result = await pool.query(
10
+ 'SELECT * FROM parties ORDER BY name ASC'
11
+ );
12
+ res.json(result.rows);
13
+ } catch (error) {
14
+ console.error('Error fetching parties:', error);
15
+ res.status(500).json({ success: false, message: error.message });
16
+ }
17
+ });
18
+
19
+ // GET party by ID
20
+ router.get('/:id', async (req, res) => {
21
+ try {
22
+ const { id } = req.params;
23
+ const result = await pool.query(
24
+ 'SELECT * FROM parties WHERE id = $1',
25
+ [id]
26
+ );
27
+
28
+ if (result.rows.length === 0) {
29
+ return res.status(404).json({ success: false, message: 'Party not found' });
30
+ }
31
+
32
+ res.json(result.rows[0]);
33
+ } catch (error) {
34
+ console.error('Error fetching party:', error);
35
+ res.status(500).json({ success: false, message: error.message });
36
+ }
37
+ });
38
+
39
+ // POST create or update party
40
+ router.post('/', async (req, res) => {
41
+ const client = await pool.connect();
42
+
43
+ try {
44
+ const { id, name, phone, city, party_type, current_balance } = req.body;
45
+
46
+ if (!name) {
47
+ return res.status(400).json({ success: false, message: 'Party name is required' });
48
+ }
49
+
50
+ const partyId = id || uuidv4();
51
+
52
+ await client.query('BEGIN');
53
+
54
+ // Check if party exists
55
+ const existing = await client.query('SELECT id FROM parties WHERE id = $1', [partyId]);
56
+
57
+ let result;
58
+ if (existing.rows.length > 0) {
59
+ // Update existing party
60
+ result = await client.query(
61
+ `UPDATE parties
62
+ SET name = $1, phone = $2, city = $3, party_type = $4, current_balance = $5, updated_at = CURRENT_TIMESTAMP
63
+ WHERE id = $6
64
+ RETURNING *`,
65
+ [name, phone || '', city || '', party_type || 'both', current_balance || 0, partyId]
66
+ );
67
+ } else {
68
+ // Insert new party
69
+ result = await client.query(
70
+ `INSERT INTO parties (id, name, phone, city, party_type, current_balance)
71
+ VALUES ($1, $2, $3, $4, $5, $6)
72
+ RETURNING *`,
73
+ [partyId, name, phone || '', city || '', party_type || 'both', current_balance || 0]
74
+ );
75
+ }
76
+
77
+ await client.query('COMMIT');
78
+
79
+ res.json({
80
+ success: true,
81
+ data: result.rows[0],
82
+ message: existing.rows.length > 0 ? 'Party updated successfully' : 'Party created successfully'
83
+ });
84
+
85
+ } catch (error) {
86
+ await client.query('ROLLBACK');
87
+ console.error('Error saving party:', error);
88
+ res.status(500).json({ success: false, message: error.message });
89
+ } finally {
90
+ client.release();
91
+ }
92
+ });
93
+
94
+ // DELETE party
95
+ router.delete('/:id', async (req, res) => {
96
+ try {
97
+ const { id } = req.params;
98
+
99
+ const result = await pool.query(
100
+ 'DELETE FROM parties WHERE id = $1 RETURNING *',
101
+ [id]
102
+ );
103
+
104
+ if (result.rows.length === 0) {
105
+ return res.status(404).json({ success: false, message: 'Party not found' });
106
+ }
107
+
108
+ res.json({ success: true, message: 'Party deleted successfully' });
109
+ } catch (error) {
110
+ console.error('Error deleting party:', error);
111
+ res.status(500).json({ success: false, message: error.message });
112
+ }
113
+ });
114
+
115
+ module.exports = router;
src/routes/transactions.js ADDED
@@ -0,0 +1,533 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const router = express.Router();
3
+ const pool = require('../db/config');
4
+ const { v4: uuidv4 } = require('uuid');
5
+
6
+ // GET all transactions
7
+ router.get('/', async (req, res) => {
8
+ try {
9
+ const { party_id, bill_type, is_return } = req.query;
10
+
11
+ let query = `
12
+ SELECT t.*,
13
+ json_agg(DISTINCT jsonb_build_object(
14
+ 'id', ti.id,
15
+ 'mirchi_type_id', ti.mirchi_type_id,
16
+ 'mirchi_name', ti.mirchi_name,
17
+ 'quality', ti.quality,
18
+ 'lot_id', ti.lot_id,
19
+ 'lot_number', l.lot_number,
20
+ 'poti_weights', ti.poti_weights,
21
+ 'gross_weight', ti.gross_weight,
22
+ 'poti_count', ti.poti_count,
23
+ 'total_potya', ti.total_potya,
24
+ 'net_weight', ti.net_weight,
25
+ 'rate_per_kg', ti.rate_per_kg,
26
+ 'item_total', ti.item_total
27
+ )) FILTER (WHERE ti.id IS NOT NULL) as items,
28
+ json_build_object(
29
+ 'cess_percent', e.cess_percent,
30
+ 'cess_amount', e.cess_amount,
31
+ 'adat_percent', e.adat_percent,
32
+ 'adat_amount', e.adat_amount,
33
+ 'poti_rate', e.poti_rate,
34
+ 'poti_amount', e.poti_amount,
35
+ 'hamali_per_poti', e.hamali_per_poti,
36
+ 'hamali_amount', e.hamali_amount,
37
+ 'packaging_hamali_per_poti', e.packaging_hamali_per_poti,
38
+ 'packaging_hamali_amount', e.packaging_hamali_amount,
39
+ 'gaadi_bharni', e.gaadi_bharni,
40
+ 'other_expenses', e.other_expenses
41
+ ) as expenses,
42
+ json_agg(DISTINCT jsonb_build_object(
43
+ 'mode', p.mode,
44
+ 'amount', p.amount,
45
+ 'reference', p.reference
46
+ )) FILTER (WHERE p.id IS NOT NULL) as payments
47
+ FROM transactions t
48
+ LEFT JOIN transaction_items ti ON t.id = ti.transaction_id
49
+ LEFT JOIN lots l ON ti.lot_id = l.id
50
+ LEFT JOIN expenses e ON t.id = e.transaction_id
51
+ LEFT JOIN payments p ON t.id = p.transaction_id
52
+ `;
53
+
54
+ const conditions = [];
55
+ const params = [];
56
+ let paramCount = 1;
57
+
58
+ if (party_id) {
59
+ conditions.push(`t.party_id = $${paramCount}`);
60
+ params.push(party_id);
61
+ paramCount++;
62
+ }
63
+
64
+ if (bill_type) {
65
+ conditions.push(`t.bill_type = $${paramCount}`);
66
+ params.push(bill_type);
67
+ paramCount++;
68
+ }
69
+
70
+ if (is_return !== undefined) {
71
+ conditions.push(`t.is_return = $${paramCount}`);
72
+ params.push(is_return === 'true');
73
+ paramCount++;
74
+ }
75
+
76
+ if (conditions.length > 0) {
77
+ query += ' WHERE ' + conditions.join(' AND ');
78
+ }
79
+
80
+ query += ' GROUP BY t.id, e.id ORDER BY t.bill_date DESC, t.created_at DESC';
81
+
82
+ const result = await pool.query(query, params);
83
+ res.json(result.rows);
84
+ } catch (error) {
85
+ console.error('Error fetching transactions:', error);
86
+ res.status(500).json({ success: false, message: error.message });
87
+ }
88
+ });
89
+
90
+ // GET transaction by ID
91
+ router.get('/:id', async (req, res) => {
92
+ try {
93
+ const { id } = req.params;
94
+
95
+ const result = await pool.query(`
96
+ SELECT t.*,
97
+ json_agg(DISTINCT jsonb_build_object(
98
+ 'id', ti.id,
99
+ 'mirchi_type_id', ti.mirchi_type_id,
100
+ 'mirchi_name', ti.mirchi_name,
101
+ 'quality', ti.quality,
102
+ 'lot_id', ti.lot_id,
103
+ 'lot_number', l.lot_number,
104
+ 'poti_weights', ti.poti_weights,
105
+ 'gross_weight', ti.gross_weight,
106
+ 'poti_count', ti.poti_count,
107
+ 'total_potya', ti.total_potya,
108
+ 'net_weight', ti.net_weight,
109
+ 'rate_per_kg', ti.rate_per_kg,
110
+ 'item_total', ti.item_total
111
+ )) FILTER (WHERE ti.id IS NOT NULL) as items,
112
+ json_build_object(
113
+ 'cess_percent', e.cess_percent,
114
+ 'cess_amount', e.cess_amount,
115
+ 'adat_percent', e.adat_percent,
116
+ 'adat_amount', e.adat_amount,
117
+ 'poti_rate', e.poti_rate,
118
+ 'poti_amount', e.poti_amount,
119
+ 'hamali_per_poti', e.hamali_per_poti,
120
+ 'hamali_amount', e.hamali_amount,
121
+ 'packaging_hamali_per_poti', e.packaging_hamali_per_poti,
122
+ 'packaging_hamali_amount', e.packaging_hamali_amount,
123
+ 'gaadi_bharni', e.gaadi_bharni,
124
+ 'other_expenses', e.other_expenses
125
+ ) as expenses,
126
+ json_agg(DISTINCT jsonb_build_object(
127
+ 'mode', p.mode,
128
+ 'amount', p.amount,
129
+ 'reference', p.reference
130
+ )) FILTER (WHERE p.id IS NOT NULL) as payments
131
+ FROM transactions t
132
+ LEFT JOIN transaction_items ti ON t.id = ti.transaction_id
133
+ LEFT JOIN lots l ON ti.lot_id = l.id
134
+ LEFT JOIN expenses e ON t.id = e.transaction_id
135
+ LEFT JOIN payments p ON t.id = p.transaction_id
136
+ WHERE t.id = $1
137
+ GROUP BY t.id, e.id
138
+ `, [id]);
139
+
140
+ if (result.rows.length === 0) {
141
+ return res.status(404).json({ success: false, message: 'Transaction not found' });
142
+ }
143
+
144
+ res.json(result.rows[0]);
145
+ } catch (error) {
146
+ console.error('Error fetching transaction:', error);
147
+ res.status(500).json({ success: false, message: error.message });
148
+ }
149
+ });
150
+
151
+ // POST create transaction
152
+ router.post('/', async (req, res) => {
153
+ const client = await pool.connect();
154
+
155
+ try {
156
+ const {
157
+ id,
158
+ bill_number,
159
+ bill_date,
160
+ bill_type,
161
+ is_return,
162
+ party_id,
163
+ party_name,
164
+ items,
165
+ expenses,
166
+ payments,
167
+ gross_weight_total,
168
+ net_weight_total,
169
+ subtotal,
170
+ total_expenses,
171
+ total_amount,
172
+ paid_amount,
173
+ balance_amount
174
+ } = req.body;
175
+
176
+ // Validation
177
+ if (!party_id) {
178
+ return res.status(400).json({ success: false, message: 'Party is required' });
179
+ }
180
+
181
+ if (!items || items.length === 0) {
182
+ return res.status(400).json({ success: false, message: 'At least one item is required' });
183
+ }
184
+
185
+ await client.query('BEGIN');
186
+
187
+ const transactionId = id || uuidv4();
188
+
189
+ console.log('=== BACKEND: SAVING TRANSACTION ===');
190
+ console.log('Transaction ID:', transactionId);
191
+ console.log('Items received:', items?.length);
192
+ console.log('Items data:', JSON.stringify(items, null, 2));
193
+
194
+ // 1. Insert transaction
195
+ const txResult = await client.query(
196
+ `INSERT INTO transactions (
197
+ id, bill_number, bill_date, bill_type, is_return, party_id, party_name,
198
+ gross_weight_total, net_weight_total, subtotal, total_expenses,
199
+ total_amount, paid_amount, balance_amount
200
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)
201
+ RETURNING *`,
202
+ [
203
+ transactionId, bill_number, bill_date, bill_type, is_return || false,
204
+ party_id, party_name, gross_weight_total, net_weight_total,
205
+ subtotal, total_expenses, total_amount, paid_amount, balance_amount
206
+ ]
207
+ );
208
+
209
+ // 2. Insert transaction items
210
+ console.log('=== INSERTING ITEMS ===');
211
+ for (const item of items) {
212
+ const itemId = item.id || uuidv4();
213
+ console.log('Inserting item:', itemId, item.mirchi_name);
214
+ await client.query(
215
+ `INSERT INTO transaction_items (
216
+ id, transaction_id, mirchi_type_id, mirchi_name, quality, lot_id,
217
+ poti_weights, gross_weight, poti_count, total_potya, net_weight,
218
+ rate_per_kg, item_total
219
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`,
220
+ [
221
+ itemId, transactionId, item.mirchi_type_id, item.mirchi_name,
222
+ item.quality, item.lot_id, JSON.stringify(item.poti_weights),
223
+ item.gross_weight, item.poti_count, item.total_potya,
224
+ item.net_weight, item.rate_per_kg, item.item_total
225
+ ]
226
+ );
227
+ }
228
+ console.log('=== ITEMS INSERTED ===');
229
+
230
+ // 3. Insert expenses
231
+ if (expenses) {
232
+ await client.query(
233
+ `INSERT INTO expenses (
234
+ transaction_id, cess_percent, cess_amount, adat_percent, adat_amount,
235
+ poti_rate, poti_amount, hamali_per_poti, hamali_amount,
236
+ packaging_hamali_per_poti, packaging_hamali_amount, gaadi_bharni, other_expenses
237
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)`,
238
+ [
239
+ transactionId, expenses.cess_percent || 0, expenses.cess_amount || 0,
240
+ expenses.adat_percent || 0, expenses.adat_amount || 0,
241
+ expenses.poti_rate || 0, expenses.poti_amount || 0,
242
+ expenses.hamali_per_poti || 0, expenses.hamali_amount || 0,
243
+ expenses.packaging_hamali_per_poti || 0, expenses.packaging_hamali_amount || 0,
244
+ expenses.gaadi_bharni || 0, expenses.other_expenses || 0
245
+ ]
246
+ );
247
+ }
248
+
249
+ // 4. Insert payments
250
+ if (payments && payments.length > 0) {
251
+ for (const payment of payments) {
252
+ if (payment.amount > 0) {
253
+ await client.query(
254
+ `INSERT INTO payments (transaction_id, mode, amount, reference)
255
+ VALUES ($1, $2, $3, $4)`,
256
+ [transactionId, payment.mode, payment.amount, payment.reference]
257
+ );
258
+ }
259
+ }
260
+ }
261
+
262
+ // 5. Update party balance
263
+ if (bill_type === 'jawaak') {
264
+ // Purchase: We owe them (decrease balance)
265
+ if (is_return) {
266
+ await client.query(
267
+ 'UPDATE parties SET current_balance = current_balance + $1 WHERE id = $2',
268
+ [balance_amount, party_id]
269
+ );
270
+ } else {
271
+ await client.query(
272
+ 'UPDATE parties SET current_balance = current_balance - $1 WHERE id = $2',
273
+ [balance_amount, party_id]
274
+ );
275
+ }
276
+ } else {
277
+ // Sales: They owe us (increase balance)
278
+ if (is_return) {
279
+ await client.query(
280
+ 'UPDATE parties SET current_balance = current_balance - $1 WHERE id = $2',
281
+ [balance_amount, party_id]
282
+ );
283
+ } else {
284
+ await client.query(
285
+ 'UPDATE parties SET current_balance = current_balance + $1 WHERE id = $2',
286
+ [balance_amount, party_id]
287
+ );
288
+ }
289
+ }
290
+
291
+ // 6. Update lots (stock management)
292
+ // AWAAK = Purchase (Stock IN), JAWAAK = Sale (Stock OUT)
293
+ if (bill_type === 'awaak' && !is_return) {
294
+ // Purchase: Create new lots or update existing ones
295
+ for (let i = 0; i < items.length; i++) {
296
+ const item = items[i];
297
+ const mirchi = await client.query('SELECT name FROM mirchi_types WHERE id = $1', [item.mirchi_type_id]);
298
+ const mirchiName = mirchi.rows[0]?.name || 'Unknown';
299
+
300
+ // Check if lot_number is provided (user-entered or selected existing)
301
+ if (item.lot_number) {
302
+ // Check if lot already exists
303
+ const existingLot = await client.query(
304
+ 'SELECT id FROM lots WHERE lot_number = $1',
305
+ [item.lot_number]
306
+ );
307
+
308
+ if (existingLot.rows.length > 0) {
309
+ // Update existing lot - add stock
310
+ const lotId = existingLot.rows[0].id;
311
+ await client.query(
312
+ `UPDATE lots
313
+ SET total_quantity = total_quantity + $1,
314
+ remaining_quantity = remaining_quantity + $1,
315
+ status = 'active',
316
+ updated_at = CURRENT_TIMESTAMP
317
+ WHERE id = $2`,
318
+ [item.net_weight, lotId]
319
+ );
320
+
321
+ // Update item with lot_id
322
+ await client.query(
323
+ 'UPDATE transaction_items SET lot_id = $1 WHERE id = $2',
324
+ [lotId, item.id || uuidv4()]
325
+ );
326
+ } else {
327
+ // Create new lot with user-provided lot_number
328
+ const lotId = uuidv4();
329
+ await client.query(
330
+ `INSERT INTO lots (id, lot_number, mirchi_type_id, mirchi_name, total_quantity, remaining_quantity, purchase_date, status, avg_rate)
331
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)`,
332
+ [lotId, item.lot_number, item.mirchi_type_id, mirchiName, item.net_weight, item.net_weight, bill_date, 'active', item.rate_per_kg]
333
+ );
334
+
335
+ // Update item with lot_id
336
+ await client.query(
337
+ 'UPDATE transaction_items SET lot_id = $1 WHERE id = $2',
338
+ [lotId, item.id || uuidv4()]
339
+ );
340
+ }
341
+ }
342
+ }
343
+ } else if (bill_type === 'awaak' && is_return) {
344
+ // Purchase Return: Reduce stock from lots
345
+ for (const item of items) {
346
+ if (item.lot_id) {
347
+ await client.query(
348
+ `UPDATE lots
349
+ SET total_quantity = total_quantity - $1,
350
+ remaining_quantity = remaining_quantity - $1,
351
+ status = CASE WHEN remaining_quantity - $1 <= 0 THEN 'sold_out' ELSE 'active' END,
352
+ updated_at = CURRENT_TIMESTAMP
353
+ WHERE id = $2`,
354
+ [item.net_weight, item.lot_id]
355
+ );
356
+ }
357
+ }
358
+ } else if (bill_type === 'jawaak' && !is_return) {
359
+ // Sale: Reduce stock from selected lots using GROSS weight
360
+ // (NET weight is for billing, GROSS weight is actual physical stock)
361
+ for (const item of items) {
362
+ if (item.lot_id) {
363
+ await client.query(
364
+ `UPDATE lots
365
+ SET remaining_quantity = remaining_quantity - $1,
366
+ status = CASE WHEN remaining_quantity - $1 <= 0 THEN 'sold_out' ELSE 'active' END,
367
+ updated_at = CURRENT_TIMESTAMP
368
+ WHERE id = $2`,
369
+ [item.gross_weight, item.lot_id]
370
+ );
371
+ }
372
+ }
373
+ } else if (bill_type === 'jawaak' && is_return) {
374
+ // Sales Return: Add stock back to lots using GROSS weight
375
+ // (Must match the GROSS weight that was originally deducted)
376
+ for (const item of items) {
377
+ if (item.lot_id) {
378
+ await client.query(
379
+ `UPDATE lots
380
+ SET remaining_quantity = remaining_quantity + $1,
381
+ status = CASE WHEN remaining_quantity + $1 > 0 THEN 'active' ELSE status END,
382
+ updated_at = CURRENT_TIMESTAMP
383
+ WHERE id = $2`,
384
+ [item.gross_weight, item.lot_id]
385
+ );
386
+ }
387
+ }
388
+ }
389
+
390
+ await client.query('COMMIT');
391
+
392
+ // Fetch the complete transaction with items, expenses, and payments
393
+ const completeTransaction = await client.query(`
394
+ SELECT t.*,
395
+ json_agg(DISTINCT jsonb_build_object(
396
+ 'id', ti.id,
397
+ 'mirchi_type_id', ti.mirchi_type_id,
398
+ 'mirchi_name', ti.mirchi_name,
399
+ 'quality', ti.quality,
400
+ 'lot_id', ti.lot_id,
401
+ 'lot_number', l.lot_number,
402
+ 'poti_weights', ti.poti_weights,
403
+ 'gross_weight', ti.gross_weight,
404
+ 'poti_count', ti.poti_count,
405
+ 'total_potya', ti.total_potya,
406
+ 'net_weight', ti.net_weight,
407
+ 'rate_per_kg', ti.rate_per_kg,
408
+ 'item_total', ti.item_total
409
+ )) FILTER (WHERE ti.id IS NOT NULL) as items,
410
+ json_build_object(
411
+ 'cess_percent', e.cess_percent,
412
+ 'cess_amount', e.cess_amount,
413
+ 'adat_percent', e.adat_percent,
414
+ 'adat_amount', e.adat_amount,
415
+ 'poti_rate', e.poti_rate,
416
+ 'poti_amount', e.poti_amount,
417
+ 'hamali_per_poti', e.hamali_per_poti,
418
+ 'hamali_amount', e.hamali_amount,
419
+ 'packaging_hamali_per_poti', e.packaging_hamali_per_poti,
420
+ 'packaging_hamali_amount', e.packaging_hamali_amount,
421
+ 'gaadi_bharni', e.gaadi_bharni,
422
+ 'other_expenses', e.other_expenses
423
+ ) as expenses,
424
+ json_agg(DISTINCT jsonb_build_object(
425
+ 'mode', p.mode,
426
+ 'amount', p.amount,
427
+ 'reference', p.reference
428
+ )) FILTER (WHERE p.id IS NOT NULL) as payments
429
+ FROM transactions t
430
+ LEFT JOIN transaction_items ti ON t.id = ti.transaction_id
431
+ LEFT JOIN lots l ON ti.lot_id = l.id
432
+ LEFT JOIN expenses e ON t.id = e.transaction_id
433
+ LEFT JOIN payments p ON t.id = p.transaction_id
434
+ WHERE t.id = $1
435
+ GROUP BY t.id, e.id
436
+ `, [transactionId]);
437
+
438
+ res.json({
439
+ success: true,
440
+ data: completeTransaction.rows[0],
441
+ message: 'Transaction saved successfully'
442
+ });
443
+
444
+ } catch (error) {
445
+ await client.query('ROLLBACK');
446
+ console.error('Error saving transaction:', error);
447
+ res.status(500).json({ success: false, message: error.message });
448
+ } finally {
449
+ client.release();
450
+ }
451
+ });
452
+
453
+ // PATCH update transaction payment
454
+ router.patch('/:id/payment', async (req, res) => {
455
+ const client = await pool.connect();
456
+
457
+ try {
458
+ const { id } = req.params;
459
+ const { amount } = req.body;
460
+
461
+ if (!amount || amount <= 0) {
462
+ return res.status(400).json({ success: false, message: 'Amount must be greater than 0' });
463
+ }
464
+
465
+ await client.query('BEGIN');
466
+
467
+ // Get transaction
468
+ const txResult = await client.query(
469
+ 'SELECT * FROM transactions WHERE id = $1',
470
+ [id]
471
+ );
472
+
473
+ if (txResult.rows.length === 0) {
474
+ await client.query('ROLLBACK');
475
+ return res.status(404).json({ success: false, message: 'Transaction not found' });
476
+ }
477
+
478
+ const tx = txResult.rows[0];
479
+
480
+ if (amount > tx.balance_amount) {
481
+ await client.query('ROLLBACK');
482
+ return res.status(400).json({ success: false, message: 'Amount exceeds due balance' });
483
+ }
484
+
485
+ // Update transaction
486
+ await client.query(
487
+ `UPDATE transactions
488
+ SET paid_amount = paid_amount + $1,
489
+ balance_amount = balance_amount - $1,
490
+ updated_at = CURRENT_TIMESTAMP
491
+ WHERE id = $2`,
492
+ [amount, id]
493
+ );
494
+
495
+ // Add payment record
496
+ await client.query(
497
+ `INSERT INTO payments (transaction_id, mode, amount, reference)
498
+ VALUES ($1, $2, $3, $4)`,
499
+ [id, 'cash', amount, `Due Payment - ${new Date().toLocaleDateString()}`]
500
+ );
501
+
502
+ // Update party balance
503
+ if (tx.bill_type === 'awaak') {
504
+ // Sales: Reduce receivable
505
+ await client.query(
506
+ 'UPDATE parties SET current_balance = current_balance - $1 WHERE id = $2',
507
+ [amount, tx.party_id]
508
+ );
509
+ } else {
510
+ // Purchase: Reduce payable
511
+ await client.query(
512
+ 'UPDATE parties SET current_balance = current_balance + $1 WHERE id = $2',
513
+ [amount, tx.party_id]
514
+ );
515
+ }
516
+
517
+ await client.query('COMMIT');
518
+
519
+ res.json({
520
+ success: true,
521
+ message: 'Payment updated successfully'
522
+ });
523
+
524
+ } catch (error) {
525
+ await client.query('ROLLBACK');
526
+ console.error('Error updating payment:', error);
527
+ res.status(500).json({ success: false, message: error.message });
528
+ } finally {
529
+ client.release();
530
+ }
531
+ });
532
+
533
+ module.exports = router;
src/server.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const cors = require('cors');
3
+ require('dotenv').config();
4
+
5
+ const partiesRouter = require('./routes/parties');
6
+ const mirchiTypesRouter = require('./routes/mirchiTypes');
7
+ const lotsRouter = require('./routes/lots');
8
+ const transactionsRouter = require('./routes/transactions');
9
+
10
+ const app = express();
11
+ const PORT = process.env.PORT || 4000;
12
+
13
+ // Middleware
14
+ app.use(cors());
15
+ app.use(express.json());
16
+ app.use(express.urlencoded({ extended: true }));
17
+
18
+ // Request logging
19
+ app.use((req, res, next) => {
20
+ console.log(`${new Date().toISOString()} - ${req.method} ${req.path}`);
21
+ next();
22
+ });
23
+
24
+ // Routes
25
+ app.use('/api/parties', partiesRouter);
26
+ app.use('/api/mirchi-types', mirchiTypesRouter);
27
+ app.use('/api/lots', lotsRouter);
28
+ app.use('/api/transactions', transactionsRouter);
29
+
30
+ // Health check
31
+ app.get('/health', (req, res) => {
32
+ res.json({ status: 'ok', timestamp: new Date().toISOString() });
33
+ });
34
+
35
+ // Root endpoint
36
+ app.get('/', (req, res) => {
37
+ res.json({
38
+ message: 'Pattanshetty Inventory Management API',
39
+ version: '1.0.0',
40
+ endpoints: {
41
+ parties: '/api/parties',
42
+ mirchiTypes: '/api/mirchi-types',
43
+ lots: '/api/lots',
44
+ transactions: '/api/transactions'
45
+ }
46
+ });
47
+ });
48
+
49
+ // Error handling middleware
50
+ app.use((err, req, res, next) => {
51
+ console.error('Error:', err);
52
+ res.status(500).json({
53
+ success: false,
54
+ message: err.message || 'Internal server error'
55
+ });
56
+ });
57
+
58
+ // 404 handler
59
+ app.use((req, res) => {
60
+ res.status(404).json({
61
+ success: false,
62
+ message: 'Route not found'
63
+ });
64
+ });
65
+
66
+ // Start server
67
+ app.listen(PORT, () => {
68
+ console.log(`๐Ÿš€ Server running on port ${PORT}`);
69
+ console.log(`๐Ÿ“ API available at http://localhost:${PORT}`);
70
+ console.log(`๐Ÿ’š Health check: http://localhost:${PORT}/health`);
71
+ });
72
+
73
+ module.exports = app;