VK Group Stats, v1.0.0, alpha 2
Posted on

Service for a collecting of a VK groups stats.
Second alpha of a major release. Add the client, implement the group UI.
Change Log
- correct npm scripts:
- add an installation;
- add a client building;
- add a hot reloading:
- for the server;
- for the client;
- back-end:
- change a default server port to 4000;
- correct routes:
- add the
/users/meroute; - remove the
/loginroute;
- add the
- support a skipping of an authentication;
- front-end:
- use Redux DevTools;
- add a group list displaying;
- add a group adding;
- add a group removing.
Features
- back-end:
- authentication:
- an authentication via VK;
- support of a skipping of an authentication;
- users:
- data:
- MongoDB ObjectId;
- VK ID;
- operations:
- getting of a current user;
- automatically addition on an authentication;
- support of a fake user on a skipping of an authentication;
- data:
- groups:
- data:
- MongoDB ObjectId;
- user ObjectId;
- VK screen name;
- operations (for a current user):
- getting of all;
- addition of one;
- deletion of one;
- data:
- counters:
- data:
- MongoDB ObjectId;
- group ObjectId;
- addition timestamp;
- group members counter;
- operations (for a specified group):
- getting of all in a descending order;
- getting of all in a descending order beginning with a specified timestamp;
- addition of one (automatically via VK API);
- deletion of all;
- data:
- automatically addition of counters via VK API for all added groups by schedule;
- authentication:
- front-end:
- design:
- adaptive;
- material;
- group list:
- displays:
- groups;
- states:
- fetching;
- success;
- failure;
- for every group:
- displays:
- VK screen name;
- states:
- fetching;
- success;
- failure;
- displays:
- displays:
- add group dialog.
- design:
Technologies
- ECMAScript 2015;
- back-end:
- Node.js;
- Express;
- MongoDB;
- front-end:
- Redux;
- React;
- Material-UI.
Usage
In a development:
$ npm start
In a production:
$ npm server-up
Environment variables:
NODE_ENV— the current environment (allowed:production);VK_GROUP_STATS_SERVER_PORT— the server port (default: 4000);VK_GROUP_STATS_MONGODB_HOST— the MongoDB host (default:localhost);VK_GROUP_STATS_MONGODB_DATABASE— the MongoDB database (default:vk-group-stats);VK_GROUP_STATS_MONGODB_PORT— the MongoDB port (default: 27017);VK_GROUP_STATS_SESSION_SECURE— use secure sessions (TRUEto an use);VK_GROUP_STATS_SESSION_SECRET— the sessions secret (default: a random UUID v4);VK_GROUP_STATS_VK_APP_ID— the VK app ID (default: 5878021);VK_GROUP_STATS_VK_APP_SECRET— the VK app secret;VK_GROUP_STATS_VK_APP_CALLBACK— the VK app callback for an authentication (default:http://localhost:4000/authentication/vk/callback);VK_GROUP_STATS_SKIP_AUTHENTICATION— skip an authentication (TRUEto a skip);VK_GROUP_STATS_SCHEDULING— scheduling settings (use the cron utility format; default:0 0 * * *, i.e. once every day).
API
API description in the Swagger format:
swagger: '2.0'
info:
title: vk-group-stats
version: 1.0.0
basePath: /api/v1
schemes:
- http
- https
consumes:
- application/x-www-form-urlencoded
- application/json
produces:
- application/json
paths:
/groups:
get:
responses:
200:
description: OK
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/definitions/group'
required:
- data
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
post:
parameters:
- $ref: '#/parameters/group_form'
responses:
200:
description: OK
schema:
type: object
properties:
data:
$ref: '#/definitions/group'
required:
- data
400:
description: Bad Request
schema:
$ref: '#/definitions/error'
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
/groups/{group_id}:
parameters:
- $ref: '#/parameters/group_id'
delete:
responses:
200:
description: OK
schema:
$ref: '#/definitions/ok'
400:
description: Bad Request
schema:
$ref: '#/definitions/error'
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
/groups/{group_id}/counters:
parameters:
- $ref: '#/parameters/group_id'
get:
parameters:
- $ref: '#/parameters/start_timestamp'
responses:
200:
description: OK
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/definitions/counter'
required:
- data
400:
description: Bad Request
schema:
$ref: '#/definitions/error'
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
post:
responses:
200:
description: OK
schema:
type: object
properties:
data:
$ref: '#/definitions/counter'
required:
- data
400:
description: Bad Request
schema:
$ref: '#/definitions/error'
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
delete:
responses:
200:
description: OK
schema:
$ref: '#/definitions/ok'
400:
description: Bad Request
schema:
$ref: '#/definitions/error'
401:
description: Unauthorized
schema:
$ref: '#/definitions/error'
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
/users/me:
get:
responses:
200:
description: OK
schema:
type: object
properties:
data:
$ref: '#/definitions/user'
required:
- data
500:
description: Internal Server Error
schema:
$ref: '#/definitions/error'
parameters:
group_id:
name: group_id
in: path
required: true
type: string
format: mongodb-objectid
pattern: ^[0-9A-Fa-f]+$
minLength: 24
maxLength: 24
group_form:
name: body
in: body
required: true
schema:
$ref: '#/definitions/group_form'
start_timestamp:
name: start_timestamp
in: query
type: string
format: iso8601-timestamp
pattern: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$
definitions:
group_form:
type: object
properties:
screen_name:
type: string
required:
- screen_name
group:
type: object
properties:
_id:
$ref: '#/definitions/mongodb-objectid'
user_id:
$ref: '#/definitions/mongodb-objectid'
screen_name:
type: string
required:
- _id
- user_id
- screen_name
counter:
type: object
properties:
_id:
$ref: '#/definitions/mongodb-objectid'
group_id:
$ref: '#/definitions/mongodb-objectid'
timestamp:
type: string
description: date and time in ISO 8601 format
pattern: ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z$
value:
type: integer
minimum: 0
required:
- _id
- group_id
- timestamp
- value
user:
type: object
description: may be null
properties:
_id:
$ref: '#/definitions/mongodb-objectid'
vk_id:
type: integer
minimum: 0
required:
- _id
- vk_id
ok:
type: object
properties:
data:
type: boolean
description: always true
required:
- data
error:
type: object
properties:
errors:
type: array
minItems: 1
items:
type: object
properties:
message:
type: string
field:
type: string
required:
- message
required:
- errors
mongodb-objectid:
type: string
pattern: ^[0-9A-Fa-f]+$
minLength: 24
maxLength: 24
Redux state
Redux state in the JSON Schema format:
{
"type": "object",
"properties": {
"groupDialog": {
"type": "object",
"properties": {
"open": {
"type": "boolean"
}
},
"required": [
"open"
]
},
"groups": {
"type": "object",
"properties": {
"state": {
"$ref": "#/definitions/state"
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"state": {
"$ref": "#/definitions/state"
},
"data": {
"$ref": "#/definitions/group"
}
},
"required": [
"state",
"data"
]
}
}
},
"required": [
"state",
"items"
]
}
},
"required": [
"groupDialog",
"groups"
],
"definitions": {
"state": {
"type": "string",
"enum": [
"fetching",
"success",
"failure"
],
"default": "success"
},
"group": {
"type": "object",
"properties": {
"_id": {
"$ref": "#/definitions/mongodb-objectid"
},
"screen_name": {
"type": "string"
}
},
"required": [
"_id",
"screen_name"
]
},
"mongodb-objectid": {
"type": "string",
"pattern": "^[0-9A-Fa-f]+$",
"minLength": 24,
"maxLength": 24
}
}
}
Repository
Link: https://github.com/thewizardplusplus/vk-group-stats/tree/v1.0.0-alpha.2.
Content: code.
License: MIT.
Screenshots
GET /users/me

Fetching state

Failure state

Add group dialog

Main menu
