📁 File Manager Pro
v10.0.3 | PHP: 8.2.31
Server: LiteSpeed
2026-06-29 10:38:20
📂
/ (Root)
/
home
/
orkouolp
/
node_js
/
orkofarms.com
/
api
📍 /home/orkouolp/node_js/orkofarms.com/api
🔄 Refresh
✏️
Editing: getShopData.js
Writable
const firebase = require('../firebase'); const SHOP_DATA = [ // { // id: 100, // title: 'Farm Fresh Milk', //'Cumulus', // description: 'Pure country cow milk', // //'Light as air. The Cumulus is encased in cloud-like waterproof nylon and has a spacious main interior. Collapse it for easy travel and snap it shut with magnetic closures.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Farm_Fresh_Milk.jpeg', // price: 110, unit: 'Litre', minQty: 5, active: true, // }, // { // id: 110, // title: 'Farm Fresh Deshi Cow Milk', //'Organic Beef', // description: 'Our cows are fed with natural and hygenic food.', // //'The Studio Bag is identical to its predecessor plus a few more inches to love. Transition it from satchel to backpack to crossbody simply by changing straps. Carry it wherever you go - it will be ready to adapt to your needs and keep up with your lifestyle.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Farm_Fresh_Deshi_Cow_Milk.jpeg', // price: 125, unit: 'Litre', minQty: 5, active: true, // }, // { // id: 120, // title: 'Home Made Yogurt', //'Cumulus', // description: 'Pure cow milk youghurt', // //'Light as air. The Cumulus is encased in cloud-like waterproof nylon and has a spacious main interior. Collapse it for easy travel and snap it shut with magnetic closures.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/HomemadeYoughurt.jpeg', // price: 250, unit: 'Kg', minQty: 1, active: true, // }, // { // id: 130, // title: 'Home Made Butter', //'Cumulus', // description: 'Pure cow milk butter', // //'Light as air. The Cumulus is encased in cloud-like waterproof nylon and has a spacious main interior. Collapse it for easy travel and snap it shut with magnetic closures.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/HomemadeButter.jpeg', // price: 250, unit: '200g', minQty: 1, active: true, // }, // { // id: 140, // title: 'Home Made Paneer', //'Cumulus', // description: 'Pure cow milk paneer', // //'Light as air. The Cumulus is encased in cloud-like waterproof nylon and has a spacious main interior. Collapse it for easy travel and snap it shut with magnetic closures.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/HomemadePaneer.jpeg', // price: 250, unit: '200g', minQty: 1, active: true, // }, // { // id: 150, // title: 'Home Made Ghee', //'Cumulus', // description: 'Pure cow milk ghee', // //'Light as air. The Cumulus is encased in cloud-like waterproof nylon and has a spacious main interior. Collapse it for easy travel and snap it shut with magnetic closures.', // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/HomemadeGhee.jpeg', // price: 300, unit: '200g', minQty: 1, active: true, // }, // // { // // id: 200, // // title: 'Deshi Chicken Eggs', //'Stratus Backpack', // // description: 'Organic nutrient healthy chicken eggs', // // //'The Stratus is encased in cloud-like waterproof nylon and features exterior + interior pockets for your water bottle, umbrella, and laptop. Reach around to the side for on-the-go access to the main compartment. Collapse it for easy travel. Your backpack just got an upgrade.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/desi-eggs-1.jpg', // // price: 240, unit: 'Dozen', minQty: 2, active: true, // // }, // // { // // id: 210, // // title: 'Deshi Chickens', //'Dance Bag Nylon', // // description: 'Naturally raised organic deshi chicken', // // //'For days when you just need to grab and go. The Dance Bag is a compact, gumdrop-shaped backpack wrapped in water-repellent nylon. It’s the perfect carry-all for your life in motion.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Deshi_Ckicken.jpeg', // // price: 1100, unit: 'Kg', minQty: 2, active: true, //, orUnit: Piece // // }, // // { // // id: 220, // // title: 'Pak Chicken', //'Dance Bag Nylon', // // description: 'Naturally raised organic deshi chicken', // // //'For days when you just need to grab and go. The Dance Bag is a compact, gumdrop-shaped backpack wrapped in water-repellent nylon. It’s the perfect carry-all for your life in motion.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/desi-chicken-1.webp', // // price: 600, unit: 'Kg', minQty: 2, active: true, //, orUnit: Piece // // }, // // { // // id: 230, // // title: 'Broiler Chicken', //'Dance Bag Nylon', // // description: 'Naturally raised organic deshi chicken', // // //'For days when you just need to grab and go. The Dance Bag is a compact, gumdrop-shaped backpack wrapped in water-repellent nylon. It’s the perfect carry-all for your life in motion.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Broiler_Chicken.jpeg', // // price: 450, unit: 'Kg', minQty: 2, active: true, //, orUnit: Piece // // }, // // { // // id: 400, // // title: 'Beef Bone In', //'Organic Beef', // // description: 'Our cows are fed with natural and hygenic food.', // // //'The Studio Bag is identical to its predecessor plus a few more inches to love. Transition it from satchel to backpack to crossbody simply by changing straps. Carry it wherever you go - it will be ready to adapt to your needs and keep up with your lifestyle.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Beef_Bone_In.jpeg', // // price: 750, unit: 'Kg', minQty: 3, active: true, // // }, // // { // // id: 410, // // title: 'Beef Boneless', //'Organic Beef', // // description: 'Our cows are fed with natural and hygenic food.', // // //'The Studio Bag is identical to its predecessor plus a few more inches to love. Transition it from satchel to backpack to crossbody simply by changing straps. Carry it wherever you go - it will be ready to adapt to your needs and keep up with your lifestyle.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Beef_Bone_less.jpeg', // // price: 1000, unit: 'Kg', minQty: 3, active: true, // // }, // // { // // id: 420, // // title: 'Ox Head Meat', //'Organic Beef', // // description: 'Our cows are fed with natural and hygenic food.', // // //'The Studio Bag is identical to its predecessor plus a few more inches to love. Transition it from satchel to backpack to crossbody simply by changing straps. Carry it wherever you go - it will be ready to adapt to your needs and keep up with your lifestyle.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Ox_Head_Meat.jpeg', // // price: 750, unit: 'Kg', minQty: 3, active: true, // // }, // // { // // id: 430, // // title: 'Ox Liver (Kolija)', //'Organic Beef', // // description: 'Our cows are fed with natural and hygenic food.', // // //'The Studio Bag is identical to its predecessor plus a few more inches to love. Transition it from satchel to backpack to crossbody simply by changing straps. Carry it wherever you go - it will be ready to adapt to your needs and keep up with your lifestyle.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Ox_Liver.jpeg', // // price: 750, unit: 'Kg', minQty: 3, active: true, // // }, // // { // // id: 600, // // title: 'Mutton Bone In', //'Studio Bag Vaqueta', // // description: 'Our goats are fed with natural and hygenic food.', // // //'You’re not any one thing, why should your bag be? The Studio Bag Vaqueta features everything you know and love about the Studio Bag wrapped up in colorful Italian nylon and exquisite vaqueta leather. ', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Mutton_Bone_In.jpeg', // // price: 1200, unit: 'Kg', minQty: 2, active: true, // // }, // // { // // id: 610, // // title: 'Goat Liver', //'Studio Bag Vaqueta', // // description: 'Our goats are fed with natural and hygenic food.', // // //'You’re not any one thing, why should your bag be? The Studio Bag Vaqueta features everything you know and love about the Studio Bag wrapped up in colorful Italian nylon and exquisite vaqueta leather. ', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Goat_Liver.jpeg', // // price: 700, unit: 'Kg', minQty: 2, active: true, // // }, // // { // // id: 630, // // title: 'Goat Head Meat', //'Studio Bag Vaqueta', // // description: 'Our goats are fed with natural and hygenic food.', // // //'You’re not any one thing, why should your bag be? The Studio Bag Vaqueta features everything you know and love about the Studio Bag wrapped up in colorful Italian nylon and exquisite vaqueta leather. ', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/Goat_Head_Meat.jpeg', // // price: 600, unit: 'Kg', minQty: 2, active: true, // // }, // // { // // id: 800, // // title: 'Duck Eggs', //'Mini Circle', // // description: 'Organic nutrient healthy duck eggs', // // //'The Mini Circle is the ultimate multipurpose grab and go style. Transfer it from crossbody to waistbelt to wristlet simply by changing straps. Internal built-in battery that can charge your USB device. Vegan friendly.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/duck-eggs-1.jpg', // // price: 240, unit: 'Dozen', minQty: 1, active: false, // // }, // // { // // id: 810, // // title: 'Ducks', //'Organic Ducks', // // description: 'Naturally raised organic ducks', // // //'The Cirrus rucksack is encased in cloud-like waterproof nylon and features ample interior and exterior pockets, including built-in phone + battery pockets to stay powered up on the go. Luggage slip and secure passport sleeve make it the perfect travel companion. Adventure away.', // // imageUrl: 'https://storage.googleapis.com/organic-orkobd/images/ducks-1.jpg', // // price: 600, unit: 'Kg', minQty: 2, active: false, // // }, ]; const setUserTypes = (nextPageToken) => { // List batch of users, 1000 at a time. firebase.auth .listUsers(1000, nextPageToken) .then((listUsersResult) => { listUsersResult.users.forEach(async (userRecord) => { //console.log(userRecord); const user = { uid:userRecord.uid, email:userRecord.email, displayName:userRecord.displayName, type: (userRecord.customClaims && userRecord.customClaims.type? userRecord.customClaims.type: '') }; switch(user.email) { case 'mahbubur.rahman.64@gmail.com': await firebase.auth.setCustomUserClaims(user.uid, { type: 'A' }); break; case 'mahbub.seaboard@gmail.com': await firebase.auth.setCustomUserClaims(user.uid, { type: 'M' }); break; case 'mahbub.bysontech@gmail.com': await firebase.auth.setCustomUserClaims(user.uid, { type: 'E' }); break; } //console.log('user', user); //userRecord.toJSON() }); if (listUsersResult.pageToken) listAllUsers(listUsersResult.pageToken); }) .catch((error) => { console.log('Error listing users:', error); }); }; async function getShopData(req, res) { console.log('GET /get-shop-data'); const productsDb = firebase.db.collection('products'); // SHOP_DATA.forEach(async (data) => { // await productsDb.doc(data.id.toString()).set({ id: data.id.toString(), // title: data.title, description: data.description, imageUrl: data.imageUrl, // price: data.price, unit: data.unit, minQty: data.minQty, active: data.active, // }); // }) //------------------------------------------------------------------------------// const products = await firebase.db.collection('products').get(); //console.log("products:", products); //QuerySnapshot // const shopData = [], docs = products.docs; //console.log("docs:", docs); //QueryDocumentSnapshot[] // for(let doc of docs) { //console.log("doc:", doc); //QueryDocumentSnapshot // const data = doc.data(); shopData.push(data); //console.log("data:", data); // } console.log("shopData:", shopData); const shopData = products.docs.map(doc => doc.data()); //console.log('shopData:', shopData); // setUserTypes(); res.status(200).json({data: shopData}); //SHOP_DATA } module.exports = getShopData;
💾 Save Changes
❌ Cancel