From 1ecf232734d9fa7612b6b7a09e0aee04b990e9d1 Mon Sep 17 00:00:00 2001 From: wsknorth Date: Mon, 11 Dec 2017 18:39:40 +0100 Subject: [PATCH 1/4] close #13 start command stop command after middleware starts model sequelize module --- .gitignore | 1 + database/.gitkeep | 0 index.js | 14 +- lib/after/index.js | 13 + lib/response/index.js | 10 +- lib/sequelize/index.js | 10 + lib/start/index.js | 22 + lib/starts/index.js | 8 + lib/stop/index.js | 22 + package-lock.json | 1144 ++++++++++++++++++++++++++++++---------- package.json | 4 +- 11 files changed, 960 insertions(+), 288 deletions(-) create mode 100644 database/.gitkeep create mode 100644 lib/after/index.js create mode 100644 lib/sequelize/index.js create mode 100644 lib/start/index.js create mode 100644 lib/starts/index.js create mode 100644 lib/stop/index.js diff --git a/.gitignore b/.gitignore index d4bfeba..e5f4ab3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ lib/configs/configs.json +database/midnabot.sqlite diff --git a/database/.gitkeep b/database/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/index.js b/index.js index e3c47bc..497f972 100644 --- a/index.js +++ b/index.js @@ -3,20 +3,28 @@ const debug = require('debug')('midnabot') const Telegraf = require('telegraf') +const { sequelize } = require('./lib/sequelize') const { configs } = require('./lib/configs') const { request } = require('./lib/request') const { response } = require('./lib/response') +const { start } = require('./lib/start') +const { after } = require('./lib/after') const { sandbox } = require('./lib/sandbox') -const { about } = require('./lib/about') const { roll } = require('./lib/roll') +const { about } = require('./lib/about') +const { stop } = require('./lib/stop') const bot = new Telegraf(configs.token, { username: configs.username }) +sequelize.sync().then(() => debug(`sQlite connected`)) bot.use(request()) -bot.context.response = response() +bot.use(response()) +bot.command('start', start()) +bot.use(after()) bot.command('sandbox', sandbox()) -bot.command('about', about()) bot.command('roll', roll()) +bot.command('about', about()) +bot.command('stop', stop()) const production = () => { debug(`${configs.username} setting webhook: ${configs.webhook}`) diff --git a/lib/after/index.js b/lib/after/index.js new file mode 100644 index 0000000..8188fd8 --- /dev/null +++ b/lib/after/index.js @@ -0,0 +1,13 @@ +const debug = require('debug')('midnabot:after') + +const { Starts } = require('../starts') + +const after = () => (ctx, next) => { + const name = (ctx.update.message.chat.type === 'private') + ? ctx.update.message.from.username + : ctx.update.message.chat.title + Starts.findOne({ where: { name } }) + .then((starts) => (starts.dataValues.start) ? next() : debug('not started')) +} + +module.exports = { after } diff --git a/lib/response/index.js b/lib/response/index.js index 3b419f5..59866d7 100644 --- a/lib/response/index.js +++ b/lib/response/index.js @@ -1,8 +1,12 @@ const debug = require('debug')('midnabot:response') -const response = () => (callback, message) => { - debug(message) - return callback(message) +const response = () => (ctx, next) => { + ctx.response = (callback, message) => { + debug(message) + return callback(message) + } + + next() } module.exports = { response } diff --git a/lib/sequelize/index.js b/lib/sequelize/index.js new file mode 100644 index 0000000..1314cc9 --- /dev/null +++ b/lib/sequelize/index.js @@ -0,0 +1,10 @@ +const Sequelize = require('sequelize') + +const sequelize = new Sequelize('midnabot', null, null, { + dialect: 'sqlite', + storage: './database/midnabot.sqlite', + operatorsAliases: false, + logging: false +}) + +module.exports = { Sequelize, sequelize } diff --git a/lib/start/index.js b/lib/start/index.js new file mode 100644 index 0000000..5cbb69e --- /dev/null +++ b/lib/start/index.js @@ -0,0 +1,22 @@ +const debug = require('debug')('midnabot:start') + +const { Starts } = require('../starts') + +const start = () => (ctx) => { + const name = (ctx.update.message.chat.type === 'private') + ? ctx.update.message.from.username + : ctx.update.message.chat.title + + const reply = (ctx.update.message.chat.type === 'private') + ? `midnabot is now listening in this chat` + : `midnabot is now listening in this channel` + + Starts.upsert({ name, start: true }) + .then(() => ctx.response(ctx.reply, reply)) + .catch((error) => { + debug(error) + return ctx.response(ctx.reply, `Ooops, something went wrong`) + }) +} + +module.exports = { start } diff --git a/lib/starts/index.js b/lib/starts/index.js new file mode 100644 index 0000000..8e9797b --- /dev/null +++ b/lib/starts/index.js @@ -0,0 +1,8 @@ +const { Sequelize, sequelize } = require('../sequelize') + +const Starts = sequelize.define('starts', { + name: { type: Sequelize.STRING, allowNull: false, unique: true }, + start: { type: Sequelize.BOOLEAN, defaultValue: false } +}) + +module.exports = { Starts } diff --git a/lib/stop/index.js b/lib/stop/index.js new file mode 100644 index 0000000..5e301ba --- /dev/null +++ b/lib/stop/index.js @@ -0,0 +1,22 @@ +const debug = require('debug')('midnabot:stop') + +const { Starts } = require('../starts') + +const stop = () => (ctx) => { + const name = (ctx.update.message.chat.type === 'private') + ? ctx.update.message.from.username + : ctx.update.message.chat.title + + const reply = (ctx.update.message.chat.type === 'private') + ? `midnabot is not listening in this chat` + : `midnabot is not listening in this channel` + + Starts.upsert({ name, start: false }) + .then(() => ctx.response(ctx.reply, reply)) + .catch((error) => { + debug(error) + return ctx.response(ctx.reply, `Ooops, something went wrong`) + }) +} + +module.exports = { stop } diff --git a/package-lock.json b/package-lock.json index aeab0e3..196d9d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,17 +1,18 @@ { - "name": "midna", - "version": "0.1.2", + "name": "midnabot", + "version": "0.1.5", "lockfileVersion": 1, "requires": true, "dependencies": { - "accepts": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", - "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", - "requires": { - "mime-types": "2.1.17", - "negotiator": "0.6.1" - } + "@types/geojson": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-1.0.6.tgz", + "integrity": "sha512-Xqg/lIZMrUd0VRmSRbCAewtwGZiAk3mEUDvV4op1tGl+LvyPcb/MIOSxTl9z+9+J+R4/vpjiCAT4xeKzH9ji1w==" + }, + "@types/node": { + "version": "8.0.57", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.57.tgz", + "integrity": "sha512-ZxrhcBxlZA7tn0HFf7ebUYfR9aHyBgjyavBLzyrYMYuAMbONBPY4S5O35562iV2FfwnZCjQky3gTDy1B3jSZ2Q==" }, "acorn": { "version": "5.2.1", @@ -72,11 +73,6 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, - "any-promise": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", - "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" - }, "argparse": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", @@ -148,6 +144,11 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==" + }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", @@ -164,11 +165,6 @@ "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", "dev": true }, - "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" - }, "caller-path": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/caller-path/-/caller-path-0.1.0.tgz", @@ -242,21 +238,20 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, + "cls-bluebird": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cls-bluebird/-/cls-bluebird-2.1.0.tgz", + "integrity": "sha1-N+8eCAqP+1XC9BZPU28ZGeeWiu4=", + "requires": { + "is-bluebird": "1.0.2", + "shimmer": "1.2.0" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" - }, - "co-body": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/co-body/-/co-body-5.1.1.tgz", - "integrity": "sha1-2XeB0eM0S6SoIP0YBr3fg0FQUjY=", - "requires": { - "inflation": "2.0.0", - "qs": "6.5.1", - "raw-body": "2.3.2", - "type-is": "1.6.15" - } + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true }, "color-convert": { "version": "1.9.1", @@ -296,25 +291,6 @@ "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", "dev": true }, - "content-disposition": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", - "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" - }, - "content-type": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" - }, - "cookies": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/cookies/-/cookies-0.7.1.tgz", - "integrity": "sha1-fIphX1SBxhq58WyDNzG8uPZjuZs=", - "requires": { - "depd": "1.1.1", - "keygrip": "1.0.2" - } - }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -340,11 +316,6 @@ "ms": "2.0.0" } }, - "deep-equal": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.0.1.tgz", - "integrity": "sha1-9dJgKStmDghO/0zbyfCK0yR0SLU=" - }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", @@ -366,21 +337,11 @@ "rimraf": "2.6.2" } }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=" - }, "depd": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" }, - "destroy": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", - "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" - }, "doctrine": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.0.2.tgz", @@ -396,10 +357,10 @@ "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=", "dev": true }, - "ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + "dottie": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dottie/-/dottie-2.0.0.tgz", + "integrity": "sha1-2hkZgci41xPKARXViYzzl8Lw3dA=" }, "encoding": { "version": "0.1.12", @@ -418,16 +379,6 @@ "is-arrayish": "0.2.1" } }, - "error-inject": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/error-inject/-/error-inject-1.0.0.tgz", - "integrity": "sha1-4rPZG1Su1nLzCdlQ0VSFD6EdTzc=" - }, - "escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" - }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -725,16 +676,6 @@ "write": "0.2.1" } }, - "formidable": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.1.1.tgz", - "integrity": "sha1-lriIb3w8NQi5Mta9cMTTqI818ak=" - }, - "fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" - }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -753,6 +694,11 @@ "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, + "generic-pool": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.2.0.tgz", + "integrity": "sha512-JjcXDHT84icN/kFaF5+rNd1trZsgJFVqTSgM9dv6eayxSIQKMq0ilBJ+5pvf0SgimacMlZEsav4oL+4dUE4E2g==" + }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -823,26 +769,6 @@ "integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg==", "dev": true }, - "http-assert": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/http-assert/-/http-assert-1.3.0.tgz", - "integrity": "sha1-oxpc+IyHPsu1eWkH1NbxMujAHko=", - "requires": { - "deep-equal": "1.0.1", - "http-errors": "1.6.2" - } - }, - "http-errors": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", - "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", - "requires": { - "depd": "1.1.1", - "inherits": "2.0.3", - "setprototypeof": "1.0.3", - "statuses": "1.4.0" - } - }, "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", @@ -860,10 +786,10 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, - "inflation": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/inflation/-/inflation-2.0.0.tgz", - "integrity": "sha1-i0F+R8KPklpFEz2RTKH9OJEH8w8=" + "inflection": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.12.0.tgz", + "integrity": "sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=" }, "inflight": { "version": "1.0.6", @@ -878,7 +804,8 @@ "inherits": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true }, "inquirer": { "version": "3.3.0", @@ -908,6 +835,11 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-bluebird": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bluebird/-/is-bluebird-1.0.2.tgz", + "integrity": "sha1-CWQ5Bg9KpBGr7hkUOoTWpVNG1uI=" + }, "is-builtin-module": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", @@ -923,11 +855,6 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, - "is-generator-function": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.6.tgz", - "integrity": "sha1-nnFlPNFf/zQcecQVFGChMdMen8Q=" - }, "is-path-cwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", @@ -1012,80 +939,6 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "keygrip": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/keygrip/-/keygrip-1.0.2.tgz", - "integrity": "sha1-rTKXxVcGneqLz+ek+kkbdcXd65E=" - }, - "koa": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/koa/-/koa-2.4.1.tgz", - "integrity": "sha512-3caQ9OyLDYSL3wAhVfv2s9k3tLNgW18QxnKIPaRjzG9uXyDhp4tOo+U+XtbY+xbzEiCW5smjxMCegpZqCjmjMw==", - "requires": { - "accepts": "1.3.4", - "content-disposition": "0.5.2", - "content-type": "1.0.4", - "cookies": "0.7.1", - "debug": "3.1.0", - "delegates": "1.0.0", - "depd": "1.1.1", - "destroy": "1.0.4", - "error-inject": "1.0.0", - "escape-html": "1.0.3", - "fresh": "0.5.2", - "http-assert": "1.3.0", - "http-errors": "1.6.2", - "is-generator-function": "1.0.6", - "koa-compose": "4.0.0", - "koa-convert": "1.2.0", - "koa-is-json": "1.0.0", - "mime-types": "2.1.17", - "on-finished": "2.3.0", - "only": "0.0.2", - "parseurl": "1.3.2", - "statuses": "1.4.0", - "type-is": "1.6.15", - "vary": "1.1.2" - } - }, - "koa-body": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/koa-body/-/koa-body-2.5.0.tgz", - "integrity": "sha1-hOj82NUimozBy5ipJuk5Bp5xaRU=", - "requires": { - "co-body": "5.1.1", - "formidable": "1.1.1" - } - }, - "koa-compose": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-4.0.0.tgz", - "integrity": "sha1-KAClE9nDYe8NY4UrA45Pby1adzw=" - }, - "koa-convert": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/koa-convert/-/koa-convert-1.2.0.tgz", - "integrity": "sha1-2kCHXfSd4FOQmNFwC1CCDOvNIdA=", - "requires": { - "co": "4.6.0", - "koa-compose": "3.2.1" - }, - "dependencies": { - "koa-compose": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/koa-compose/-/koa-compose-3.2.1.tgz", - "integrity": "sha1-qFzLQLfZhtjlo0Wzoazo6rz1Tec=", - "requires": { - "any-promise": "1.3.0" - } - } - } - }, - "koa-is-json": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/koa-is-json/-/koa-is-json-1.0.0.tgz", - "integrity": "sha1-JzwH7c3Ljfaiwat9We52SRRR7BQ=" - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -1129,8 +982,7 @@ "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", - "dev": true + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, "lodash.cond": { "version": "4.5.2", @@ -1148,24 +1000,6 @@ "yallist": "2.1.2" } }, - "media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" - }, - "mime-db": { - "version": "1.30.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", - "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" - }, - "mime-types": { - "version": "2.1.17", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", - "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", - "requires": { - "mime-db": "1.30.0" - } - }, "mimic-fn": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz", @@ -1196,6 +1030,19 @@ "minimist": "0.0.8" } }, + "moment": { + "version": "2.19.4", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.19.4.tgz", + "integrity": "sha512-1xFTAknSLfc47DIxHDUbnJWC+UwgWxATmymaxIPQpmMh7LBm7ZbwVEsuushqwL2GYZU0jie4xO+TK44hJPjNSQ==" + }, + "moment-timezone": { + "version": "0.5.14", + "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.14.tgz", + "integrity": "sha1-TrOP+VOLgBCLpGekWPPtQmjM/LE=", + "requires": { + "moment": "2.19.4" + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1207,17 +1054,17 @@ "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", "dev": true }, + "nan": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.7.0.tgz", + "integrity": "sha1-2Vv3IeyHfgjbJ27T/G63j5CDrUY=" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, - "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" - }, "node-fetch": { "version": "1.7.3", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.3.tgz", @@ -1245,14 +1092,6 @@ "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, - "on-finished": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", - "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", - "requires": { - "ee-first": "1.1.1" - } - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1271,11 +1110,6 @@ "mimic-fn": "1.1.0" } }, - "only": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/only/-/only-0.0.2.tgz", - "integrity": "sha1-Kv3oTQPlC5qO3EROMGEKcCle37Q=" - }, "optionator": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", @@ -1320,11 +1154,6 @@ "error-ex": "1.3.1" } }, - "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" - }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", @@ -1421,22 +1250,6 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, - "qs": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", - "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" - }, - "raw-body": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", - "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", - "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.2", - "iconv-lite": "0.4.19", - "unpipe": "1.0.0" - } - }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -1519,6 +1332,25 @@ "signal-exit": "3.0.2" } }, + "retry-as-promised": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-2.3.2.tgz", + "integrity": "sha1-zZdO5P2bX+A8vzGHHuSCIcB3N7c=", + "requires": { + "bluebird": "3.5.1", + "debug": "2.6.9" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, "rimraf": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", @@ -1576,13 +1408,31 @@ "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", - "dev": true + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" }, - "setprototypeof": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", - "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + "sequelize": { + "version": "4.28.0", + "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-4.28.0.tgz", + "integrity": "sha512-ni4hAHR7zz4v7rCUtBk2f0sbYCX0mnavsvIna91kDSGVxbP29vGQpVwUg0hj5hzZvpzysK+5NzC+aIcALXU8Wg==", + "requires": { + "bluebird": "3.5.1", + "cls-bluebird": "2.1.0", + "debug": "3.1.0", + "depd": "1.1.1", + "dottie": "2.0.0", + "generic-pool": "3.2.0", + "inflection": "1.12.0", + "lodash": "4.17.4", + "moment": "2.19.4", + "moment-timezone": "0.5.14", + "retry-as-promised": "2.3.2", + "semver": "5.4.1", + "terraformer-wkt-parser": "1.1.2", + "toposort-class": "1.0.1", + "uuid": "3.1.0", + "validator": "9.2.0", + "wkx": "0.4.2" + } }, "shebang-command": { "version": "1.2.0", @@ -1599,6 +1449,11 @@ "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", "dev": true }, + "shimmer": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shimmer/-/shimmer-1.2.0.tgz", + "integrity": "sha512-xTCx2vohXC2EWWDqY/zb4+5Mu28D+HYNSOuFzsyRDRvI/e1ICb69afwaUwfjr+25ZXldbOLyp+iDUZHq8UnTag==" + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -1641,10 +1496,717 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + "sqlite3": { + "version": "3.1.13", + "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-3.1.13.tgz", + "integrity": "sha512-JxXKPJnkZ6NuHRojq+g2WXWBt3M1G9sjZaYiHEWSTGijDM3cwju/0T2XbWqMXFmPqDgw+iB7zKQvnns4bvzXlw==", + "requires": { + "nan": "2.7.0", + "node-pre-gyp": "0.6.38" + }, + "dependencies": { + "abbrev": { + "version": "1.1.1", + "bundled": true + }, + "ajv": { + "version": "4.11.8", + "bundled": true, + "requires": { + "co": "4.6.0", + "json-stable-stringify": "1.0.1" + } + }, + "ansi-regex": { + "version": "2.1.1", + "bundled": true + }, + "aproba": { + "version": "1.2.0", + "bundled": true + }, + "are-we-there-yet": { + "version": "1.1.4", + "bundled": true, + "requires": { + "delegates": "1.0.0", + "readable-stream": "2.3.3" + } + }, + "asn1": { + "version": "0.2.3", + "bundled": true + }, + "assert-plus": { + "version": "0.2.0", + "bundled": true + }, + "asynckit": { + "version": "0.4.0", + "bundled": true + }, + "aws-sign2": { + "version": "0.6.0", + "bundled": true + }, + "aws4": { + "version": "1.6.0", + "bundled": true + }, + "balanced-match": { + "version": "1.0.0", + "bundled": true + }, + "bcrypt-pbkdf": { + "version": "1.0.1", + "bundled": true, + "optional": true, + "requires": { + "tweetnacl": "0.14.5" + } + }, + "block-stream": { + "version": "0.0.9", + "bundled": true, + "requires": { + "inherits": "2.0.3" + } + }, + "boom": { + "version": "2.10.1", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "brace-expansion": { + "version": "1.1.8", + "bundled": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "caseless": { + "version": "0.12.0", + "bundled": true + }, + "co": { + "version": "4.6.0", + "bundled": true + }, + "code-point-at": { + "version": "1.1.0", + "bundled": true + }, + "combined-stream": { + "version": "1.0.5", + "bundled": true, + "requires": { + "delayed-stream": "1.0.0" + } + }, + "concat-map": { + "version": "0.0.1", + "bundled": true + }, + "console-control-strings": { + "version": "1.1.0", + "bundled": true + }, + "core-util-is": { + "version": "1.0.2", + "bundled": true + }, + "cryptiles": { + "version": "2.0.5", + "bundled": true, + "requires": { + "boom": "2.10.1" + } + }, + "dashdash": { + "version": "1.14.1", + "bundled": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "debug": { + "version": "2.6.9", + "bundled": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-extend": { + "version": "0.4.2", + "bundled": true + }, + "delayed-stream": { + "version": "1.0.0", + "bundled": true + }, + "delegates": { + "version": "1.0.0", + "bundled": true + }, + "ecc-jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true, + "requires": { + "jsbn": "0.1.1" + } + }, + "extend": { + "version": "3.0.1", + "bundled": true + }, + "extsprintf": { + "version": "1.3.0", + "bundled": true + }, + "forever-agent": { + "version": "0.6.1", + "bundled": true + }, + "form-data": { + "version": "2.1.4", + "bundled": true, + "requires": { + "asynckit": "0.4.0", + "combined-stream": "1.0.5", + "mime-types": "2.1.17" + } + }, + "fs.realpath": { + "version": "1.0.0", + "bundled": true + }, + "fstream": { + "version": "1.0.11", + "bundled": true, + "requires": { + "graceful-fs": "4.1.11", + "inherits": "2.0.3", + "mkdirp": "0.5.1", + "rimraf": "2.6.2" + } + }, + "fstream-ignore": { + "version": "1.0.5", + "bundled": true, + "requires": { + "fstream": "1.0.11", + "inherits": "2.0.3", + "minimatch": "3.0.4" + } + }, + "gauge": { + "version": "2.7.4", + "bundled": true, + "requires": { + "aproba": "1.2.0", + "console-control-strings": "1.1.0", + "has-unicode": "2.0.1", + "object-assign": "4.1.1", + "signal-exit": "3.0.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wide-align": "1.1.2" + } + }, + "getpass": { + "version": "0.1.7", + "bundled": true, + "requires": { + "assert-plus": "1.0.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "glob": { + "version": "7.1.2", + "bundled": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "graceful-fs": { + "version": "4.1.11", + "bundled": true + }, + "har-schema": { + "version": "1.0.5", + "bundled": true + }, + "har-validator": { + "version": "4.2.1", + "bundled": true, + "requires": { + "ajv": "4.11.8", + "har-schema": "1.0.5" + } + }, + "has-unicode": { + "version": "2.0.1", + "bundled": true + }, + "hawk": { + "version": "3.1.3", + "bundled": true, + "requires": { + "boom": "2.10.1", + "cryptiles": "2.0.5", + "hoek": "2.16.3", + "sntp": "1.0.9" + } + }, + "hoek": { + "version": "2.16.3", + "bundled": true + }, + "http-signature": { + "version": "1.1.1", + "bundled": true, + "requires": { + "assert-plus": "0.2.0", + "jsprim": "1.4.1", + "sshpk": "1.13.1" + } + }, + "inflight": { + "version": "1.0.6", + "bundled": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "bundled": true + }, + "ini": { + "version": "1.3.4", + "bundled": true + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "bundled": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-typedarray": { + "version": "1.0.0", + "bundled": true + }, + "isarray": { + "version": "1.0.0", + "bundled": true + }, + "isstream": { + "version": "0.1.2", + "bundled": true + }, + "jsbn": { + "version": "0.1.1", + "bundled": true, + "optional": true + }, + "json-schema": { + "version": "0.2.3", + "bundled": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "bundled": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "bundled": true + }, + "jsonify": { + "version": "0.0.0", + "bundled": true + }, + "jsprim": { + "version": "1.4.1", + "bundled": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "mime-db": { + "version": "1.30.0", + "bundled": true + }, + "mime-types": { + "version": "2.1.17", + "bundled": true, + "requires": { + "mime-db": "1.30.0" + } + }, + "minimatch": { + "version": "3.0.4", + "bundled": true, + "requires": { + "brace-expansion": "1.1.8" + } + }, + "minimist": { + "version": "0.0.8", + "bundled": true + }, + "mkdirp": { + "version": "0.5.1", + "bundled": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "bundled": true + }, + "node-pre-gyp": { + "version": "0.6.38", + "bundled": true, + "requires": { + "hawk": "3.1.3", + "mkdirp": "0.5.1", + "nopt": "4.0.1", + "npmlog": "4.1.2", + "rc": "1.2.1", + "request": "2.81.0", + "rimraf": "2.6.2", + "semver": "5.4.1", + "tar": "2.2.1", + "tar-pack": "3.4.0" + } + }, + "nopt": { + "version": "4.0.1", + "bundled": true, + "requires": { + "abbrev": "1.1.1", + "osenv": "0.1.4" + } + }, + "npmlog": { + "version": "4.1.2", + "bundled": true, + "requires": { + "are-we-there-yet": "1.1.4", + "console-control-strings": "1.1.0", + "gauge": "2.7.4", + "set-blocking": "2.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "bundled": true + }, + "oauth-sign": { + "version": "0.8.2", + "bundled": true + }, + "object-assign": { + "version": "4.1.1", + "bundled": true + }, + "once": { + "version": "1.4.0", + "bundled": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "os-homedir": { + "version": "1.0.2", + "bundled": true + }, + "os-tmpdir": { + "version": "1.0.2", + "bundled": true + }, + "osenv": { + "version": "0.1.4", + "bundled": true, + "requires": { + "os-homedir": "1.0.2", + "os-tmpdir": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "bundled": true + }, + "performance-now": { + "version": "0.2.0", + "bundled": true + }, + "process-nextick-args": { + "version": "1.0.7", + "bundled": true + }, + "punycode": { + "version": "1.4.1", + "bundled": true + }, + "qs": { + "version": "6.4.0", + "bundled": true + }, + "rc": { + "version": "1.2.1", + "bundled": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.4", + "minimist": "1.2.0", + "strip-json-comments": "2.0.1" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "bundled": true + } + } + }, + "readable-stream": { + "version": "2.3.3", + "bundled": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "1.0.7", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "request": { + "version": "2.81.0", + "bundled": true, + "requires": { + "aws-sign2": "0.6.0", + "aws4": "1.6.0", + "caseless": "0.12.0", + "combined-stream": "1.0.5", + "extend": "3.0.1", + "forever-agent": "0.6.1", + "form-data": "2.1.4", + "har-validator": "4.2.1", + "hawk": "3.1.3", + "http-signature": "1.1.1", + "is-typedarray": "1.0.0", + "isstream": "0.1.2", + "json-stringify-safe": "5.0.1", + "mime-types": "2.1.17", + "oauth-sign": "0.8.2", + "performance-now": "0.2.0", + "qs": "6.4.0", + "safe-buffer": "5.1.1", + "stringstream": "0.0.5", + "tough-cookie": "2.3.3", + "tunnel-agent": "0.6.0", + "uuid": "3.1.0" + } + }, + "rimraf": { + "version": "2.6.2", + "bundled": true, + "requires": { + "glob": "7.1.2" + } + }, + "safe-buffer": { + "version": "5.1.1", + "bundled": true + }, + "semver": { + "version": "5.4.1", + "bundled": true + }, + "set-blocking": { + "version": "2.0.0", + "bundled": true + }, + "signal-exit": { + "version": "3.0.2", + "bundled": true + }, + "sntp": { + "version": "1.0.9", + "bundled": true, + "requires": { + "hoek": "2.16.3" + } + }, + "sshpk": { + "version": "1.13.1", + "bundled": true, + "requires": { + "asn1": "0.2.3", + "assert-plus": "1.0.0", + "bcrypt-pbkdf": "1.0.1", + "dashdash": "1.14.1", + "ecc-jsbn": "0.1.1", + "getpass": "0.1.7", + "jsbn": "0.1.1", + "tweetnacl": "0.14.5" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "string-width": { + "version": "1.0.2", + "bundled": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string_decoder": { + "version": "1.0.3", + "bundled": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "stringstream": { + "version": "0.0.5", + "bundled": true + }, + "strip-ansi": { + "version": "3.0.1", + "bundled": true, + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-json-comments": { + "version": "2.0.1", + "bundled": true + }, + "tar": { + "version": "2.2.1", + "bundled": true, + "requires": { + "block-stream": "0.0.9", + "fstream": "1.0.11", + "inherits": "2.0.3" + } + }, + "tar-pack": { + "version": "3.4.0", + "bundled": true, + "requires": { + "debug": "2.6.9", + "fstream": "1.0.11", + "fstream-ignore": "1.0.5", + "once": "1.4.0", + "readable-stream": "2.3.3", + "rimraf": "2.6.2", + "tar": "2.2.1", + "uid-number": "0.0.6" + } + }, + "tough-cookie": { + "version": "2.3.3", + "bundled": true, + "requires": { + "punycode": "1.4.1" + } + }, + "tunnel-agent": { + "version": "0.6.0", + "bundled": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "tweetnacl": { + "version": "0.14.5", + "bundled": true, + "optional": true + }, + "uid-number": { + "version": "0.0.6", + "bundled": true + }, + "util-deprecate": { + "version": "1.0.2", + "bundled": true + }, + "uuid": { + "version": "3.1.0", + "bundled": true + }, + "verror": { + "version": "1.10.0", + "bundled": true, + "requires": { + "assert-plus": "1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "1.3.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "bundled": true + } + } + }, + "wide-align": { + "version": "1.1.2", + "bundled": true, + "requires": { + "string-width": "1.0.2" + } + }, + "wrappy": { + "version": "1.0.2", + "bundled": true + } + } }, "string-width": { "version": "2.1.1", @@ -1734,6 +2296,22 @@ } } }, + "terraformer": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/terraformer/-/terraformer-1.0.8.tgz", + "integrity": "sha1-UeCtiXRvzyFh3G9lqnDkI3fItZM=", + "requires": { + "@types/geojson": "1.0.6" + } + }, + "terraformer-wkt-parser": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/terraformer-wkt-parser/-/terraformer-wkt-parser-1.1.2.tgz", + "integrity": "sha1-M2oMj8gglKWv+DKI9prt7NNpvww=", + "requires": { + "terraformer": "1.0.8" + } + }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", @@ -1755,6 +2333,11 @@ "os-tmpdir": "1.0.2" } }, + "toposort-class": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toposort-class/-/toposort-class-1.0.1.tgz", + "integrity": "sha1-f/0feMi+KMO6Rc1OGj9e4ZO9mYg=" + }, "tryit": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", @@ -1770,32 +2353,23 @@ "prelude-ls": "1.1.2" } }, - "type-is": { - "version": "1.6.15", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", - "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", - "requires": { - "media-typer": "0.3.0", - "mime-types": "2.1.17" - } - }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, - "unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" - }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==" + }, "validate-npm-package-license": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz", @@ -1806,10 +2380,10 @@ "spdx-expression-parse": "1.0.4" } }, - "vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + "validator": { + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/validator/-/validator-9.2.0.tgz", + "integrity": "sha512-6Ij4Eo0KM4LkR0d0IegOwluG5453uqT5QyF5SV5Ezvm8/zmkKI/L4eoraafZGlZPC9guLkwKzgypcw8VGWWnGA==" }, "which": { "version": "1.3.0", @@ -1820,6 +2394,14 @@ "isexe": "2.0.0" } }, + "wkx": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.4.2.tgz", + "integrity": "sha1-d201pjSlwi5lbkdEvetU+D/Szo0=", + "requires": { + "@types/node": "8.0.57" + } + }, "wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", diff --git a/package.json b/package.json index 22a79f9..ace901c 100644 --- a/package.json +++ b/package.json @@ -18,13 +18,15 @@ }, "homepage": "https://github.com/wsknorth/midnabot#readme", "dependencies": { + "dotenv": "^4.0.0", "roll": "^1.2.0", "sandbox": "^0.8.6", + "sequelize": "^4.28.0", + "sqlite3": "^3.1.13", "telegraf": "^3.17.0" }, "devDependencies": { "debug": "^3.1.0", - "dotenv": "^4.0.0", "eslint": "^4.12.1", "eslint-config-standard": "^10.2.1", "eslint-plugin-import": "^2.8.0", From 6d77847ac7166e846d9ebd9895544111c20293e6 Mon Sep 17 00:00:00 2001 From: wsknorth Date: Mon, 11 Dec 2017 19:35:38 +0100 Subject: [PATCH 2/4] structure refactoring --- index.js | 15 ++++----------- lib/{ => commands}/about/index.js | 2 +- lib/commands/index.js | 7 +++++++ lib/{ => commands}/roll/index.js | 0 lib/{ => commands}/sandbox/index.js | 0 lib/{ => commands}/start/index.js | 2 +- lib/{ => commands}/stop/index.js | 2 +- lib/{ => middlewares}/after/index.js | 2 +- lib/middlewares/index.js | 5 +++++ lib/{ => middlewares}/request/index.js | 0 lib/{ => middlewares}/response/index.js | 0 lib/models/index.js | 3 +++ lib/{ => models}/starts/index.js | 2 +- lib/modules/configs/configs.json | 12 ++++++++++++ lib/{ => modules}/configs/configs.sample.json | 0 lib/{ => modules}/configs/index.js | 0 lib/modules/index.js | 4 ++++ lib/{ => modules}/sequelize/index.js | 0 18 files changed, 40 insertions(+), 16 deletions(-) rename lib/{ => commands}/about/index.js (70%) create mode 100644 lib/commands/index.js rename lib/{ => commands}/roll/index.js (100%) rename lib/{ => commands}/sandbox/index.js (100%) rename lib/{ => commands}/start/index.js (92%) rename lib/{ => commands}/stop/index.js (92%) rename lib/{ => middlewares}/after/index.js (88%) create mode 100644 lib/middlewares/index.js rename lib/{ => middlewares}/request/index.js (100%) rename lib/{ => middlewares}/response/index.js (100%) create mode 100644 lib/models/index.js rename lib/{ => models}/starts/index.js (74%) create mode 100644 lib/modules/configs/configs.json rename lib/{ => modules}/configs/configs.sample.json (100%) rename lib/{ => modules}/configs/index.js (100%) create mode 100644 lib/modules/index.js rename lib/{ => modules}/sequelize/index.js (100%) diff --git a/index.js b/index.js index 497f972..800b19a 100644 --- a/index.js +++ b/index.js @@ -3,19 +3,12 @@ const debug = require('debug')('midnabot') const Telegraf = require('telegraf') -const { sequelize } = require('./lib/sequelize') -const { configs } = require('./lib/configs') -const { request } = require('./lib/request') -const { response } = require('./lib/response') -const { start } = require('./lib/start') -const { after } = require('./lib/after') -const { sandbox } = require('./lib/sandbox') -const { roll } = require('./lib/roll') -const { about } = require('./lib/about') -const { stop } = require('./lib/stop') +const { configs, sequelize } = require('./lib/modules') +const { request, response, after } = require('./lib/middlewares') +const { start, sandbox, roll, about, stop } = require('./lib/commands') const bot = new Telegraf(configs.token, { username: configs.username }) -sequelize.sync().then(() => debug(`sQlite connected`)) +sequelize.sync().then(() => debug(`Database connected`)) bot.use(request()) bot.use(response()) diff --git a/lib/about/index.js b/lib/commands/about/index.js similarity index 70% rename from lib/about/index.js rename to lib/commands/about/index.js index 70cbafc..36da630 100644 --- a/lib/about/index.js +++ b/lib/commands/about/index.js @@ -1,4 +1,4 @@ -const { name, version, author, homepage } = require('../../package.json') +const { name, version, author, homepage } = require('../../../package.json') const about = () => (ctx) => { const message = `*${name} ${version}*\n${author}\n${homepage}` diff --git a/lib/commands/index.js b/lib/commands/index.js new file mode 100644 index 0000000..959b821 --- /dev/null +++ b/lib/commands/index.js @@ -0,0 +1,7 @@ +const { start } = require('./start') +const { sandbox } = require('./sandbox') +const { roll } = require('./roll') +const { about } = require('./about') +const { stop } = require('./stop') + +module.exports = { start, sandbox, roll, about, stop } diff --git a/lib/roll/index.js b/lib/commands/roll/index.js similarity index 100% rename from lib/roll/index.js rename to lib/commands/roll/index.js diff --git a/lib/sandbox/index.js b/lib/commands/sandbox/index.js similarity index 100% rename from lib/sandbox/index.js rename to lib/commands/sandbox/index.js diff --git a/lib/start/index.js b/lib/commands/start/index.js similarity index 92% rename from lib/start/index.js rename to lib/commands/start/index.js index 5cbb69e..8687986 100644 --- a/lib/start/index.js +++ b/lib/commands/start/index.js @@ -1,6 +1,6 @@ const debug = require('debug')('midnabot:start') -const { Starts } = require('../starts') +const { Starts } = require('../../models/starts') const start = () => (ctx) => { const name = (ctx.update.message.chat.type === 'private') diff --git a/lib/stop/index.js b/lib/commands/stop/index.js similarity index 92% rename from lib/stop/index.js rename to lib/commands/stop/index.js index 5e301ba..182aa9c 100644 --- a/lib/stop/index.js +++ b/lib/commands/stop/index.js @@ -1,6 +1,6 @@ const debug = require('debug')('midnabot:stop') -const { Starts } = require('../starts') +const { Starts } = require('../../models/starts') const stop = () => (ctx) => { const name = (ctx.update.message.chat.type === 'private') diff --git a/lib/after/index.js b/lib/middlewares/after/index.js similarity index 88% rename from lib/after/index.js rename to lib/middlewares/after/index.js index 8188fd8..faa56b3 100644 --- a/lib/after/index.js +++ b/lib/middlewares/after/index.js @@ -1,6 +1,6 @@ const debug = require('debug')('midnabot:after') -const { Starts } = require('../starts') +const { Starts } = require('../../models/starts') const after = () => (ctx, next) => { const name = (ctx.update.message.chat.type === 'private') diff --git a/lib/middlewares/index.js b/lib/middlewares/index.js new file mode 100644 index 0000000..11d7660 --- /dev/null +++ b/lib/middlewares/index.js @@ -0,0 +1,5 @@ +const { request } = require('./request') +const { response } = require('./response') +const { after } = require('./after') + +module.exports = { request, response, after } diff --git a/lib/request/index.js b/lib/middlewares/request/index.js similarity index 100% rename from lib/request/index.js rename to lib/middlewares/request/index.js diff --git a/lib/response/index.js b/lib/middlewares/response/index.js similarity index 100% rename from lib/response/index.js rename to lib/middlewares/response/index.js diff --git a/lib/models/index.js b/lib/models/index.js new file mode 100644 index 0000000..934f7b1 --- /dev/null +++ b/lib/models/index.js @@ -0,0 +1,3 @@ +const { Starts } = require('./starts') + +module.exports = { Starts } diff --git a/lib/starts/index.js b/lib/models/starts/index.js similarity index 74% rename from lib/starts/index.js rename to lib/models/starts/index.js index 8e9797b..bf0b33b 100644 --- a/lib/starts/index.js +++ b/lib/models/starts/index.js @@ -1,4 +1,4 @@ -const { Sequelize, sequelize } = require('../sequelize') +const { Sequelize, sequelize } = require('../../modules/sequelize') const Starts = sequelize.define('starts', { name: { type: Sequelize.STRING, allowNull: false, unique: true }, diff --git a/lib/modules/configs/configs.json b/lib/modules/configs/configs.json new file mode 100644 index 0000000..934d1de --- /dev/null +++ b/lib/modules/configs/configs.json @@ -0,0 +1,12 @@ +{ + "development": { + "username": "midnadevbot", + "token": "488808043:AAEnrG_7_jtm6k2eJm_zHHhV67Yaqxflje4" + }, + "production": { + "username": "midnabot", + "token": "426124500:AAHyqS64s1TEZjwMQbMFEeE7NxC8bl5CDgk", + "webhook": "https://wsknorth.io/midnabot", + "port": 4000 + } +} diff --git a/lib/configs/configs.sample.json b/lib/modules/configs/configs.sample.json similarity index 100% rename from lib/configs/configs.sample.json rename to lib/modules/configs/configs.sample.json diff --git a/lib/configs/index.js b/lib/modules/configs/index.js similarity index 100% rename from lib/configs/index.js rename to lib/modules/configs/index.js diff --git a/lib/modules/index.js b/lib/modules/index.js new file mode 100644 index 0000000..e7042d5 --- /dev/null +++ b/lib/modules/index.js @@ -0,0 +1,4 @@ +const { configs } = require('./configs') +const { sequelize } = require('./sequelize') + +module.exports = { configs, sequelize } diff --git a/lib/sequelize/index.js b/lib/modules/sequelize/index.js similarity index 100% rename from lib/sequelize/index.js rename to lib/modules/sequelize/index.js From 5653d3359933c4c6ce8a4656514ca84bbdc473ec Mon Sep 17 00:00:00 2001 From: wsknorth Date: Tue, 12 Dec 2017 06:05:18 +0100 Subject: [PATCH 3/4] Resolve #18 --- docs/Readme.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/Readme.md b/docs/Readme.md index 8b8b395..eb02690 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -17,11 +17,17 @@ ## Commands -### About +### Start ``` -/about +/start ``` -Show information about midnabot +Enable bot + +### Stop +``` +/stop +``` +Disable bot ### Sandbox ``` @@ -36,3 +42,9 @@ The `/sandbox` command use [gf3/sandbox](https://github.com/gf3/sandbox) to work ``` Roll dices. The `/roll` command use [troygoode/node-roll](https://github.com/troygoode/node-roll) to work. + +### About +``` +/about +``` +Show information about midnabot From 46744cd7aa58c66a8a9173fa9f8f85eb11479454 Mon Sep 17 00:00:00 2001 From: wsknorth Date: Tue, 12 Dec 2017 06:06:59 +0100 Subject: [PATCH 4/4] Resolve #16 --- docs/Readme.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Readme.md b/docs/Readme.md index eb02690..44775d0 100644 --- a/docs/Readme.md +++ b/docs/Readme.md @@ -4,7 +4,7 @@

Standard - Version + Version License Telegram Donate diff --git a/package.json b/package.json index ace901c..39f907c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "midnabot", - "version": "0.1.5", + "version": "0.2.0", "description": "midnabot for telegram", "main": "index.js", "scripts": {