| src | ||
| .gitignore | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
DMRocket API
A Node.js/Express API for managing orders with MySQL database integration.
Setup
1. Install Dependencies
npm install
2. Database Setup
Create your MySQL database and table:
CREATE DATABASE dmrocket;
USE dmrocket;
CREATE TABLE `Orders` (
`id` INT NOT NULL AUTO_INCREMENT,
`wallet` TEXT NOT NULL,
`mint` TEXT NOT NULL,
`amount` BIGINT NOT NULL DEFAULT '100',
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`user_id` TEXT NOT NULL,
`pk` TEXT,
`order_data` JSON,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;
3. Environment Configuration
Create a .env.local file in the root directory with your database credentials:
# Database Configuration
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password_here
DB_NAME=dmrocket
DB_PORT=3306
# Server Configuration
PORT=7111
NODE_ENV=development
4. Run the Application
# Development mode
npm run dev
# Production build
npm run build
npm start
API Endpoints
All endpoints use GET requests for simplicity and ease of use.
Orders API
Create Order
- GET
/api/v1/create_order - Query Parameters:
mint(required) - Mint addressamount(optional) - Order amount (default: 100)user_id(required) - User identifierinstagramAccount(required) - Instagram accounttargetAccounts(required) - Target accountstargetHashtags(required) - Target hashtagstargetLocation(required) - Target locationpackageType(required) - Package type (number)customMessage(required) - Custom messageemail(required) - Email address
Note: A new Solana wallet is automatically generated for each order, including the wallet address and private key.
Example:
GET /api/v1/create_order?mint=mint_address&amount=200&user_id=user123&instagramAccount=myaccount&targetAccounts=account1,account2&targetHashtags=#tag1,#tag2&targetLocation=New York&packageType=1&customMessage=Hello&email=user@example.com
Get All Orders
- GET
/api/v1/get_all_orders
Example:
GET /api/v1/get_all_orders
Get Order by ID
- GET
/api/v1/get_order_by_id/:id
Example:
GET /api/v1/get_order_by_id/1
Get Orders by User ID
- GET
/api/v1/get_orders_by_user/:userId
Example:
GET /api/v1/get_orders_by_user/user123
Update Order
- GET
/api/v1/update_order/:id - Query Parameters: (any combination of fields)
wallet(optional) - New wallet addressmint(optional) - New mint addressamount(optional) - New amountuser_id(optional) - New user IDpk(optional) - New private keyinstagramAccount(optional) - New Instagram accounttargetAccounts(optional) - New target accountstargetHashtags(optional) - New target hashtagstargetLocation(optional) - New target locationpackageType(optional) - New package typecustomMessage(optional) - New custom messageemail(optional) - New email address
Example:
GET /api/v1/update_order/1?amount=300&user_id=newuser456&packageType=2&customMessage=Updated message
Delete Order
- GET
/api/v1/delete_order/:id
Example:
GET /api/v1/delete_order/1
Health Check
- GET
/health- Returns API status and database connection status
Response Format
All API responses follow this format:
{
"success": true,
"data": {...},
"count": 1
}
Error responses:
{
"error": "Error message",
"message": "Detailed error description"
}
Database Schema
| Field | Type | Description |
|---|---|---|
| id | INT | Auto-increment primary key |
| wallet | TEXT | Wallet address (auto-generated) |
| mint | TEXT | Mint address |
| amount | BIGINT | Order amount (default: 100) |
| created_at | DATETIME | Timestamp (auto-generated) |
| user_id | TEXT | User identifier |
| pk | TEXT | Private key (auto-generated) |
| order_data | JSON | Order details (Instagram account, targets, etc.) |
Development
- TypeScript for type safety
- Express.js for the web framework
- MySQL2 for database operations
- Dotenv for environment variable management