This project is a Node.js server that interacts with various NFT marketplaces, allowing users to place bids, cancel orders, and manage tasks related to NFT trading. It utilizes WebSocket for real-time communication and Redis for task management and caching.
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies:
npm install
-
Set up Redis: Ensure you have Redis installed and running. You can use Docker to run Redis:
docker-compose up -d
-
Set up environment variables: Create a
.envfile in the root directory and add the following variables:MONGODB_URI=<your_mongodb_uri> REDIS_URI=redis://localhost:6379 PORT=3003
To start the server in development mode, use:
npm run dev
- Express: The server framework used to handle HTTP requests.
- WebSocket: For real-time communication with clients.
- BullMQ: A queue system for managing tasks and jobs.
- Mongoose: ODM for MongoDB, used to interact with the database.
- Redis: Used for caching and managing state across tasks.
src/: Contains the main application code.index.ts: Entry point of the application.models/: Mongoose models for MongoDB.marketplace/: Functions related to different NFT marketplaces.utils/: Utility functions and classes.adapter/: WebSocket handling and event management.functions/: Helper functions for various operations.
- initialize(): Sets up the application, including rate limiting and API key configuration.
- fetchCurrentTasks(): Retrieves current tasks from the database and adds them to the queue.
- processNewTask(task): Adds a new task to the queue and subscribes to the relevant collections.
- updateStatus(task): Updates the running status of a task.
- connectWebSocket(): Establishes a connection to the OpenSea WebSocket for real-time updates.
Make sure to set the following environment variables in your .env file:
MONGODB_URI: Connection string for MongoDB.REDIS_URI: Connection string for Redis.PORT: Port on which the server will run (default is 3003).
This project is licensed under the MIT License.