Skip to content

A middleware backend server that registers views to my db server when requested to register a view from my other projects.

Notifications You must be signed in to change notification settings

harshankur/viewcounterbackend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is a mini node server that can be used to register user views on websites on a mysql instance.

This is a very simple implementation that I use myself to register views from users that stored country information, timestamp and ip of the user view on a table for the appId.

It also contains provision to validate input data to prevent sql injection.

How to Proceed

  1. Clone this repo and install node modules
# Clone repo
git clone https://github.com/harshankur/viewcounterbackend.git
# Install node modules
npm i
  1. Add dbInfo.json that contains the information for accessing your db inside of the repository like below
{
    "host":     "<hostname>",       // 127.0.0.1 for localhost
    "database": "<db name>",
    "user":     "<db user>",
    "password": "<db password>"
}
  1. Add allowed.json that contains the validation information for registering views as required for your needs. This also saves us from sql injection as the values will be validation before adding to insert statements
{
    "appId": [
        "<app_name_1>",
        "<app_name_2>"
    ],
    "deviceSize": [
        "<device_size_1>",
        "<device_size_2>",
        "<device_size_3>"
    ]
}
  1. Alter the code, dbInfo.json and allowed.json to suit your needs for registering columns into your mysql instance.
  2. Run the server and expose the relevant port
# Start
npm start
# nohup initialization
nohup node index.js > stdout.log &
# Kill nohup
kill <pid_generated_after_running_above_nohup_command>

About

A middleware backend server that registers views to my db server when requested to register a view from my other projects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published