UNPKG

crypto-slots

Version:

A minimal test server is provided, see server

86 lines (71 loc) 1.69 kB
'use strict'; function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } var Koa = _interopDefault(require('koa')); var Router = _interopDefault(require('@koa/router')); var fs = require('fs'); var staticKoa = _interopDefault(require('koa-static')); const topTen = { columns: 5, rows: 5, slotHeight: 100, slots: [ 'btc', 'eth', 'xrp', 'bch', 'ltc', 'eos', 'bnb', 'usdt', 'xlm', 'ada', 'trx', 'xmr' ], bonus: 'btc', multiplier: 2 }; const onebythree = { rows: 1, columns: 3, slotHeight: 100, slots: [ 'eth', 'ltc', 'bnb', 'xlm', 'ada', 'trx', 'xmr', 'xtz' ], bonus: 'eth', multiplier: 2 }; var config = { topTen, onebythree }; const server = new Koa(); const router = new Router(); server.use(staticKoa('./www/')); router.get('/', async ctx => { ctx.body = fs.readFileSync('./www/index.html').toString(); ctx.type = 'html/text'; ctx.status = 200; }); router.get('/index.html', async ctx => { ctx.body = fs.readFileSync('./www/index.html').toString(); // ctx.type = 'html/text' // ctx.status = 200 }); router.get('/spin', async ctx => { const result = []; const game = ctx.params.game; if (!game) throw new Error(404, 'game not defined.') else for (var i = 0; i < config[game].columns; i++) { result.push(lottery(3, config[game].slots.length)); } ctx.body = result; }); server.use(router.routes()); server.use(router.allowedMethods()); server.on('error', error => console.error({error})); server.listen(5000);