create-myexam-app 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +29 -28
- package/package.json +1 -1
- package/projects/EPMS/backend/.env +1 -1
- package/projects/EPMS/backend/config/db.js +1 -1
- package/projects/EPMS/backend/controllers/authController.js +1 -1
- package/projects/EPMS/backend/middleware/auth.js +2 -6
- package/projects/EPMS/backend/server.js +2 -1
- package/projects/Elysee File/# Full-Stack [SUBJECT] Management (edited).txt +214 -0
- package/projects/SCMS/backend/.env +1 -1
- package/projects/SCMS/backend/config/db.js +1 -1
- package/projects/SCMS/backend/controllers/authController.js +1 -1
- package/projects/SCMS/backend/middleware/auth.js +2 -6
- package/projects/SCMS/backend/server.js +3 -7
- package/projects/SCMS/frontend/src/App.jsx +1 -2
- package/projects/SMS/backend-project/config/db.js +12 -0
- package/projects/SMS/backend-project/controllers/authController.js +90 -0
- package/projects/{SCMS/backend → SMS/backend-project}/controllers/productController.js +27 -26
- package/projects/SMS/backend-project/controllers/reportController.js +63 -0
- package/projects/SMS/backend-project/controllers/salesController.js +124 -0
- package/projects/SMS/backend-project/controllers/supplierController.js +66 -0
- package/projects/SMS/backend-project/controllers/warehouseController.js +56 -0
- package/projects/SMS/backend-project/middleware/auth.js +32 -0
- package/projects/SMS/backend-project/models/StockTransaction.js +32 -0
- package/projects/SMS/backend-project/models/User.js +28 -0
- package/projects/SMS/backend-project/models/Warehouse.js +24 -0
- package/projects/{SCMS/backend → SMS/backend-project}/models/product.js +16 -16
- package/projects/SMS/backend-project/models/supplier.js +25 -0
- package/projects/{SMS- → SMS}/backend-project/package-lock.json +2190 -1568
- package/projects/SMS/backend-project/package.json +23 -0
- package/projects/SMS/backend-project/routes/SupplierRoutes.js +15 -0
- package/projects/SMS/backend-project/routes/authRoutes.js +11 -0
- package/projects/SMS/backend-project/routes/protectedRoutes.js +18 -0
- package/projects/SMS/backend-project/routes/reportRoutes.js +9 -0
- package/projects/SMS/backend-project/routes/salesRoutes.js +14 -0
- package/projects/SMS/backend-project/routes/warehouseRoutes.js +20 -0
- package/projects/SMS/backend-project/server.js +33 -0
- package/projects/{SMS- → SMS}/frontend-project/index.html +1 -1
- package/projects/{SMS- → SMS}/frontend-project/package-lock.json +19 -19
- package/projects/{SMS- → SMS}/frontend-project/package.json +2 -2
- package/projects/SMS/frontend-project/src/App.jsx +61 -0
- package/projects/SMS/frontend-project/src/components/AppLayout.jsx +97 -0
- package/projects/SMS/frontend-project/src/components/Dashboard.jsx +34 -0
- package/projects/SMS/frontend-project/src/components/ProtectedRoute.jsx +13 -0
- package/projects/SMS/frontend-project/src/index.css +47 -0
- package/projects/SMS/frontend-project/src/pages/Login.jsx +81 -0
- package/projects/SMS/frontend-project/src/pages/Product.jsx +122 -0
- package/projects/SMS/frontend-project/src/pages/Profile.jsx +64 -0
- package/projects/SMS/frontend-project/src/pages/Register.jsx +110 -0
- package/projects/SMS/frontend-project/src/pages/Reports.jsx +88 -0
- package/projects/SMS/frontend-project/src/pages/Sales.jsx +224 -0
- package/projects/SMS/frontend-project/src/pages/Warehouse.jsx +82 -0
- package/projects/{SMS- → SMS}/frontend-project/vite.config.js +1 -4
- package/projects/SRMS/backend/.env +3 -3
- package/projects/SRMS/backend/config/db.js +12 -0
- package/projects/SRMS/backend/controllers/authController.js +90 -0
- package/projects/SRMS/backend/controllers/customerController.js +45 -0
- package/projects/SRMS/backend/controllers/productController.js +44 -0
- package/projects/SRMS/backend/controllers/reportsController.js +44 -0
- package/projects/SRMS/backend/controllers/salesController.js +88 -0
- package/projects/SRMS/backend/middleware/auth.js +24 -13
- package/projects/SRMS/backend/models/User.js +26 -6
- package/projects/SRMS/backend/models/customer.js +36 -0
- package/projects/SRMS/backend/models/product.js +30 -0
- package/projects/SRMS/backend/models/sales.js +44 -0
- package/projects/SRMS/backend/package-lock.json +2190 -1568
- package/projects/SRMS/backend/package.json +23 -23
- package/projects/SRMS/backend/routes/authRoutes.js +11 -0
- package/projects/SRMS/backend/routes/customerRoutes.js +12 -0
- package/projects/SRMS/backend/routes/productRoutes.js +12 -0
- package/projects/SRMS/backend/routes/reportsRoutes.js +10 -0
- package/projects/SRMS/backend/routes/salesRoutes.js +15 -0
- package/projects/SRMS/backend/server.js +22 -17
- package/projects/SRMS/frontend/index.html +1 -1
- package/projects/SRMS/frontend/package-lock.json +24 -24
- package/projects/SRMS/frontend/package.json +1 -1
- package/projects/SRMS/frontend/src/App.jsx +27 -32
- package/projects/SRMS/frontend/src/components/Dashboard.jsx +32 -0
- package/projects/SRMS/frontend/src/components/Layout.jsx +104 -0
- package/projects/SRMS/frontend/src/index.css +57 -1
- package/projects/SRMS/frontend/src/pages/Customer.jsx +127 -104
- package/projects/SRMS/frontend/src/pages/Login.jsx +76 -52
- package/projects/SRMS/frontend/src/pages/Product.jsx +116 -95
- package/projects/SRMS/frontend/src/pages/Profile.jsx +69 -0
- package/projects/SRMS/frontend/src/pages/Register.jsx +111 -56
- package/projects/SRMS/frontend/src/pages/Reports.jsx +72 -229
- package/projects/SRMS/frontend/src/pages/Sales.jsx +269 -0
- package/projects/SRMS/frontend/vite.config.js +1 -4
- package/projects/sims/backend/middleware/auth.js +1 -5
- package/projects/user/Seed.js +29 -0
- package/projects/{SMS-/backend-project/middlware → user}/auth.js +2 -1
- package/projects/{SRMS/frontend/App.jsx → user/h.jsx} +1 -1
- package/projects/SCMS/backend/routes/protectedRoutes.js +0 -10
- package/projects/SCMS/frontend/src/components/ProtectedRoute.jsx +0 -30
- package/projects/SMS-/backend-project/.env +0 -3
- package/projects/SMS-/backend-project/controllers/ProductController.js +0 -19
- package/projects/SMS-/backend-project/controllers/StockTransactionController.js +0 -46
- package/projects/SMS-/backend-project/controllers/UserController.js +0 -35
- package/projects/SMS-/backend-project/controllers/WarehouseController.js +0 -19
- package/projects/SMS-/backend-project/db/connectDB.js +0 -11
- package/projects/SMS-/backend-project/models/Product.js +0 -13
- package/projects/SMS-/backend-project/models/StockTransaction.js +0 -9
- package/projects/SMS-/backend-project/models/User.js +0 -8
- package/projects/SMS-/backend-project/models/Warehouse.js +0 -9
- package/projects/SMS-/backend-project/package.json +0 -23
- package/projects/SMS-/backend-project/routes/ProductRoutes.js +0 -11
- package/projects/SMS-/backend-project/routes/StockTransactionRoutes.js +0 -14
- package/projects/SMS-/backend-project/routes/UserRoutes.js +0 -10
- package/projects/SMS-/backend-project/routes/WarehouseRoutes.js +0 -10
- package/projects/SMS-/backend-project/server.js +0 -24
- package/projects/SMS-/frontend-project/public/icons.svg +0 -24
- package/projects/SMS-/frontend-project/src/App.css +0 -184
- package/projects/SMS-/frontend-project/src/App.jsx +0 -41
- package/projects/SMS-/frontend-project/src/assets/hero.png +0 -0
- package/projects/SMS-/frontend-project/src/assets/react.svg +0 -1
- package/projects/SMS-/frontend-project/src/assets/vite.svg +0 -1
- package/projects/SMS-/frontend-project/src/components/Navbar.jsx +0 -37
- package/projects/SMS-/frontend-project/src/index.css +0 -1
- package/projects/SMS-/frontend-project/src/pages/Dashboard.jsx +0 -31
- package/projects/SMS-/frontend-project/src/pages/Login.jsx +0 -79
- package/projects/SMS-/frontend-project/src/pages/Product.jsx +0 -135
- package/projects/SMS-/frontend-project/src/pages/Register.jsx +0 -72
- package/projects/SMS-/frontend-project/src/pages/Reports.jsx +0 -302
- package/projects/SMS-/frontend-project/src/pages/StockTransaction.jsx +0 -185
- package/projects/SMS-/frontend-project/src/pages/Warehouse.jsx +0 -125
- package/projects/SRMS/backend/controllers/CustomerControllers.js +0 -29
- package/projects/SRMS/backend/controllers/ProductControllers.js +0 -31
- package/projects/SRMS/backend/controllers/SaleControllers.js +0 -49
- package/projects/SRMS/backend/controllers/UserControllers.js +0 -40
- package/projects/SRMS/backend/db/connectDB.js +0 -11
- package/projects/SRMS/backend/models/Customer.js +0 -13
- package/projects/SRMS/backend/models/Product.js +0 -9
- package/projects/SRMS/backend/models/Sale.js +0 -12
- package/projects/SRMS/backend/routes/CustomerRoutes.js +0 -11
- package/projects/SRMS/backend/routes/ProductRoutes.js +0 -11
- package/projects/SRMS/backend/routes/SaleRoutes.js +0 -13
- package/projects/SRMS/backend/routes/UserRoutes.js +0 -11
- package/projects/SRMS/frontend/README.md +0 -16
- package/projects/SRMS/frontend/public/icons.svg +0 -24
- package/projects/SRMS/frontend/src/App.css +0 -184
- package/projects/SRMS/frontend/src/assets/hero.png +0 -0
- package/projects/SRMS/frontend/src/assets/react.svg +0 -1
- package/projects/SRMS/frontend/src/assets/vite.svg +0 -1
- package/projects/SRMS/frontend/src/axiosInstance.js +0 -11
- package/projects/SRMS/frontend/src/components/Navbar.jsx +0 -30
- package/projects/SRMS/frontend/src/pages/Dashboard.jsx +0 -31
- package/projects/SRMS/frontend/src/pages/Sale.jsx +0 -228
- /package/projects/{SCMS/backend → SMS/backend-project}/routes/productRoutes.js +0 -0
- /package/projects/{SMS- → SMS}/frontend-project/README.md +0 -0
- /package/projects/{SMS- → SMS}/frontend-project/eslint.config.js +0 -0
- /package/projects/{SMS- → SMS}/frontend-project/public/favicon.svg +0 -0
- /package/projects/{SMS- → SMS}/frontend-project/src/main.jsx +0 -0
- /package/projects/{SMS-/frontend-project/src → user}/axiosInstance.js +0 -0
package/index.js
CHANGED
|
@@ -10,41 +10,42 @@ const rl = readline.createInterface({
|
|
|
10
10
|
output: process.stdout
|
|
11
11
|
})
|
|
12
12
|
console.log('\n[1] Car Repair Parking Managemnt System')
|
|
13
|
-
console.log('[2]
|
|
14
|
-
console.log('[3]Employee Payroll Management System
|
|
15
|
-
console.log('[4]
|
|
16
|
-
console.log('[5]
|
|
17
|
-
console.log('[6]
|
|
18
|
-
console.log('[7]Supply Chain
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
console.log('[2]Elysee File Prompt')
|
|
14
|
+
console.log('[3]Employee Payroll Management System')
|
|
15
|
+
console.log('[4]Employee Payroll Management System Elysee')
|
|
16
|
+
console.log('[5]middleware')
|
|
17
|
+
console.log('[6] Parking Management System')
|
|
18
|
+
console.log('[7]Supply Chain Managemnt System')
|
|
19
|
+
console.log('[8]Supply Chain Management System Elysee')
|
|
20
|
+
console.log('[9] School fee Management System')
|
|
21
|
+
console.log('[10]Stock Hub Management System')
|
|
22
|
+
console.log('[11]Stock Invetory Management System')
|
|
23
|
+
console.log('[12]Stock Management System')
|
|
24
|
+
console.log('[13]Sales Record Management System')
|
|
25
|
+
console.log('[14]Sales Record Management System Elysee')
|
|
26
|
+
console.log('[15]userController.js')
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
|
|
30
|
-
rl.question('Pick (1-
|
|
31
|
+
rl.question('Pick (1-15): ', (answer) => {
|
|
31
32
|
|
|
32
33
|
const projects = {
|
|
33
34
|
'1':'crpms',
|
|
34
|
-
'2':'
|
|
35
|
-
'3':'EPMS
|
|
36
|
-
'4':'
|
|
37
|
-
'5':
|
|
38
|
-
'6':'
|
|
39
|
-
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
-
'
|
|
44
|
-
'
|
|
45
|
-
'
|
|
46
|
-
'
|
|
47
|
-
'
|
|
35
|
+
'2':'Elysee File',
|
|
36
|
+
'3':'EPMS',
|
|
37
|
+
'4':'EPMS(Ely)',
|
|
38
|
+
'5':'middleware',
|
|
39
|
+
'6': 'parking managementt system',
|
|
40
|
+
'7':'SCMS',
|
|
41
|
+
'8':'SCMS(Ely)',
|
|
42
|
+
'9': 'sfms-app',
|
|
43
|
+
'10':'SHMS(Ely)',
|
|
44
|
+
'11':'sims',
|
|
45
|
+
'12': 'SMS',
|
|
46
|
+
'13':'SRMS',
|
|
47
|
+
'14':'SRMS(Ely)',
|
|
48
|
+
'15':'user',
|
|
48
49
|
|
|
49
50
|
|
|
50
51
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ const mongoose = require('mongoose');
|
|
|
2
2
|
|
|
3
3
|
const connectDB = async () => {
|
|
4
4
|
try {
|
|
5
|
-
await mongoose.connect(
|
|
5
|
+
await mongoose.connect(process.env.MONGO_URI);
|
|
6
6
|
console.log('MongoDB connected');
|
|
7
7
|
} catch (error) {
|
|
8
8
|
console.error('MongoDB connection error:', error);
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
//it is checking if the user is authenticated by checking the token in the header(the header is the part of the request that contains the token)
|
|
3
|
-
//if the user is not authenticated, it will return a 401 status code and a message that the user is not authorized
|
|
4
|
-
//if the user is authenticated, it will return the user object
|
|
5
|
-
//and the user object is the user that is authenticated
|
|
1
|
+
|
|
6
2
|
|
|
7
3
|
const jwt = require('jsonwebtoken');
|
|
8
4
|
const User = require('../models/User');
|
|
9
|
-
const JWT_SECRET =
|
|
5
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
10
6
|
|
|
11
7
|
exports.protect = async (req, res, next) => {
|
|
12
8
|
try {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require('dotenv').config();
|
|
1
2
|
const express = require('express');
|
|
2
3
|
const cors = require('cors');
|
|
3
4
|
|
|
@@ -21,7 +22,7 @@ app.use('/api/employees', employeeRoutes);
|
|
|
21
22
|
app.use('/api/salaries', salaryRoutes);
|
|
22
23
|
app.use('/api/protected', protectedRoutes);
|
|
23
24
|
|
|
24
|
-
const PORT = 5001
|
|
25
|
+
const PORT = process.env.PORT || 5001
|
|
25
26
|
app.listen(PORT, () => {
|
|
26
27
|
console.log(`Server running on http://localhost:${PORT}`);
|
|
27
28
|
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# OPENCODE EXECUTION RULES
|
|
2
|
+
|
|
3
|
+
IMPORTANT
|
|
4
|
+
|
|
5
|
+
Follow the original project specification exactly as provided.
|
|
6
|
+
|
|
7
|
+
Do not remove, simplify, replace, or ignore any requirement from the original specification.
|
|
8
|
+
|
|
9
|
+
These instructions are additional rules that must be followed during project generation.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## STRICT IMPLEMENTATION POLICY
|
|
14
|
+
|
|
15
|
+
* Follow the specification exactly.
|
|
16
|
+
* Do not invent new business requirements.
|
|
17
|
+
* Do not add features that are not requested.
|
|
18
|
+
* Only add improvements listed in the "Project Improvements" section below.
|
|
19
|
+
* If any requirement is unclear, ask before implementing.
|
|
20
|
+
* Avoid introducing additional frameworks, libraries, architectures, or technologies that were not requested.
|
|
21
|
+
* Keep the project maintainable, professional, and suitable for academic practical examination purposes.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## ISOLATED DEVELOPMENT WORKSPACE
|
|
26
|
+
|
|
27
|
+
Create a dedicated workspace named:
|
|
28
|
+
|
|
29
|
+
.cache
|
|
30
|
+
|
|
31
|
+
This workspace will be used for all generated code, planning, temporary files, logs, documentation, and experimentation.
|
|
32
|
+
|
|
33
|
+
All generated content must remain inside:
|
|
34
|
+
|
|
35
|
+
.cache/
|
|
36
|
+
|
|
37
|
+
Example structure:
|
|
38
|
+
|
|
39
|
+
.cache/
|
|
40
|
+
├── backend-project/
|
|
41
|
+
├── frontend-project/
|
|
42
|
+
├── docs/
|
|
43
|
+
├── logs/
|
|
44
|
+
├── temp/
|
|
45
|
+
├── PROJECT_SUMMARY.md
|
|
46
|
+
└── SETUP.md
|
|
47
|
+
|
|
48
|
+
Never generate project files outside this workspace.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## WORKSPACE ALIAS SYSTEM
|
|
53
|
+
|
|
54
|
+
The user may use navigation aliases.
|
|
55
|
+
|
|
56
|
+
Alias Mapping:
|
|
57
|
+
|
|
58
|
+
1 = Main Project Workspace
|
|
59
|
+
|
|
60
|
+
10 = .cache Workspace
|
|
61
|
+
|
|
62
|
+
These aliases are navigation shortcuts only.
|
|
63
|
+
|
|
64
|
+
Do NOT create actual folders named:
|
|
65
|
+
|
|
66
|
+
* 1
|
|
67
|
+
* 10
|
|
68
|
+
* project10
|
|
69
|
+
* generated10
|
|
70
|
+
|
|
71
|
+
The actual folder name must remain:
|
|
72
|
+
|
|
73
|
+
.cache
|
|
74
|
+
|
|
75
|
+
Examples:
|
|
76
|
+
|
|
77
|
+
* "Open 1 controllers" → Open controllers in the main project.
|
|
78
|
+
* "Open 10 routes" → Open routes inside .cache.
|
|
79
|
+
* "Add controller in 10" → Create or modify files only inside .cache.
|
|
80
|
+
* "Return to 1" → Return to the main project.
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## PROJECT GENERATION
|
|
85
|
+
|
|
86
|
+
Generate the complete full-stack application described in the original specification.
|
|
87
|
+
|
|
88
|
+
Generate all required:
|
|
89
|
+
|
|
90
|
+
* Backend files
|
|
91
|
+
* Frontend files
|
|
92
|
+
* Models
|
|
93
|
+
* Controllers
|
|
94
|
+
* Routes
|
|
95
|
+
* Middleware
|
|
96
|
+
* Authentication
|
|
97
|
+
* Dashboard
|
|
98
|
+
* Reports
|
|
99
|
+
* Styling
|
|
100
|
+
* Configuration
|
|
101
|
+
* Documentation
|
|
102
|
+
|
|
103
|
+
Do not skip required components.
|
|
104
|
+
|
|
105
|
+
Do not leave placeholders where implementation is expected.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## PROJECT IMPROVEMENTS
|
|
110
|
+
|
|
111
|
+
While preserving the original specification, include the following improvements:
|
|
112
|
+
|
|
113
|
+
* createdAt timestamps
|
|
114
|
+
* updatedAt timestamps
|
|
115
|
+
* reusable validation helpers
|
|
116
|
+
* reusable utility modules
|
|
117
|
+
* centralized API error handling
|
|
118
|
+
* activity logging
|
|
119
|
+
* search functionality
|
|
120
|
+
* filtering functionality
|
|
121
|
+
* loading states
|
|
122
|
+
* error states
|
|
123
|
+
* role support for users
|
|
124
|
+
|
|
125
|
+
Invoice numbering must be generated automatically.
|
|
126
|
+
|
|
127
|
+
Format:
|
|
128
|
+
|
|
129
|
+
INV-YYYY-0001
|
|
130
|
+
|
|
131
|
+
Examples:
|
|
132
|
+
|
|
133
|
+
INV-2026-0001
|
|
134
|
+
|
|
135
|
+
INV-2026-0002
|
|
136
|
+
|
|
137
|
+
INV-2026-0003
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## SAFETY RULES
|
|
142
|
+
|
|
143
|
+
Workspace 1 (Main Project) is protected.
|
|
144
|
+
|
|
145
|
+
Never:
|
|
146
|
+
|
|
147
|
+
* Modify files in Workspace 1.
|
|
148
|
+
* Delete files in Workspace 1.
|
|
149
|
+
* Rename files in Workspace 1.
|
|
150
|
+
* Move files in Workspace 1.
|
|
151
|
+
* Install dependencies in Workspace 1.
|
|
152
|
+
* Generate files in Workspace 1.
|
|
153
|
+
* Overwrite user files.
|
|
154
|
+
* Alter the existing project structure.
|
|
155
|
+
|
|
156
|
+
Treat Workspace 1 as read-only.
|
|
157
|
+
|
|
158
|
+
Treat Workspace 10 (.cache) as the active development workspace.
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## FILE OPERATION VALIDATION
|
|
163
|
+
|
|
164
|
+
Before creating, editing, moving, renaming, or deleting any file:
|
|
165
|
+
|
|
166
|
+
Verify that the target path begins with:
|
|
167
|
+
|
|
168
|
+
.cache/
|
|
169
|
+
|
|
170
|
+
If the target path is outside:
|
|
171
|
+
|
|
172
|
+
.cache/
|
|
173
|
+
|
|
174
|
+
Cancel the operation and notify the user.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## COMPLETION REQUIREMENTS
|
|
179
|
+
|
|
180
|
+
When generation is complete:
|
|
181
|
+
|
|
182
|
+
1. Display the complete generated folder tree.
|
|
183
|
+
2. Display all generated backend files.
|
|
184
|
+
3. Display all generated frontend files.
|
|
185
|
+
4. Display all generated models.
|
|
186
|
+
5. Display all generated controllers.
|
|
187
|
+
6. Display all generated routes.
|
|
188
|
+
7. Generate PROJECT_SUMMARY.md.
|
|
189
|
+
8. Generate SETUP.md.
|
|
190
|
+
9. Show required environment variables.
|
|
191
|
+
10. Show startup commands.
|
|
192
|
+
11. Show the exact location of the generated project.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## FINAL BEHAVIOR
|
|
197
|
+
|
|
198
|
+
Work only inside:
|
|
199
|
+
|
|
200
|
+
.cache
|
|
201
|
+
|
|
202
|
+
Do not start servers automatically.
|
|
203
|
+
|
|
204
|
+
Do not run npm install automatically.
|
|
205
|
+
|
|
206
|
+
Do not modify the user's existing implementation.
|
|
207
|
+
|
|
208
|
+
Do not merge generated files into the main project.
|
|
209
|
+
|
|
210
|
+
Do not copy generated files into the main project automatically.
|
|
211
|
+
|
|
212
|
+
Wait for user approval before performing any action outside .cache.
|
|
213
|
+
|
|
214
|
+
All generated artifacts, documentation, logs, helper files, temporary files, and project resources must remain isolated inside .cache until the user explicitly decides otherwise.
|
|
@@ -2,7 +2,7 @@ const mongoose = require('mongoose');
|
|
|
2
2
|
|
|
3
3
|
const connectDB = async () => {
|
|
4
4
|
try {
|
|
5
|
-
await mongoose.connect(
|
|
5
|
+
await mongoose.connect(process.env.MONGO_URI);
|
|
6
6
|
console.log('MongoDB connected');
|
|
7
7
|
} catch (error) {
|
|
8
8
|
console.error('MongoDB connection error:', error);
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
//it is checking if the user is authenticated by checking the token in the header(the header is the part of the request that contains the token)
|
|
3
|
-
//if the user is not authenticated, it will return a 401 status code and a message that the user is not authorized
|
|
4
|
-
//if the user is authenticated, it will return the user object
|
|
5
|
-
//and the user object is the user that is authenticated
|
|
1
|
+
|
|
6
2
|
|
|
7
3
|
const jwt = require('jsonwebtoken');
|
|
8
4
|
const User = require('../models/User');
|
|
9
|
-
const JWT_SECRET =
|
|
5
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
10
6
|
|
|
11
7
|
exports.protect = async (req, res, next) => {
|
|
12
8
|
try {
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
+
require ('dotenv'). config();
|
|
1
2
|
const express = require('express');
|
|
2
3
|
const cors = require('cors');
|
|
3
4
|
|
|
4
5
|
const connectDB = require('./config/db');
|
|
5
6
|
|
|
6
7
|
const authRoutes = require('./routes/authRoutes');
|
|
7
|
-
|
|
8
|
-
const productRoutes = require('./routes/productRoutes');
|
|
9
8
|
const SupplierRoutes = require('./routes/SupplierRoutes');
|
|
10
9
|
const shipmentRoutes = require('./routes/shipmentRoutes');
|
|
11
10
|
const deliveryRoutes = require('./routes/deliveryRoutes');
|
|
12
11
|
const reportsRoutes = require('./routes/reportsRoutes');
|
|
13
|
-
const protectedRoutes = require('./routes/protectedRoutes');
|
|
14
12
|
|
|
15
13
|
const app = express();
|
|
16
14
|
|
|
@@ -18,16 +16,14 @@ app.use(cors());
|
|
|
18
16
|
app.use(express.json());
|
|
19
17
|
connectDB();
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
|
|
22
20
|
app.use('/api/supplier', SupplierRoutes);
|
|
23
21
|
app.use('/api/auth', authRoutes);
|
|
24
|
-
|
|
25
22
|
app.use('/api/shipment', shipmentRoutes);
|
|
26
23
|
app.use('/api/delivery', deliveryRoutes);
|
|
27
24
|
app.use('/api/reports', reportsRoutes);
|
|
28
|
-
app.use('/api/protected', protectedRoutes);
|
|
29
25
|
|
|
30
|
-
const PORT = 5001
|
|
26
|
+
const PORT = process.env.PORT || 5001
|
|
31
27
|
app.listen(PORT, () => {
|
|
32
28
|
console.log(`Server running on http://localhost:${PORT}`);
|
|
33
29
|
});
|
|
@@ -8,7 +8,6 @@ import Supplier from './pages/Supplier';
|
|
|
8
8
|
import Shipment from './pages/Shipment';
|
|
9
9
|
import Delivery from './pages/Delivery';
|
|
10
10
|
import Reports from './pages/Reports';
|
|
11
|
-
import ProtectedRoute from './components/ProtectedRoute';
|
|
12
11
|
|
|
13
12
|
function App() {
|
|
14
13
|
return (
|
|
@@ -17,7 +16,7 @@ function App() {
|
|
|
17
16
|
<Route path="/login" element={<Login />} />
|
|
18
17
|
<Route path="/register" element={<Register />} />
|
|
19
18
|
|
|
20
|
-
<Route path="/dashboard" element={<
|
|
19
|
+
<Route path="/dashboard" element={<DashboardLayout />}>
|
|
21
20
|
<Route index element={<DashboardHome />} />
|
|
22
21
|
<Route path="supplier" element={<Supplier />} />
|
|
23
22
|
<Route path="shipment" element={<Shipment />} />
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const connectDB = async () => {
|
|
4
|
+
try {
|
|
5
|
+
await mongoose.connect('mongodb://localhost:27017/SMS');
|
|
6
|
+
console.log('MongoDB connected');
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error('MongoDB connection error:', error);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = connectDB;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const bcrypt = require('bcrypt');
|
|
2
|
+
const jwt = require('jsonwebtoken');
|
|
3
|
+
const User = require('../models/User');
|
|
4
|
+
const JWT_SECRET = 'change_this_to_a_long_random_secret';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function createToken(userId) {
|
|
9
|
+
return jwt.sign({ userId },JWT_SECRET, { expiresIn: '7d' });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function formatUser(user) {
|
|
13
|
+
return {
|
|
14
|
+
id: user._id,
|
|
15
|
+
name: user.name,
|
|
16
|
+
email: user.email,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.register = async (req, res) => {
|
|
21
|
+
try {
|
|
22
|
+
const { name, email, password } = req.body;
|
|
23
|
+
|
|
24
|
+
if (!name || !email || !password) {
|
|
25
|
+
return res.status(400).json({ message: 'Name, email, and password are required' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (password.length < 6) {
|
|
29
|
+
return res.status(400).json({ message: 'Password must be at least 6 characters' });
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const existing = await User.findOne({ email: email.toLowerCase() });
|
|
33
|
+
if (existing) {
|
|
34
|
+
return res.status(409).json({ message: 'Email already registered' });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const hashedPassword = await bcrypt.hash(password, 10);
|
|
38
|
+
const user = await User.create({
|
|
39
|
+
name,
|
|
40
|
+
email: email.toLowerCase(),//to ensure the email is always lowercase
|
|
41
|
+
password: hashedPassword,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const token = createToken(user._id);
|
|
45
|
+
|
|
46
|
+
res.status(201).json({
|
|
47
|
+
token,
|
|
48
|
+
user: formatUser(user),
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
res.status(500).json({ message: err.message });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
exports.login = async (req, res) => {
|
|
56
|
+
try {
|
|
57
|
+
const { email, password } = req.body;
|
|
58
|
+
|
|
59
|
+
if (!email || !password) {
|
|
60
|
+
return res.status(400).json({ message: 'Email and password are required' });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const user = await User.findOne({ email: email.toLowerCase() });
|
|
64
|
+
if (!user) {
|
|
65
|
+
return res.status(401).json({ message: 'Invalid email or password' });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const match = await bcrypt.compare(password, user.password);
|
|
69
|
+
if (!match) {
|
|
70
|
+
return res.status(401).json({ message: 'Invalid email or password' });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const token = createToken(user._id);
|
|
74
|
+
|
|
75
|
+
res.json({
|
|
76
|
+
token,
|
|
77
|
+
user: formatUser(user),
|
|
78
|
+
});
|
|
79
|
+
} catch (err) {
|
|
80
|
+
res.status(500).json({ message: err.message });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
exports.getMe = async (req, res) => {
|
|
85
|
+
try {
|
|
86
|
+
res.json({ user: formatUser(req.user) });
|
|
87
|
+
} catch (err) {
|
|
88
|
+
res.status(500).json({ message: err.message });
|
|
89
|
+
}
|
|
90
|
+
};
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
const Product = require('../models/
|
|
2
|
-
|
|
1
|
+
const Product = require('../models/product');
|
|
3
2
|
|
|
4
3
|
exports.getproduct = async (req, res) => {
|
|
5
4
|
try {
|
|
6
|
-
const products = await Product.find()
|
|
7
|
-
if (!products) {
|
|
8
|
-
return res.status(404).json({ message: 'Products not found' });
|
|
9
|
-
}
|
|
5
|
+
const products = await Product.find();
|
|
10
6
|
res.json(products);
|
|
11
7
|
} catch (err) {
|
|
12
8
|
res.status(500).json({ message: err.message });
|
|
13
9
|
}
|
|
14
|
-
}
|
|
10
|
+
};
|
|
15
11
|
|
|
16
12
|
exports.getproductbyid = async (req, res) => {
|
|
17
13
|
try {
|
|
18
|
-
const productById = await Product.findById(req.params.id)
|
|
14
|
+
const productById = await Product.findById(req.params.id);
|
|
19
15
|
if (!productById) {
|
|
20
16
|
return res.status(404).json({ message: 'Product not found' });
|
|
21
17
|
}
|
|
@@ -27,48 +23,53 @@ exports.getproductbyid = async (req, res) => {
|
|
|
27
23
|
|
|
28
24
|
exports.addproduct = async (req, res) => {
|
|
29
25
|
try {
|
|
30
|
-
const {
|
|
26
|
+
const {
|
|
27
|
+
productCode,
|
|
28
|
+
productName,
|
|
29
|
+
category,
|
|
30
|
+
unitPrice,
|
|
31
|
+
quantityInStock,
|
|
32
|
+
supplierName,
|
|
33
|
+
dateReceived,
|
|
34
|
+
} = req.body;
|
|
35
|
+
|
|
31
36
|
const newproduct = await Product.create({
|
|
32
37
|
productCode,
|
|
33
38
|
productName,
|
|
34
39
|
category,
|
|
35
40
|
unitPrice,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
41
|
+
quantityInStock,
|
|
42
|
+
supplierName,
|
|
43
|
+
dateReceived,
|
|
39
44
|
});
|
|
40
45
|
|
|
41
46
|
res.status(201).json(newproduct);
|
|
42
47
|
} catch (err) {
|
|
43
48
|
res.status(500).json({ message: err.message });
|
|
44
49
|
}
|
|
45
|
-
}
|
|
50
|
+
};
|
|
46
51
|
|
|
47
52
|
exports.updateproduct = async (req, res) => {
|
|
48
53
|
try {
|
|
49
|
-
const updateproducts = await Product.findByIdAndUpdate(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
if (!updateproducts) return res.status(404).json({ msg: " product not found" })
|
|
54
|
+
const updateproducts = await Product.findByIdAndUpdate(req.params.id, req.body, {
|
|
55
|
+
new: true,
|
|
56
|
+
});
|
|
57
|
+
if (!updateproducts) return res.status(404).json({ msg: 'Product not found' });
|
|
55
58
|
|
|
56
|
-
res.json({ msg:
|
|
59
|
+
res.json({ msg: 'Product updated successfully', data: updateproducts });
|
|
57
60
|
} catch (err) {
|
|
58
61
|
res.status(500).json({ message: err.message });
|
|
59
62
|
}
|
|
60
|
-
}
|
|
63
|
+
};
|
|
61
64
|
|
|
62
65
|
exports.deleteproduct = async (req, res) => {
|
|
63
66
|
try {
|
|
64
|
-
const deleteproduct = await Product.findByIdAndDelete(
|
|
65
|
-
req.params.id
|
|
66
|
-
);
|
|
67
|
+
const deleteproduct = await Product.findByIdAndDelete(req.params.id);
|
|
67
68
|
if (!deleteproduct) {
|
|
68
|
-
return res.status(404).json({ message: '
|
|
69
|
+
return res.status(404).json({ message: 'Product not found' });
|
|
69
70
|
}
|
|
70
71
|
res.json({ message: 'Product deleted successfully' });
|
|
71
72
|
} catch (err) {
|
|
72
73
|
res.status(500).json({ message: err.message });
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
+
};
|