Begin to store counts in a db. Draw and store card counts async.
This commit is contained in:
parent
0f944ffda2
commit
304dc28236
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
/build
|
||||||
|
/lib
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
68
package-lock.json
generated
68
package-lock.json
generated
@ -840,6 +840,11 @@
|
|||||||
"repeat-element": "^1.1.2"
|
"repeat-element": "^1.1.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"bson": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-jCGVYLoYMHDkOsbwJZBCqwMHyH4c+wzgI9hG7Z6SZJRXWr+x58pdIbm2i9a/jFGCkRJqRUr8eoI7lDWa0hTkxg=="
|
||||||
|
},
|
||||||
"bytes": {
|
"bytes": {
|
||||||
"version": "3.0.0",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz",
|
||||||
@ -2546,6 +2551,12 @@
|
|||||||
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
"resolved": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||||
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
"integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
|
||||||
},
|
},
|
||||||
|
"memory-pager": {
|
||||||
|
"version": "1.5.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
|
||||||
|
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"merge-descriptors": {
|
"merge-descriptors": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||||
@ -2648,6 +2659,26 @@
|
|||||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.23.0.tgz",
|
||||||
"integrity": "sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA=="
|
"integrity": "sha512-3IE39bHVqFbWWaPOMHZF98Q9c3LDKGTmypMiTM2QygGXXElkFWIH7GxfmlwmY2vwa+wmNsoYZmG2iusf1ZjJoA=="
|
||||||
},
|
},
|
||||||
|
"mongodb": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-xQ6apOOV+w7VFApdaJpWhYhzartpjIDFQjG0AwgJkLh7dBs7PTsq4A3Bia2QWpDohmAzTBIdQVLMqqLy0mwt3Q==",
|
||||||
|
"requires": {
|
||||||
|
"mongodb-core": "3.2.2",
|
||||||
|
"safe-buffer": "^5.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mongodb-core": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-YRgC39MuzKL0uoGoRdTmV1e9m47NbMnYmuEx4IOkgWAGXPSEzRY7cwb3N0XMmrDMnD9vp7MysNyAriIIeGgIQg==",
|
||||||
|
"requires": {
|
||||||
|
"bson": "^1.1.1",
|
||||||
|
"require_optional": "^1.0.1",
|
||||||
|
"safe-buffer": "^5.1.2",
|
||||||
|
"saslprep": "^1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ms": {
|
"ms": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||||
@ -3464,6 +3495,20 @@
|
|||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"require_optional": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==",
|
||||||
|
"requires": {
|
||||||
|
"resolve-from": "^2.0.0",
|
||||||
|
"semver": "^5.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"resolve-from": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c="
|
||||||
|
},
|
||||||
"resolve-url": {
|
"resolve-url": {
|
||||||
"version": "0.2.1",
|
"version": "0.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz",
|
||||||
@ -3498,6 +3543,20 @@
|
|||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||||
},
|
},
|
||||||
|
"saslprep": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.2.tgz",
|
||||||
|
"integrity": "sha512-4cDsYuAjXssUSjxHKRe4DTZC0agDwsCqcMqtJAQPzC74nJ7LfAJflAtC1Zed5hMzEQKj82d3tuzqdGNRsLJ4Gw==",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"sparse-bitfield": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "5.7.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz",
|
||||||
|
"integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA=="
|
||||||
|
},
|
||||||
"send": {
|
"send": {
|
||||||
"version": "0.16.2",
|
"version": "0.16.2",
|
||||||
"resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
|
"resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz",
|
||||||
@ -3720,6 +3779,15 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"sparse-bitfield": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
|
||||||
|
"integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=",
|
||||||
|
"optional": true,
|
||||||
|
"requires": {
|
||||||
|
"memory-pager": "^1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"split-string": {
|
"split-string": {
|
||||||
"version": "3.1.0",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"express": "^4.16.4",
|
"express": "^4.16.4",
|
||||||
"helmet": "^3.15.1",
|
"helmet": "^3.15.1",
|
||||||
"moment": "^2.23.0",
|
"moment": "^2.23.0",
|
||||||
|
"mongodb": "^3.2.2",
|
||||||
"request": "^2.88.0"
|
"request": "^2.88.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
16
src/index.js
16
src/index.js
@ -6,15 +6,15 @@ import express from 'express';
|
|||||||
import bodyParser from 'body-parser';
|
import bodyParser from 'body-parser';
|
||||||
|
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import strategies from './strategies';
|
import { drawCard } from './draw';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
app.use(bodyParser.urlencoded({extended: false}));
|
app.use(bodyParser.urlencoded({extended: false}));
|
||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
|
|
||||||
app.get('/', (req, res) => {
|
app.get('/', async (req, res) => {
|
||||||
const theStrategy = strategies[ Math.floor(Math.random()*strategies.length) ];
|
const theStrategy = await drawCard();
|
||||||
const theTree =
|
const theTree =
|
||||||
`<!doctype html>
|
`<!doctype html>
|
||||||
<html lang='en'>
|
<html lang='en'>
|
||||||
@ -22,13 +22,13 @@ app.get('/', (req, res) => {
|
|||||||
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
<link rel='apple-touch-icon' href='./touch_icon.png'>
|
<link rel='apple-touch-icon' href='./touch_icon.png'>
|
||||||
<title>
|
<title>
|
||||||
${theStrategy.toLowerCase()}
|
${theStrategy}
|
||||||
</title>
|
</title>
|
||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
</head>
|
</head>
|
||||||
<body style='background-color:#111; margin:0; padding:0; display:flex;align-items:center;justify-content:center;min-height:24em;'>
|
<body style='background-color:#111; margin:0; padding:0; display:flex;align-items:center;justify-content:center;min-height:24em;'>
|
||||||
<div style='color:#eee;margin:0 auto; max-width:80%;flex:1;text-align:center;font-family:Futura;font-size:30px;line-height:40px'>
|
<div style='color:#eee;margin:0 auto; max-width:80%;flex:1;text-align:center;font-family:Futura;font-size:30px;line-height:40px'>
|
||||||
${theStrategy.toLowerCase()}
|
${theStrategy}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>`;
|
</html>`;
|
||||||
@ -38,7 +38,7 @@ app.get('/', (req, res) => {
|
|||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.post('/', (req, res, next) => {
|
app.post('/', async (req, res, next) => {
|
||||||
if (req.body.type === 'url_verification') {
|
if (req.body.type === 'url_verification') {
|
||||||
return res.status(200).json(req.body.challenge);
|
return res.status(200).json(req.body.challenge);
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ app.post('/', (req, res, next) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
const theStrategy = encodeURIComponent(strategies[ Math.floor(Math.random()*strategies.length) ].toLowerCase());
|
const theStrategy = encodeURIComponent(await drawCard());
|
||||||
|
|
||||||
var theResponseRequest = https.request(
|
var theResponseRequest = https.request(
|
||||||
{
|
{
|
||||||
@ -78,5 +78,5 @@ app.post('/', (req, res, next) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.listen(4242, () => {
|
app.listen(4242, () => {
|
||||||
console.log(`oblique strategies are being served`)
|
console.log(`oblique strategies are being served`);
|
||||||
});
|
});
|
||||||
|
@ -65,7 +65,6 @@ const strategies = [
|
|||||||
`Get your neck massaged`,
|
`Get your neck massaged`,
|
||||||
`Ghost echoes`,
|
`Ghost echoes`,
|
||||||
`Give the game away`,
|
`Give the game away`,
|
||||||
`Give the name away`,
|
|
||||||
`Give way to your worst impulse`,
|
`Give way to your worst impulse`,
|
||||||
`Go outside. Shut the door.`,
|
`Go outside. Shut the door.`,
|
||||||
`Go slowly all the way round the outside`,
|
`Go slowly all the way round the outside`,
|
||||||
@ -174,6 +173,6 @@ const strategies = [
|
|||||||
`Short circuit`,
|
`Short circuit`,
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = strategies;
|
module.exports = {
|
||||||
|
strategies,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user