Compare commits
2 Commits
e37f230deb
...
8f6e52813d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
8f6e52813d | ||
![]() |
af107e6845 |
@ -1,7 +1,12 @@
|
|||||||
import admin from "firebase-admin";
|
import admin from "firebase-admin";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
// import serviceAccount from "../googlefirebasePushnotification.json" with { type: "json" };
|
// import serviceAccount from "../googlefirebasePushnotification.json" with { type: "json" };
|
||||||
import serviceAccount from "../googlefirebasePushnotification.json" assert { type: "json" };
|
// import serviceAccount from "../googlefirebasePushnotification.json" assert { type: "json" };
|
||||||
export const sendPushNotification = async (userToken,title, message) => {
|
const serviceAccount = JSON.parse(
|
||||||
|
readFileSync("./googlefirebasePushnotification.json", "utf8")
|
||||||
|
);
|
||||||
|
export const sendPushNotification = async (userToken, title, message) => {
|
||||||
// const admin = require("firebase-admin");
|
// const admin = require("firebase-admin");
|
||||||
// const serviceAccount = require("./path/to/your-firebase-adminsdk.json");
|
// const serviceAccount = require("./path/to/your-firebase-adminsdk.json");
|
||||||
|
|
||||||
|
22
app.js
22
app.js
@ -7,12 +7,16 @@ import bodyParser from "body-parser";
|
|||||||
import fileUpload from "express-fileupload"; // important pkg for file upload
|
import fileUpload from "express-fileupload"; // important pkg for file upload
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
import cookieParser from "cookie-parser";
|
import cookieParser from "cookie-parser";
|
||||||
|
import { readFileSync } from "fs";
|
||||||
|
|
||||||
// firebase admin push notification
|
// firebase admin push notification
|
||||||
import admin from "firebase-admin";
|
import admin from "firebase-admin";
|
||||||
// import serviceAccount from "./googlefirebasePushnotification.json" with { type: "json" };
|
// import serviceAccount from "./googlefirebasePushnotification.json" with { type: "json" };
|
||||||
import serviceAccount from "./googlefirebasePushnotification.json" assert { type: "json" };
|
// import serviceAccount from "./googlefirebasePushnotification.json" assert { type: "json" };
|
||||||
// Design Router
|
// Design Router
|
||||||
|
const serviceAccount = JSON.parse(
|
||||||
|
readFileSync("./googlefirebasePushnotification.json", "utf8")
|
||||||
|
);
|
||||||
import designRoute from "./resources/Design/designRouter.js";
|
import designRoute from "./resources/Design/designRouter.js";
|
||||||
app.use(express.json({ limit: "50mb" }));
|
app.use(express.json({ limit: "50mb" }));
|
||||||
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
||||||
@ -141,7 +145,7 @@ import orderRoute from "./resources/Orders/orderRoute.js";
|
|||||||
import DepartureRouter from "./resources/Departure/DepartureRoute.js";
|
import DepartureRouter from "./resources/Departure/DepartureRoute.js";
|
||||||
import InformationRoute from "./resources/Informations/InformationRoute.js";
|
import InformationRoute from "./resources/Informations/InformationRoute.js";
|
||||||
import Testimonial from "./resources/Testimonials/TestimonialRoute.js";
|
import Testimonial from "./resources/Testimonials/TestimonialRoute.js";
|
||||||
import Transporter from "./resources/setting/Transporter/transporterRoutes.js";
|
import Transporter from "./resources/setting/Transporter/transporterRoutes.js";
|
||||||
import StateRouter from "./resources/setting/state/state_routes.js";
|
import StateRouter from "./resources/setting/state/state_routes.js";
|
||||||
//
|
//
|
||||||
import LanguageRoute from "./resources/setting/Language/language_routes.js";
|
import LanguageRoute from "./resources/setting/Language/language_routes.js";
|
||||||
@ -282,9 +286,9 @@ app.use("/api/v1", attendance);
|
|||||||
app.use("/api/v1", leave);
|
app.use("/api/v1", leave);
|
||||||
|
|
||||||
// notification route
|
// notification route
|
||||||
app.use("/api",notification)
|
app.use("/api", notification)
|
||||||
// order routes
|
// order routes
|
||||||
app.use("/api",PdOrderRoute)
|
app.use("/api", PdOrderRoute)
|
||||||
//Inventory
|
//Inventory
|
||||||
app.use("/api/inventory", InventoryRoute);
|
app.use("/api/inventory", InventoryRoute);
|
||||||
// Sales
|
// Sales
|
||||||
@ -292,17 +296,17 @@ app.use("/api/sales", SalesRoute);
|
|||||||
//Task
|
//Task
|
||||||
app.use("/api/task", TaskRoute);
|
app.use("/api/task", TaskRoute);
|
||||||
// RD Rotuts auth
|
// RD Rotuts auth
|
||||||
app.use("/api",RDRoute)
|
app.use("/api", RDRoute)
|
||||||
// RD Order routes
|
// RD Order routes
|
||||||
app.use("/api",RDOrderRoute)
|
app.use("/api", RDOrderRoute)
|
||||||
// visit RD and PD
|
// visit RD and PD
|
||||||
app.use("/api", VisitRDandPDRoute);
|
app.use("/api", VisitRDandPDRoute);
|
||||||
|
|
||||||
// Announcemnt
|
// Announcemnt
|
||||||
|
|
||||||
app.use('/api',AnnouncementRoute)
|
app.use('/api', AnnouncementRoute)
|
||||||
|
|
||||||
app.use('/api/transporter',Transporter)
|
app.use('/api/transporter', Transporter)
|
||||||
|
|
||||||
|
|
||||||
//config specialty
|
//config specialty
|
||||||
@ -319,7 +323,7 @@ app.use("/api", Stock);
|
|||||||
// Email CMS
|
// Email CMS
|
||||||
// app.use("/api", RegisterEmail);
|
// app.use("/api", RegisterEmail);
|
||||||
//Reports
|
//Reports
|
||||||
app.use("/api/report",Report);
|
app.use("/api/report", Report);
|
||||||
//MobileApp
|
//MobileApp
|
||||||
app.use("/api/mobileapp", MobileAppRoute);
|
app.use("/api/mobileapp", MobileAppRoute);
|
||||||
export default app;
|
export default app;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "atp",
|
"description": "atp",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"dev": "nodemon server.js",
|
"dev": "nodemon server.js",
|
||||||
"clean": "rm -rf dist",
|
"clean": "rm -rf dist",
|
||||||
|
@ -620,10 +620,10 @@ export const forgotPassword = async (req, res, next) => {
|
|||||||
return res.status(404).json({ message: "User not found" });
|
return res.status(404).json({ message: "User not found" });
|
||||||
}
|
}
|
||||||
// Get ResetPassword Token
|
// Get ResetPassword Token
|
||||||
const resetToken = user.getResetPasswordToken(); //call function
|
// const resetToken = user.getResetPasswordToken(); //call function
|
||||||
|
|
||||||
//save database reset token
|
//save database reset token
|
||||||
await user.save({ validateBeforeSave: false });
|
// await user.save({ validateBeforeSave: false });
|
||||||
|
|
||||||
const passwords = password.randomPassword({
|
const passwords = password.randomPassword({
|
||||||
length: 12,
|
length: 12,
|
||||||
@ -653,10 +653,10 @@ export const forgotPassword = async (req, res, next) => {
|
|||||||
message: `Email sent to ${user.email} successfully`,
|
message: `Email sent to ${user.email} successfully`,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
user.resetPasswordToken = undefined;
|
// user.resetPasswordToken = undefined;
|
||||||
user.resetPasswordExpire = undefined;
|
// user.resetPasswordExpire = undefined;
|
||||||
|
|
||||||
await user.save({ validateBeforeSave: false });
|
// await user.save({ validateBeforeSave: false });
|
||||||
|
|
||||||
return res
|
return res
|
||||||
.status(500)
|
.status(500)
|
||||||
@ -732,10 +732,10 @@ export const ResetPasswordAdmin = async (req, res) => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error resetting password:", error);
|
console.error("Error resetting password:", error);
|
||||||
|
|
||||||
|
console.error(error);
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
success: false,
|
message: error?.message || "Something went wrong!",
|
||||||
message:
|
error: error?.message || "",
|
||||||
error.message || "Something went wrong while resetting the password.",
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user