Initial commit: Lightning Lottery - Bitcoin Lightning Network powered lottery
Features: - Lightning Network payments via LNbits integration - Provably fair draws using CSPRNG - Random ticket number generation - Automatic payouts with retry/redraw logic - Nostr authentication (NIP-07) - Multiple draw cycles (hourly, daily, weekly, monthly) - PostgreSQL and SQLite database support - Real-time countdown and payment animations - Swagger API documentation - Docker support Stack: - Backend: Node.js, TypeScript, Express - Frontend: Next.js, React, TailwindCSS, Redux - Payments: LNbits
This commit is contained in:
130
back_end/src/routes/admin.ts
Normal file
130
back_end/src/routes/admin.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import { Router } from 'express';
|
||||
import {
|
||||
listCycles,
|
||||
runDrawManually,
|
||||
retryPayout,
|
||||
listPayouts
|
||||
} from '../controllers/admin';
|
||||
import { verifyAdmin } from '../middleware/auth';
|
||||
|
||||
const router = Router();
|
||||
|
||||
// All admin routes require admin key
|
||||
router.use(verifyAdmin);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /admin/cycles:
|
||||
* get:
|
||||
* summary: List all jackpot cycles
|
||||
* tags: [Admin]
|
||||
* security:
|
||||
* - adminKey: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: status
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Filter by status
|
||||
* - in: query
|
||||
* name: cycle_type
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Filter by cycle type
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 50
|
||||
* - in: query
|
||||
* name: offset
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 0
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List of cycles
|
||||
* 403:
|
||||
* description: Invalid admin key
|
||||
*/
|
||||
router.get('/cycles', listCycles);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /admin/cycles/{id}/run-draw:
|
||||
* post:
|
||||
* summary: Manually trigger a draw for a cycle
|
||||
* tags: [Admin]
|
||||
* security:
|
||||
* - adminKey: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Draw executed successfully
|
||||
* 400:
|
||||
* description: Draw failed or invalid cycle
|
||||
* 403:
|
||||
* description: Invalid admin key
|
||||
*/
|
||||
router.post('/cycles/:id/run-draw', runDrawManually);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /admin/payouts:
|
||||
* get:
|
||||
* summary: List all payouts
|
||||
* tags: [Admin]
|
||||
* security:
|
||||
* - adminKey: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: status
|
||||
* schema:
|
||||
* type: string
|
||||
* description: Filter by status
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 50
|
||||
* responses:
|
||||
* 200:
|
||||
* description: List of payouts
|
||||
* 403:
|
||||
* description: Invalid admin key
|
||||
*/
|
||||
router.get('/payouts', listPayouts);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /admin/payouts/{id}/retry:
|
||||
* post:
|
||||
* summary: Retry a failed payout
|
||||
* tags: [Admin]
|
||||
* security:
|
||||
* - adminKey: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Payout retry successful
|
||||
* 400:
|
||||
* description: Retry failed or invalid payout
|
||||
* 403:
|
||||
* description: Invalid admin key
|
||||
*/
|
||||
router.post('/payouts/:id/retry', retryPayout);
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user