This project is the MVP of backend part of DeviantART Helper.
Tests in this project are not finished due to upcoming refactoring which probably will never happen.
Main repository can be found on BitBucket.
Mirror repository is available on GitHub.
Project uses DeviantART API and requires to have working account there.
Project uses MongoDB as DB storage.
Backend part consists of server and scheduler.
Server serves frontend files and calculates user statistics.
Scheduler uses DeviantART API to update user data such as deviations.
First, npm install
should be ran first to fetch npm modules.
Next, /config/config.json
file should be created. Refer to the config.example.json
and Config section to properly set config.
After this, run npm run build
to prepare build files.
Finally, frontend files should be added to the public
folder.
To run server, use npm start
command. To fetch data automatically, use any
scheduler such as cron for Linux to run script npm run fetch
periodically.
Currently, Helper can do following:
- Display common user info
- Browse user deviations
- Display sum of deviations statistics such as total amount of views, favs, etc. in set period of time.
- Display detailed deviations statistics
- Display how deviations statistics changed by time via charts.
Alias for npm run serve:app
.
Script to convert source files using Babel.
Script to run Babel in watch mode.
Starts server and scheduler using Nodemon.
Starts scheduler using Nodemon.
Added task to scheduler to fetch DeviantART data for every registered user.
Launches the Jest test runner in the interactive watch mode.
See the section about running tests for more information.
Script for Husky to run related tests for staged changes.
Runs Jets test runner in the coverage mode.
Development server can be started by running npm start
script.
To avoid rebuilding source files manually, npm run build:watch
script can be used.
Codestyle is enforced by Eslint.
Unit tests are written with Jest.
Test coverage can be obtained by running npm run coverage
and
then checking console or coverage
folder.
Codestyle and unit tests are checked automatically during commit by Husky.
Example of config file can be found at /config/config.example.json
.
App uses /config/config.json
.
On which part server will run.
Cookie key for security. Should be unique and secret.
For how long static files can be cached in milliseconds.
By default it is 1 day.
Connection string to MongoDB database.
Database name.
OAUTH key required by DeviantART API.
OAUTH secret required by DeviantART API.
String used to encrypt user tokens.
Callback URI required by DeviantART API. Should look like [host]/auth/connect/deviantart/callback
.
Redirect URI required by DeviantART API. Should look like [host]
.
For how many milliseconds access token from DeviantART API is active.
By default it is 50 minutes to avoid problems with calling API when access token is expired.
For how many milliseconds refresh token from DeviantART API is active.
By default it is 80 days to avoid problems with calling API when refresh token is expired.
If set to true
, user cannot request data fetch by themselves to update data manually.
Is false
by default.
How many attempts scheduler can do to retrieve data before throwing an error.
Minimal delay between running scheduler tasks.
Maximal delay between running scheduler tasks.
If last task was a success, delay will be multiplied by this coefficient.
It is necessary to shorten delay if there are no problems with API.
If last task was a failure, delay will be multiplied by this coefficient.
It is necessary to extend delay if requests are occuring too often or API is down.
How many milliseconds should pass to allow user fetch data either way.
By default it is 1 minute to prevent DOSing.
How many milliseconds should pass to allow user fetch data manually.
By default it is 2 minutes to prevent DOSing.
How many deviations can be retrieved by using DeviantART API per task.
Cannot be more than 20.
For how many deviations metadata can be retrieved by using DeviantART API per task.
Cannot be more than 10.
How many deviations can be displayed on same page on Browse Deviations page.
How many deviations can be displayed on same page on Deviations Statistics page.
Interval window for ratelimit.
By default is 1 minute.
How many requests per window are allowed.
Start delay responses after set amount of requests.
By default is 50 requests.
When responses are slowed, how long will be delay between requests.
By default is 1 second.
Which environment is currently used, development
or production
.
To increase performance, indexes to MongoDB can be added.
In example, DB is called dahelper
. Run this in Mongo console:
use dahelper
db.deviations_metadata.createIndex({ "eid": 1, "ts": -1 })