Skip to content

Commit

Permalink
Firebase 0.1.8
Browse files Browse the repository at this point in the history
Restructuring/building Controllers and Routes within Server/api/
  • Loading branch information
EdmundBerkmann committed Feb 21, 2024
1 parent 0ae880f commit 66bfc8b
Show file tree
Hide file tree
Showing 221 changed files with 390 additions and 75 deletions.
3 changes: 3 additions & 0 deletions contracts/facets/steez/Collection.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (c) 2023 Edmund Berkmann
pragma solidity ^0.8.10;
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 0 additions & 11 deletions server/api/controllers/gallery/GovernanceController.js

This file was deleted.

19 changes: 0 additions & 19 deletions server/api/controllers/gallery/PortfolioController.js

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 0 additions & 11 deletions server/api/controllers/mosaic/MosaicController.js

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
23 changes: 23 additions & 0 deletions server/api/routes/bazaar/analyticRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const express = require('express');
const { protect } = require('../middleware/authMiddleware');
const {
addLiquidity,
createPool,
swapTokens,
initiateAuction,
placeBid,
fetchLeaderboard,
stakeTokens,
calculateYield,
distributeRewards,
} = require('../controllers/bazaarController');

const router = express.Router();


exports.getSummary = async (req, res) => {
// Code to retrieve market metrics or summary
};


module.exports = router;
25 changes: 25 additions & 0 deletions server/api/routes/bazaar/auctionRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const AuctionsService = require('../services/auctionsService');

// Auction Management
router.post('/initiateAuction', protect, initiateAuction);
router.post('/placeBid', protect, placeBid);
router.get('/fetchLeaderboard', protect, fetchLeaderboard);

exports.startAuction = async (req, res) => {
try {
const auction = await AuctionsService.startNewAuction(req.body);
res.status(201).json(auction);
} catch (error) {
res.status(500).send(error.message);
}
};

exports.placeBid = async (req, res) => {
try {
const auction = await AuctionsService.placeBid(req.params.auctionId, req.body);
res.json(auction);
} catch (error) {
res.status(500).send(error.message);
}
};

19 changes: 19 additions & 0 deletions server/api/routes/bazaar/blogRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports.getAllBlogs = async (req, res) => {
// Code to retrieve all blog posts or articles
};

exports.getBlogDetails = async (req, res) => {
// Code to retrieve details of a particular blog post or article
};

exports.createBlog = async (req, res) => {
// Code to create a new blog post or article
};

exports.updateBlog = async (req, res) => {
// Code to update a particular blog post or article
};

exports.deleteBlog = async (req, res) => {
// Code to delete a particular blog post or article
};
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions server/api/routes/bazaar/highlightRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.getTopCreators = async (req, res) => {
// Code to retrieve a list of top creators
};

exports.getCreatorDetails = async (req, res) => {
// Code to retrieve details of a particular creator
};
Empty file.
3 changes: 3 additions & 0 deletions server/api/routes/bazaar/inventoryRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Liquidity Management
router.post('/createPool', protect, createPool);
router.post('/addLiquidity', protect, addLiquidity);
29 changes: 29 additions & 0 deletions server/api/routes/bazaar/listingRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
exports.createListing = async (req, res) => {
try {
const listing = await ListingsService.createListing(req.body);
res.status(201).json(listing);
} catch (error) {
res.status(500).send(error.message);
}
};

exports.getListings = async (req, res) => {
try {
const listings = await ListingsService.fetchAllListings();
res.json(listings);
} catch (error) {
res.status(500).send(error.message);
}
};

exports.updateListing = async (req, res) => {
// Code to update details of a listing
};

exports.deleteListing = async (req, res) => {
// Code to delete a listing
};

exports.getAllListings = async (req, res) => {
// Code to retrieve all listings in the marketplace
};
34 changes: 0 additions & 34 deletions server/api/routes/bazaar/marketRoutes.js

This file was deleted.

7 changes: 7 additions & 0 deletions server/api/routes/bazaar/orderBookRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.getOrderBook = async (req, res) => {
// Code to retrieve the current state of the order book
};

exports.getTopOrders = async (req, res) => {
// Code to retrieve the top 'n' buy and sell orders
};
19 changes: 19 additions & 0 deletions server/api/routes/bazaar/purchaseRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports.createPurchase = async (req, res) => {
// Code to create a new purchase order
};

exports.getPurchaseDetails = async (req, res) => {
// Code to retrieve details of a purchase
};

exports.updatePurchaseStatus = async (req, res) => {
// Code to update the status of a purchase
};

exports.getAllPurchases = async (req, res) => {
// Code to retrieve all purchases for a user or seller
};


// Token Trading
router.post('/swapTokens', protect, swapTokens);
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions server/api/routes/bazaar/royaltyRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.calculateFees = async (req, res) => {
// Code to calculate fees for a particular transaction or listing
};

exports.updateFeeStructure = async (req, res) => {
// Code to update the marketplace's fee structure
};
3 changes: 3 additions & 0 deletions server/api/routes/bazaar/searchRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exports.searchListings = async (req, res) => {
// Code to search through listings based on provided criteria
};
7 changes: 7 additions & 0 deletions server/api/routes/bazaar/steezBazaarRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.getFeaturedTokens = async (req, res) => {
// Code to retrieve a list of featured tokens
};

exports.getFeaturedTokenDetails = async (req, res) => {
// Code to retrieve details of a particular featured token
};
24 changes: 24 additions & 0 deletions server/api/routes/bazaar/swapRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
exports.placeOrder = async (req, res) => {
// Code to place a new limit order
};

exports.updateOrder = async (req, res) => {
// Code to modify an existing limit order
};

exports.cancelOrder = async (req, res) => {
// Code to cancel an existing limit order
};

exports.getMyOrders = async (req, res) => {
// Code for a user to view their active and past orders
};

exports.processTransaction = async (req, res) => {
try {
const transaction = await TransactionsService.processTransaction(req.body);
res.json(transaction);
} catch (error) {
res.status(500).send(error.message);
}
};
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
46 changes: 46 additions & 0 deletions server/api/routes/common/auth/authRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
const express = require('express');
const router = express.Router();
const firebaseAuth = require('../../services/firebaseAuth');
const web3Service = require('../../services/web3Service');
const jwt = require('jsonwebtoken');

// Middleware to validate web3 token
const { validateWeb3Token } = require('../../middleware/authMiddleware');

// Route to handle user registration via Firebase and blockchain account linking
router.post('/register', async (req, res) => {
try {
const { email, password, blockchainAddress } = req.body;
const userCredential = await firebaseAuth.register(email, password);
const token = jwt.sign({ uid: userCredential.user.uid }, process.env.JWT_SECRET, { expiresIn: '1h' });

// Link blockchain address with Firebase user
await web3Service.linkBlockchainAddress(userCredential.user.uid, blockchainAddress);

res.status(201).json({ token, uid: userCredential.user.uid, blockchainAddress });
} catch (error) {
res.status(400).json({ error: error.message });
}
});

// Route to handle user login and token generation
router.post('/login', async (req, res) => {
try {
const { email, password } = req.body;
const userCredential = await firebaseAuth.login(email, password);
const token = jwt.sign({ uid: userCredential.user.uid }, process.env.JWT_SECRET, { expiresIn: '1h' });

res.status(200).json({ token, uid: userCredential.user.uid });
} catch (error) {
res.status(400).json({ error: error.message });
}
});

// Route to validate and refresh JWT tokens
router.post('/token', validateWeb3Token, (req, res) => {
// Assuming validateWeb3Token middleware validates the existing token and injects user info into req.user
const newToken = jwt.sign({ uid: req.user.uid }, process.env.JWT_SECRET, { expiresIn: '1h' });
res.status(200).json({ token: newToken });
});

module.exports = router;
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions server/api/routes/gallery/stakingRewards/stakeManagementRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.stakeTokens = async (req, res) => {
// Code to stake tokens
};

exports.unstakeTokens = async (req, res) => {
// Code to unstake tokens
};

exports.getStakedAmount = async (req, res) => {
// Code to retrieve the staked amount of tokens
};
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
exports.createUserWallet = async (req, res) => {
// Code to create a user's wallet
};

exports.getUserWalletDetails = async (req, res) => {
// Code to retrieve a user's wallet details
};

exports.updateUserWallet = async (req, res) => {
// Code to update a user's wallet details
};

exports.deleteUserWallet = async (req, res) => {
// Code to delete a user's wallet
};
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions server/api/routes/gallery/transactions/depositRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.initiateDeposit = async (req, res) => {
// Code to initiate a deposit
};

exports.confirmDeposit = async (req, res) => {
// Code to confirm a deposit
};

exports.getDepositHistory = async (req, res) => {
// Code to retrieve deposit history
};
11 changes: 11 additions & 0 deletions server/api/routes/gallery/transactions/giftRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
exports.sendGift = async (req, res) => {
// Code to send a gift
};

exports.receiveGift = async (req, res) => {
// Code to confirm receipt of a gift
};

exports.getGiftHistory = async (req, res) => {
// Code to retrieve gift history
};
7 changes: 7 additions & 0 deletions server/api/routes/gallery/transactions/royaltyRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
exports.calculateFees = async (req, res) => {
// Code to calculate fees for a given transaction
};

exports.getFeesHistory = async (req, res) => {
// Code to retrieve history of fees collected
};
Loading

0 comments on commit 66bfc8b

Please sign in to comment.