diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8062a71 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 3Engine + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..653adeb --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Minter Server + +With the Minter Server, effortlessly mint Items (NFTs) directly from your backend to enrich the gaming experience for users. This setup provides a foundational example; feel free to enhance and tailor it to your game's mechanics. + +[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) + +## 🛠 Tech Stack + +- **Server:** TypeScript, Node.js, Express + +## 🚀 Getting Started + +### 1. Clone the Repository + +```bash +git clone https://github.com/3engine/MinterServer.git +``` + +### 2. Navigate to the Directory + +```bash +cd MinterServer +``` + +### 3. Install Dependencies + +```bash +npm install +``` + +### 4. Start the Server + +```bash +npm run start +``` + +## 🌍 Environment Variables + +To run this project, ensure you have the following environment variables set up in your `.env` file: + +| Variable | Description | +|---------------------|-------------------------------------------| +| `GAME_PRIVATE_KEY` | Minter Private Key | +| `CONTRACT_ADDRESS` | Address of the Item Contract | +| `MONGODB_URI` | MongoDB Connection URI | +| `NETWORK_RPC` | EVM Network RPC | +| `APIKEY_3ENGINE` | 3Engine API Key (Reach out for access) | +| `API_3ENGINE` | 3Engine API Endpoint | + +## 📜 License + +Licensed under the [MIT License](https://choosealicense.com/licenses/mit/). diff --git a/package.json b/package.json index 1cc9c7d..8f2bb9f 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "@types/mongoose": "^5.11.97", "@types/node": "^20.8.2", "axios": "^1.5.1", + "cors": "^2.8.5", "dotenv": "^16.3.1", "ethers": "^6.7.1", "express": "^4.18.2", diff --git a/src/middlewares/authentication.ts b/src/middlewares/authentication.ts index 9df85d9..198317b 100644 --- a/src/middlewares/authentication.ts +++ b/src/middlewares/authentication.ts @@ -13,9 +13,9 @@ export async function checkSessionMiddleware ( next: NextFunction) { try { const apiKey = process.env.APIKEY_3ENGINE as string; - const sessionId: string = req.body.sessionId; + const address: string = req.body.address; - const response = await axios.get(`${process.env.API_3ENGINE}/player/session/status/${sessionId}`, { + const response = await axios.get(`${process.env.API_3ENGINE}/player/session/status?address=${address}`, { headers: { 'x-api-key': apiKey } @@ -28,7 +28,7 @@ export async function checkSessionMiddleware ( res.status(400).json({ error: 'Session is not active' }); } } catch (error) { - console.error(error); - res.status(500).json({ error: 'Failed to check session status' }); + console.error('Error details:', error.response?.data || error.message); + res.status(500).json(error.response?.data); } }; \ No newline at end of file diff --git a/src/server.ts b/src/server.ts index 1adee8f..dde2e30 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,10 +1,16 @@ import express from 'express'; import mintRoute from './routes/mintRoute'; import bodyParser from 'body-parser'; +import cors from 'cors'; import { mongodbMiddleware } from './config/db'; const app = express(); - +app.use( + cors({ + credentials: true, + origin: true, + }) +); app.use(mongodbMiddleware); app.use(bodyParser.json()); app.use('/api', mintRoute); diff --git a/vercel.json b/vercel.json index 48df6ec..3074474 100644 --- a/vercel.json +++ b/vercel.json @@ -1,7 +1,9 @@ { "name": "Minter-Server", - "rewrites": [ - { "source": "/.*", "destination": "/src/server" } + "builds": [ + { "src": "src/server.ts", "use": "@vercel/node" } + ], + "routes": [ + { "src": "/.*", "dest": "src/server.ts" } ] - } - \ No newline at end of file + } \ No newline at end of file