Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #5

Open
wants to merge 79 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
1978c32
Add notification in order
nivedit06 Sep 19, 2024
6897d08
Add notification requirement file and change in register api
nivedit06 Sep 19, 2024
05a0d4d
Add firebase configuration
nivedit06 Sep 19, 2024
950ce15
Correct the notification error
nivedit06 Sep 19, 2024
08463a3
Change port to 3129
nivedit06 Sep 20, 2024
7728879
Edit the notification functionality and remove device token constraint
nivedit06 Sep 23, 2024
2fbf274
Update highlight and update api as per website need, add discount fun…
nivedit06 Sep 24, 2024
5ea82c2
Add token verififcation and update it, integrated increase and decrea…
nivedit06 Sep 25, 2024
c7f2efb
Update address check and verifytoken in address route
nivedit06 Sep 26, 2024
7fc97e5
sds
nivedit06 Sep 26, 2024
82d1de5
verifyToken removed
nivedit06 Sep 26, 2024
a449ffd
change route
nivedit06 Sep 26, 2024
2a79698
edit route
nivedit06 Sep 26, 2024
503a933
Add jwt required header file
nivedit06 Sep 26, 2024
0914374
Add remove cart updations according to app, add notification api to g…
nivedit06 Sep 26, 2024
2a9a5db
update api for pagination
nivedit06 Sep 27, 2024
ef80c53
Update order summary with necessary fields
nivedit06 Oct 4, 2024
78581de
Update the order summary api with discount cost display
nivedit06 Oct 4, 2024
2f7a7af
Change cart api to change quantity and add getProductFromCart api to …
nivedit06 Oct 7, 2024
c73546c
fix some bugs of routes
nivedit06 Oct 7, 2024
7891e20
add order summary, where data will be shown
nivedit06 Oct 7, 2024
4ed86e8
Integrated payment method for testing purpose with currency type as U…
nivedit06 Oct 10, 2024
16ae09c
add payment model updates and add paymentId in order model and instal…
nivedit06 Oct 10, 2024
9e2e85b
add require models and files for payment to be carried properly
nivedit06 Oct 10, 2024
4d74932
add env again
nivedit06 Oct 10, 2024
f70a76c
Add buyNow api to purchase specific product
nivedit06 Oct 11, 2024
212d6eb
Add the changes of the routes
nivedit06 Oct 11, 2024
914315f
fix dockerfile
Oct 11, 2024
65f525e
check webhooks
Oct 11, 2024
19ff777
Add the stripe changed working in createOrder api and save the paymen…
nivedit06 Oct 14, 2024
7197d3f
commit
nivedit06 Oct 14, 2024
093ecc5
Add token processing for website side payment
nivedit06 Oct 15, 2024
cfef5ab
Add token method for stripe payment instead of paymentIntent
nivedit06 Oct 16, 2024
65c2065
Change status to orderStatus to identify the status of the order
nivedit06 Oct 16, 2024
5010494
Add get discount by category api to fetch discounted product accordin…
nivedit06 Oct 16, 2024
bc738bb
Integrated paypal payment method according to token generation
nivedit06 Oct 22, 2024
2016a33
Add contact us functionality
nivedit06 Oct 23, 2024
901f052
commit
nivedit06 Oct 23, 2024
511ffc7
commit
nivedit06 Oct 23, 2024
bf31915
add onbehalfof field
nivedit06 Oct 23, 2024
03c279c
Add PaymentIntent method of payment for appside
nivedit06 Oct 23, 2024
062d7a2
Rectify order summary
nivedit06 Oct 23, 2024
13aceb2
Rectify the payment issue of paypal by adding the payerId
nivedit06 Oct 24, 2024
b7b6a51
add chage
Oct 28, 2024
323d3f3
Add review functionality
nivedit06 Dec 10, 2024
4e902f7
Solve the merge confict of sumup payment
nivedit06 Dec 10, 2024
4d32910
Add google auth code, voucher updations in get voucher and get order …
nivedit06 Dec 23, 2024
0a0fafa
Add fixes to routes
nivedit06 Dec 23, 2024
7b5d21c
Add fixes in get order summary
nivedit06 Dec 23, 2024
f845644
Change the order summary api
nivedit06 Dec 23, 2024
f62d50c
Add changes regarding the order summary and vouhcer application
nivedit06 Dec 23, 2024
56da93d
Add the order summary api changes and applly voucher changes
nivedit06 Dec 23, 2024
3a6949a
Fix route
nivedit06 Dec 23, 2024
ae8d2af
Add fixes in the order summary api
nivedit06 Dec 23, 2024
3b3c9c4
Add fixes in the apply voucher and connect it with order summary and …
nivedit06 Dec 24, 2024
a88004b
Add fixes in routes
nivedit06 Dec 24, 2024
80daacc
added tax functionality
nivedit06 Dec 24, 2024
8d82efc
added get all voucher api
nivedit06 Dec 24, 2024
46cb070
fixed tax calculation
nivedit06 Dec 24, 2024
d43c905
remove tax calculation from api
nivedit06 Dec 24, 2024
9add3f7
remove tax calculation from order summary and apply voucher api
nivedit06 Dec 24, 2024
1aba3e6
Tried fixing the google auth now working is operated from frontend, i…
nivedit06 Jan 2, 2025
f4c77d8
Fix the invoice controller functionality
nivedit06 Jan 2, 2025
622ab2f
Fix the invoice number regeneration
nivedit06 Jan 2, 2025
4b8ee3c
Fix the invoice address details and created get order by id
nivedit06 Jan 3, 2025
f4e7c86
Add tracking id
nivedit06 Jan 3, 2025
ba6bcf2
Modify the get voucher according to the active status and expiry date…
nivedit06 Jan 3, 2025
af51774
creds
nivedit06 Jan 3, 2025
1adcbe2
creds
nivedit06 Jan 3, 2025
3b82ded
changed log in time to 1m
nivedit06 Jan 3, 2025
fa95838
creds
nivedit06 Jan 3, 2025
508ced2
Add reset of voucher details after order is created
nivedit06 Jan 3, 2025
bc31b5f
Fix paymnet
nivedit06 Jan 6, 2025
cfccfd4
Fix paymnet
nivedit06 Jan 6, 2025
e900c5b
Fix paymnet
nivedit06 Jan 6, 2025
7d62122
added kubernetes menifest file
Jan 6, 2025
9091bfc
Fix payment
nivedit06 Jan 6, 2025
ad4639c
Merge branch 'development' of https://github.com/nivedit06/Ecom into …
nivedit06 Jan 6, 2025
094e51a
Add changes regarding the invoice and fetching delivery charges
nivedit06 Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
13 changes: 10 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
NODE_ENV= "development"
PORT=5001
PORT=3129
JWT_SECRET= verysecretkey
FRONTEND='http://localhost:3001'
# LIVE_URL='http://localhost:4200'

[email protected]
EMAIL_PASS=nfbnxezwkpsiwyde

MERCHANT_EMAIL= [email protected]
MERCHANT_CODE=SUMUP00123


STRIPE_SECRET_KEY=sk_test_51PqTR903ec58RCFWb7qYStr1sxR9wKpUWfu4hq1MFhfMRVidxNBoO3aCYWAOJmkpN5lKTBE2RRMB2pSU574ame9F00Vr3gCarb

MERCHANT_EMAIL= [email protected]
MERCHANT_CODE=SUMUP00123
PAYPAL_MODE = sandbox

PAYPAL_CLIENT_ID= ARIN0VXEZukePCK2S-yeejyx-02RqIYg864DpeaxY0juKGp-yuXDXoVuHCiOiJshiwslRRENxWHJBp7V

PAYPAL_CLIENT_SECRET=EI6lDSRoWsGU7PSZzHdulPzGDKyr2bs6jbkZTxmkVk17XWHe5LXvSm_Fhu8n_MgcPlxj7HhJI5lJyn__
17 changes: 17 additions & 0 deletions .env.save
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
NODE_ENV= "development"
PORT=3129
JWT_SECRET= verysecretkey
FRONTEND='http://localhost:3001'
# LIVE_URL='http://localhost:4200:[email protected]
EMAIL_PASS=nfbnxezwkpsiwyde

MERCHANT_EMAIL= mailto:[email protected]
MERCHANT_CODE=SUMUP00123

STRIPE_SECRET_KEY=sk_test_51PqTR903ec58RCFWb7qYStr1sxR9wKpUWfu4hq1MFhfMRVidxNBoO3aCYWAOJmkpN5lKTBE2RRMB2pSU574ame9F00Vr3gCarb

PAYPAL_MODE = sandbox

PAYPAL_CLIENT_ID= AURFbdAH-s05k9iOhtSCc2KFlCh5UKQGC0h6ljkvk0BoxDaI6zlCYJrANmJHxSszowO_20GZYLh2M_R2

PAYPAL_CLIENT_SECRET=EOBdJuxpwH2877yNPlfIn8rwXK9d21teqC9e_zOsTaAjHb8dGrgJdH9rZqV_z1mK8hvSE9R49ixN3uaw
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Use an official Node.js runtime as a parent image
FROM node:20-alpine

# Set the working directory in the container
Expand All @@ -14,7 +13,7 @@ RUN npm install --production
COPY . .

# Expose the port the application will run on
EXPOSE 3003
EXPOSE 3129

# Define the command to run the application
CMD ["node", "app.js"]
17 changes: 14 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const voucherRoute = require('./routes/voucherRoute');
const invoiceRoute = require('./routes/invoiceRoute');
const notificationRoute = require('./routes/notificationRoute');
const paymentRoute = require('./routes/paymentRoute');

const contactRoute = require('./routes/contactRoute');
const sumupRoutes=require('./controllers/sumuppayment');
const reviewRoute = require('./routes/reviewRoute');


// Ensure the 'exports' directory exists
Expand All @@ -33,9 +35,8 @@ if (!fs.existsSync(exportDir)) {
}



// Environment variables
const PORT = process.env.PORT || 3000;
const PORT = process.env.PORT || 3129;
const MONGO_URL = process.env.MONGO_URL;
// const FRONTEND = process.env.FRONTEND;

Expand Down Expand Up @@ -77,8 +78,18 @@ app.use('/api/voucher', voucherRoute); //added voucher routes
app.use('/api/invoices', invoiceRoute);
app.use('/api/notification', notificationRoute);
app.use('/api/payment', paymentRoute);
app.use('/api/contact', contactRoute);
app.use('/api/sumup', sumupRoutes);
app.use('/api/review', reviewRoute);


// Serve static files (like PDF invoices)
app.use('/invoice', express.static(path.join(__dirname, 'public', 'invoices')));


app.get('/', (req, res) => {
res.send("Congratulations! It's working");
});



Expand Down
2 changes: 2 additions & 0 deletions atul.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
just want to check webhooks
this is the dummy file added by atul
9 changes: 9 additions & 0 deletions config/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const admin = require("firebase-admin");

const serviceAccount = require("../firebase.json");

admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
});

module.exports = admin;
54 changes: 48 additions & 6 deletions controllers/addressController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Address = require('../models/addressModel');
const User = require('../models/userModel');
const createError = require('../middleware/error');
const jwt = require('jsonwebtoken');

const addAddress = async (req, res, next) => {
try {
Expand Down Expand Up @@ -37,10 +38,47 @@ const addAddress = async (req, res, next) => {
};

// get address by user id
// const getAddressByUserId = async (req, res, next) => {
// try {
// const { userId } = req.params;

// const addresses = await Address.find({ user: userId });

// if (!addresses.length) {
// return next(createError(404, "No addresses found for this user!"));
// }

// return res.status(200).json({
// success: true,
// status: 200,
// message: "Address retrieved successfully!",
// data: addresses
// })

// }
// catch (error) {
// return next(createError(500, "Something went wrong!"));
// }
// };

const getAddressByUserId = async (req, res, next) => {
try {
const { userId } = req.params;
let userId;

const token = req.headers['authorization']?.split(' ')[1];

if (token) {
const jwtSecret = process.env.JWT_SECRET || 'your_jwt_secret';
const decoded = jwt.verify(token, jwtSecret);
userId = decoded.id; // Get the user ID from the token
} else if (req.body.userId || req.params.userId) {
userId = req.body.userId || req.params.userId;
} else {
// If neither token nor userId is available, return an error
return next(createError(401, "Access token or userId is missing!"));
}

// Fetch addresses by user ID
const addresses = await Address.find({ user: userId });

if (!addresses.length) {
Expand All @@ -50,16 +88,20 @@ const getAddressByUserId = async (req, res, next) => {
return res.status(200).json({
success: true,
status: 200,
message: "Address retrieved successfully!",
message: "Addresses retrieved successfully!",
data: addresses
})

}
catch (error) {
});
} catch (error) {
// Handle unexpected errors
if (error.name === 'JsonWebTokenError' || error.name === 'TokenExpiredError') {
return next(createError(401, "Invalid or expired token!"));
}
console.error("error", error)
return next(createError(500, "Something went wrong!"));
}
};


// Update address
const updateAddress = async (req, res, next) => {
try {
Expand Down
46 changes: 40 additions & 6 deletions controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ const nodemailer = require('nodemailer')
const bcrypt = require('bcrypt');
const validator = require('validator'); // Added validator import
const { createNotification } = require('../services/notificationService')
const admin = require("../controllers/notification");

//to login
const login = async (req, res, next) => {
try {
const { emailOrUsername, password, deviceToken } = req.body;

// Validate input
if (!emailOrUsername || !password || !deviceToken) {
if (!emailOrUsername || !password) {
return next(createError(400, "Email/Username, password or device token are required"));
}

Expand Down Expand Up @@ -174,7 +175,7 @@ const sendEmail = async (req, res, next) => {
// userType = "guide";
// }

if (!user && !guide) {
if (!user) {
return next(createError(401, "Invalid Email"));
}

Expand Down Expand Up @@ -233,7 +234,7 @@ const verifyOTP = async (req, res, next) => {
// userType = "guide";
// }

if (!user && !guide) {
if (!user) {
return res.status(400).json({ message: "Invalid or expired OTP" });
}

Expand All @@ -248,8 +249,8 @@ const verifyOTP = async (req, res, next) => {
// await guide.save();
// }

const email = user ? user.email : guide.email;
const token = jwt.sign({ email }, process.env.JWT_SECRET, { expiresIn: '15m' });
const email = user.email;
const token = jwt.sign({ email }, process.env.JWT_SECRET, { expiresIn: '11h' });

return res.status(200).json({
success: true,
Expand Down Expand Up @@ -385,6 +386,38 @@ const verifyOtpForEmail = async (req, res, next) => {
}
};

const googleAuth = async (req, res) => {
const { token } = req.body;

try {
// Verify Firebase token
const decodedToken = await admin.auth().verifyIdToken(token);
const { uid, email, displayName, photoURL } = decodedToken;

// Optional: Store user in database
const user = await User.findOneAndUpdate(
{ uid },
{ password: uid,
displayName,
userName: email,
profileImage: photoURL
},
{ upsert: true, new: true }
);

// Respond with user details
res.status(200).json({
success: true,
status: 200,
message: "Authentication successful",
user: user || { uid, email, userName, photoURL },
});
} catch (error) {
console.error("Error verifying token:", error);
res.status(401).json({ error: "Invalid token" });
}
};


// in logout reset the token
// Logout method
Expand All @@ -408,5 +441,6 @@ module.exports = {
verifyOTP,
logout,
sendVerificationEmail,
verifyOtpForEmail
verifyOtpForEmail,
googleAuth
}
Loading