create-myexam-app 1.0.27 → 1.0.29
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/package.json +1 -1
- package/projects/SMS/backend-project/.env +3 -0
- package/projects/SMS/backend-project/config/db.js +1 -1
- package/projects/SMS/backend-project/controllers/authController.js +1 -1
- package/projects/SMS/backend-project/middleware/auth.js +2 -6
- package/projects/SMS/backend-project/server.js +2 -1
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
|
|
|
@@ -25,7 +26,7 @@ app.use('/api/sales', salesRoutes);
|
|
|
25
26
|
app.use('/api/warehouse', warehouseRoutes);
|
|
26
27
|
app.use('/api/reports', reportRoutes);
|
|
27
28
|
|
|
28
|
-
const PORT = 5001
|
|
29
|
+
const PORT = process.env.PORT || 5001
|
|
29
30
|
app.listen(PORT, () => {
|
|
30
31
|
console.log(`Server running on http://localhost:${PORT}`);
|
|
31
32
|
});
|