World Conquest Chronicles

World Conquest Chronicles

VK Group Stats, v1.1.0, alpha

Heroku dashboard

Service for a collecting of a VK groups stats.

Alpha of a release. Support a deploying on Heroku.

Change Log

  • Closed issues:
    • Restore a support of the VK_GROUP_STATS_SESSION_SECRET environment variable #13
    • Generate a VK app redirect URI independently of a server port #10
    • Read a server port from the PORT environment variable too #9
    • Read a MongoDB connection URI from the MONGODB_URI environment variable too #8
    • Correct a caching of builds on Heroku #6
    • Simplify and unify a starting #5
    • Build after an installing on Heroku #4
    • Simplify and unify an installing #3
    • Move build dependencies to production dependencies #2
    • Specify a required Node.js version #1
  • Fixed bugs:
    • Correct exit codes on errors #7

Installation

Install Node.js v6+: https://nodejs.org/en/download/package-manager/

Install MongoDB Community Edition v3.4+: https://docs.mongodb.com/manual/installation/

Clone this repository:

$ git clone https://github.com/thewizardplusplus/vk-group-stats.git
$ cd vk-group-stats

Install dependencies:

$ npm install

Build the project (with the dark theme by default):

$ npm run build

To use the light theme, build the project with the REACT_APP_USE_LIGHT_THEME environment variable set to TRUE:

$ REACT_APP_USE_LIGHT_THEME=TRUE npm run build

Create the VK website app: https://vk.com/dev/first_guide?f=2.+Application+registration

Its authorized redirect URI must be in the format: http[s]://<domain>/authentication/vk/callback.

Set environment variables in the .env.prod file in the project root and rename it to .env:

$ nano .env.prod
$ mv .env.prod .env

Update

Pull updates from the repository:

$ cd vk-group-stats
$ git pull --rebase origin master

Install new dependencies:

$ npm install

Rebuild the project (with the dark theme by default):

$ npm run build

To use the light theme, rebuild the project with the REACT_APP_USE_LIGHT_THEME environment variable set to TRUE:

$ REACT_APP_USE_LIGHT_THEME=TRUE npm run build

Usage

$ npm start

Environment variables:

  • NODE_ENV — the current environment (allowed: production);
  • REACT_APP_USE_LIGHT_THEME — use the light theme (it's accepted only during the build time; TRUE to an use);
  • PORT, VK_GROUP_STATS_SERVER_PORT — the server port (default: 4000);
  • VK_GROUP_STATS_SERVER_URI — the server URI (default: http://localhost[:<port>]/);
  • VK_GROUP_STATS_SESSION_SECRET — the sessions secret (default: a random UUID v4);
  • MONGODB_URI, VK_GROUP_STATS_MONGODB_URI — the MongoDB connection URI (default: mongodb://localhost/vk-group-stats);
  • VK_GROUP_STATS_VK_APP_ID — the VK app ID;
  • VK_GROUP_STATS_VK_APP_SECRET — the VK app secure key;
  • VK_GROUP_STATS_SKIP_AUTHENTICATION — skip an authentication (TRUE to a skip);
  • VK_GROUP_STATS_SCHEDULING — scheduling settings (use the cron utility format; default: 0 0 * * *, i.e. once every day).

Environment variables can be specified in a .env file in the project root in the format:

NAME_1=value_1
NAME_2=value_2
...

See details about the format: https://github.com/motdotla/dotenv#rules

A .env file will never modify any environment variables that have already been set.

Deploy on Heroku

Create a new Heroku personal app: https://dashboard.heroku.com/new?org=personal-apps

Add to it mLab MongoDB add-on: https://elements.heroku.com/addons/mongolab

Install Heroku CLI: https://devcenter.heroku.com/articles/heroku-cli

Login to a Heroku account:

$ heroku login

Clone this repository:

$ git clone https://github.com/thewizardplusplus/vk-group-stats.git
$ cd vk-group-stats

Create a Heroku remote:

$ heroku git:remote -a <heroku-personal-app-name>

Deploy the code:

$ git push heroku master

Set up environment variables for a deployed app:

$ heroku config:set VK_GROUP_STATS_SERVER_URI=<heroku-personal-app-uri>
$ heroku config:set VK_GROUP_STATS_SESSION_SECRET=...
$ heroku config:set VK_GROUP_STATS_VK_APP_ID=...
$ heroku config:set VK_GROUP_STATS_VK_APP_SECRET=...

Repository

Link: https://github.com/thewizardplusplus/vk-group-stats/tree/v1.1.0-alpha.

Content: code.

License: MIT.