Skip to content
Extraits de code Groupes Projets
Valider a94018d6 rédigé par BLemine's avatar BLemine
Parcourir les fichiers

added request-authorization

parent 8cfbafaa
Branches
1 requête de fusion!319added request authorization
Pipeline #9005 réussi avec l'étape
in 6 minutes et 2 secondes
......@@ -40,3 +40,6 @@ NEXT_PUBLIC_DEFAULT_IMAGE_URL=https://mydressin-rec.s3.eu-west-3.amazonaws.com/I
#GATEWAY API URL
NEXT_PUBLIC_MYDRESSIN_GATEWAY_API_URL=https://api.mydressin-server.com
NEXT_ENCRYPTION_KEY=market1ngconf0rT
NEXT_ENCRYPTION_IV=mark5t1ngconf0rT
\ No newline at end of file
Ce diff est replié.
......@@ -33,10 +33,11 @@
"apexcharts": "^3.46.0",
"autosuggest-highlight": "^3.3.4",
"axios": "^1.6.7",
"crypto-js": "^4.2.0",
"date-fns": "^2.29.3",
"dayjs": "^1.11.13",
"dayjs-plugin-utc": "^0.1.2",
"firebase": "^10.12.5",
"firebase": "^10.14.1",
"formik": "^2.4.6",
"framer-motion": "^11.0.6",
"highlight.js": "^11.9.0",
......@@ -90,6 +91,7 @@
},
"devDependencies": {
"@types/autosuggest-highlight": "^3.2.3",
"@types/crypto-js": "^4.2.2",
"@types/json2csv": "^5.0.7",
"@types/lodash.debounce": "^4.0.9",
"@types/node": "20.11.30",
......
......@@ -43,3 +43,7 @@ export const MAPBOX_API = process.env.NEXT_PUBLIC_MAPBOX_API;
// ROOT PATH AFTER LOGIN SUCCESSFUL
export const PATH_AFTER_LOGIN = paths.dashboard.root; // as '/dashboard'
export const PATH_AFTER_LOGIN_DRIVER = paths.dashboard.driver.root; // as '/dashboard/driver'
export const ENCRYPTION_KEY = process.env.NEXT_ENCRYPTION_KEY ?? 'your16bytekey123';
export const ENCRYPTION_IV = process.env.NEXT_ENCRYPTION_IV ?? 'your16byteiv5678';
\ No newline at end of file
import { GATEWAY_API_URL } from "@/config-global";
import { getRequestAuthorization } from "@/utils/encryption";
import axios, { AxiosRequestConfig, CancelTokenSource } from "axios";
import { update } from "lodash";
export const axiosInstance = axios.create({ baseURL: GATEWAY_API_URL });
export const axiosInstance = axios.create({
baseURL: GATEWAY_API_URL,
headers: {
requestAuthorization: getRequestAuthorization()
}
});
axiosInstance.interceptors.response.use(
(res) => res,
......@@ -48,11 +54,11 @@ export const endpoints = {
blockUser: (senderName: string, liveId: string) =>
`/api/stream/chat/block-user?streamId=${liveId}&senderName=${senderName}`,
},
notification:{
notification: {
startLiveStreamNotification: () =>
`/api/stream/notify/startLiveStream`,
`/api/stream/notify/startLiveStream`,
},
referralSettings: {
updateOrCreate: "/api/addons/referral-settings/updateOrCreate",
get: "/api/addons/referral-settings",
......@@ -74,7 +80,7 @@ export const endpoints = {
search: (sku: string) => `/api/stream/products/search?sku=${sku}`,
allProductsByIDs: "/api/stock/products/simple-product/retrieve-ids",
allVariationsByIDs: "/api/stock/variations/variation/retrieve-ids",
variation : (id: string) => `/api/stock/variations/${id}`,
variation: (id: string) => `/api/stock/variations/${id}`,
},
live: {
all: (page: number, size: number, sort: string, sortBy: string, status: string, search: string) => `/api/stream/live/all?search=${search}&page=${page}&size=${size}&sortDir=${sort}&sortBy=${sortBy}&status=${status}`,
......@@ -216,9 +222,9 @@ export const endpoints = {
order: {
getAll: "/api/orders/all-orders",
getById: (orderId: string) => `/api/orders/${orderId}`,
updateOrderStatus:`/api/orders/update-status`,
updateOrderStatus: `/api/orders/update-status`,
deleteOne: (orderId: string) => `/api/orders/${orderId}`,
deleteList: `/api/orders/delete-orders`,
deleteList: `/api/orders/delete-orders`,
refundOrder: {
getAllRefundOrders: `/api/orders/refund-order`,
createRefundOrder: `/api/orders/refund-order`,
......@@ -233,8 +239,8 @@ export const endpoints = {
getUserById: (id: number) => `api/user/${id}`,
getByEmail: (email: string) => `api/user/getByEmail/${email}`,
changingLogingActivity: "api/user/changeLoginActivity",
updateUser:`api/user/updateUser`,
updateClient:`api/user/updateClient`,
updateUser: `api/user/updateUser`,
updateClient: `api/user/updateClient`,
changeUserStatus: "api/user/changeUserStatus",
updateUserPassword: "api/user/updatePassword",
getAllRoles: "api/user/roles/",
......@@ -248,11 +254,11 @@ export const endpoints = {
list: "/api/stock/products/list",
details: (productId: string) => `/api/stock/products/id/${productId}`,
SaleSessionResearch: () => "/api/stock/products/ProductWithvariations",
variations : (productId: string) => `/api/stock/variations/product/${productId}`,
variations: (productId: string) => `/api/stock/variations/product/${productId}`,
},
categories: {
getAll: () => "/api/stock/categories",
importCategory:() => "/api/stock/categories/import",
importCategory: () => "/api/stock/categories/import",
getById: (categoryId: string) => `/api/stock/categories/${categoryId}`,
add: () => "/api/stock/categories/add-categorie",
edit: (categoryId: string) => `/api/stock/categories/edit/${categoryId}`,
......@@ -332,17 +338,17 @@ export const endpoints = {
paypalConfig: {
get: "/api/payment/config/paypal",
edit: "/api/payment/config/paypal",
getConnexionParams : "api/paypal/config",
updateConnexionParams : "api/paypal/configure"
getConnexionParams: "api/paypal/config",
updateConnexionParams: "api/paypal/configure"
},
payPlug: {
getConfig : "api/payment/config/payplug",
updateConfig : "api/payment/config/payplug",
fetchPaymentConfig : "api/payment/payplug/fetch-payplug-config",
savePaymentConfig : "api/payment/payplug/save-payplug-config",
getConfig: "api/payment/config/payplug",
updateConfig: "api/payment/config/payplug",
fetchPaymentConfig: "api/payment/payplug/fetch-payplug-config",
savePaymentConfig: "api/payment/payplug/save-payplug-config",
getPayment: (paymentId: string) => `api/payment/payplug/payments/${paymentId}`,
createRefund : (paymentId: string) => `api/payment/payplug/payments/${paymentId}/refunds`,
getRefund : (paymentId: string, refundId: string) => `api/payment/payplug/payments/${paymentId}/refunds/${refundId}`,
createRefund: (paymentId: string) => `api/payment/payplug/payments/${paymentId}/refunds`,
getRefund: (paymentId: string, refundId: string) => `api/payment/payplug/payments/${paymentId}/refunds/${refundId}`,
},
},
supplierOrder: {
......@@ -365,85 +371,85 @@ export const endpoints = {
downloadZebraFile: (id: string) => `/api/stock/supplier-order/download-zebra-file/${id}`,
declareDiscrepancy: "/api/stock/supplier-order/declare-discrepancy",
},
salleSession:{
getClients:`/api/user/clients`,
updateClient:(id:string) =>`/api/user/clients/${id}`,
salleSession: {
getClients: `/api/user/clients`,
updateClient: (id: string) => `/api/user/clients/${id}`,
banClient: (clientId: string) => `/api/user/clients/ban/${clientId}`,
unbanClient:(clientId: string) => `/api/user/clients/unban/${clientId}`,
getUnregistredClients:`/api/user/unregistered-client/`,
addUnregistredClient:`/api/user/unregistered-client/add`,
unbanClient: (clientId: string) => `/api/user/clients/unban/${clientId}`,
getUnregistredClients: `/api/user/unregistered-client/`,
addUnregistredClient: `/api/user/unregistered-client/add`,
associateAndDelete: "/api/user/unregistered-client/associate-unregistered-client",
addSaleSession: `/api/cart/add-saleSession`,
getSessions:`/api/cart/saleSessions`,
addProductToCart:`/api/cart/addProductToCartFromLive`,
addProductToUnregisteredCart:`/api/cart/addProductToUnregisteredCartFromLive`,
getSessions: `/api/cart/saleSessions`,
addProductToCart: `/api/cart/addProductToCartFromLive`,
addProductToUnregisteredCart: `/api/cart/addProductToUnregisteredCartFromLive`,
getOrdersBySessionId: (sessionId: string) => `/api/cart/ordersSession/get-orders/${sessionId}`,
updateOrderQuantity: (orderId: string) => `/api/cart/ordersSession/update-quantity/${orderId}`,
deleteOrder: (orderId: string) => `/api/cart/ordersSession/delete-order/${orderId}`,
getSaleSessionById: (saleSessionId:string) => `/api/cart/SaleSession/${saleSessionId}`,
modifieExpirationDate : (saleSessionId:string) => `api/cart/${saleSessionId}/expiration-date`,
deleteUnregisteredClientById:`/api/user/unregistered-client/deleteUnregisteredClient`,
updateDetails : (saleSessionId:string) => `api/cart/${saleSessionId}/details`,
getSaleSessionById: (saleSessionId: string) => `/api/cart/SaleSession/${saleSessionId}`,
modifieExpirationDate: (saleSessionId: string) => `api/cart/${saleSessionId}/expiration-date`,
deleteUnregisteredClientById: `/api/user/unregistered-client/deleteUnregisteredClient`,
updateDetails: (saleSessionId: string) => `api/cart/${saleSessionId}/details`,
deleteSaleSessionById: (id: number) => `/api/cart/deleteSession/${id}`,
},
supplier: {
getAllSupplier: "/api/user/supplier",
getSupplierDetails:(id:string) => `/api/user/supplier/${id}`,
getSupplierDetails: (id: string) => `/api/user/supplier/${id}`,
addSupplier: "/api/user/supplier/add",
},
driver : {
getAllDrivers: "api/user/driver",
getDriverById: (id: string) => `api/user/driver/${id}`,
driver: {
getAllDrivers: "api/user/driver",
getDriverById: (id: string) => `api/user/driver/${id}`,
},
saleOrder:{
getAllSaleOrders : "/api/stock/sale-orders",
saleOrder: {
getAllSaleOrders: "/api/stock/sale-orders",
getSaleOrderById: (id: string) => `/api/stock/sale-orders/${id}`,
generate : (id: string) => `/api/stock/sale-orders/generate/${id}`,
generate: (id: string) => `/api/stock/sale-orders/generate/${id}`,
confirm: "/api/stock/sale-orders/confirm",
delete : (id: string) => `/api/stock/sale-orders/${id}`,
delete: (id: string) => `/api/stock/sale-orders/${id}`,
bulkDelete: "/api/stock/sale-orders/bulk-delete",
deleteItem : (id: string) => `/api/stock/sale-orders/item/${id}`,
deleteItem: (id: string) => `/api/stock/sale-orders/item/${id}`,
},
cart:{
getCart: (clientId: string) =>`/api/cart/find/${clientId}`,
cart: {
getCart: (clientId: string) => `/api/cart/find/${clientId}`,
deleteItem: "/api/cart/delete-itemBO",
saveOrUpdate : "api/cart/cart-count-config",
saveOrUpdate: "api/cart/cart-count-config",
},
Reviews:{
Config : {
getConfig : () => `/api/addons/configurations/1`,
editConfig : () => `/api/addons/configurations/1`
Reviews: {
Config: {
getConfig: () => `/api/addons/configurations/1`,
editConfig: () => `/api/addons/configurations/1`
}
},
Addons:{
GiftCart :{
add : "/api/addons/giftcart",
getAll : "/api/addons/giftcart",
Addons: {
GiftCart: {
add: "/api/addons/giftcart",
getAll: "/api/addons/giftcart",
delete: (id: number) => `/api/addons/giftcart/delete/${id}`,
update: (id: number) => `/api/addons/giftcart/edit/${id}`,
duplicate: (id: number) => `/api/addons/giftcart/${id}/duplicate`,
getById : (id: string) => `/api/addons/giftcart/${id}`,
sendEmail: (id: number) => `/api/addons/giftcart/${id}/send-email`,
getById: (id: string) => `/api/addons/giftcart/${id}`,
sendEmail: (id: number) => `/api/addons/giftcart/${id}/send-email`,
},
PromoCode: {
getAll: "/api/addons/promoCode",
getById : (id: string) => `/api/addons/promoCode/${id}`,
getById: (id: string) => `/api/addons/promoCode/${id}`,
checkPromoCodeExists: (code: string) => `/api/addons/promoCode/check-promoCode-exists/${code}`,
add: "/api/addons/promoCode/add-promoCode",
update: (id: string) => `/api/addons/promoCode/update-promoCode/${id}`,
delete: (id: string) => `/api/addons/promoCode/delete-promoCode/${id}`,
deleteByIds: "/api/addons/promoCode/delete-promoCodes-by-ids",
getProducts: (page: number, size: number, keyword: string) => `/api/stock/products/products_promo_code?page=${page}&size=${size}&keyword=${keyword}`,
getProductsPublishedWebsite: (page: number, size: number, keyword: string) =>`/api/stock/products/products_promo_code?page=${page}&size=${size}&keyword=${keyword}&publishedWeb=true`,
getProductsPublishedWebsite: (page: number, size: number, keyword: string) => `/api/stock/products/products_promo_code?page=${page}&size=${size}&keyword=${keyword}&publishedWeb=true`,
},
Vouchers : {
add : "/api/addons/vouchers",
getAll : "/api/addons/vouchers",
Vouchers: {
add: "/api/addons/vouchers",
getAll: "/api/addons/vouchers",
delete: (id: number) => `/api/addons/vouchers/delete/${id}`,
update: (id: number) => `/api/addons/vouchers/edit/${id}`,
duplicate: (id: number) => `/api/addons/vouchers/${id}/duplicate`,
getById : (id: string) => `/api/addons/vouchers/${id}`,
sendEmail: (id: number) => `/api/addons/vouchers/${id}/send-email`,
getById: (id: string) => `/api/addons/vouchers/${id}`,
sendEmail: (id: number) => `/api/addons/vouchers/${id}/send-email`,
}
}
......
import { ENCRYPTION_IV, ENCRYPTION_KEY } from '@/config-global';
import CryptoJS from 'crypto-js';
const key = CryptoJS.enc.Utf8.parse(ENCRYPTION_KEY);
const iv = CryptoJS.enc.Utf8.parse(ENCRYPTION_IV);
const encryptData = (data: string) => {
return CryptoJS.AES.encrypt(data, key, {
iv: iv,
}).toString();
}
export const getRequestAuthorization = () => {
const authorization = {
serviceName: "mydressin-front",
authorization: new Date().getTime()
};
return encryptData(JSON.stringify(authorization));
}
\ No newline at end of file
0% ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter