Git Product home page Git Product logo

trustnet-backend's Introduction

Trustnet-Backend

Trustnet-Backend is a Node.js server that uses a MySQL backend. Using this server, you can follow people or news sources with RSS feeds, boost their content to all or specific targets, add your own posts or import articles from external sources, and post your assessments of the accuracy of articles.

Trustnet-Backend considers Trustnet-Client as its client, although it can be configured to use other clients.

Setup Instructions

Install Git and clone this repository

  • git clone https://github.com/farnazj/Trustnet-Backend

Install Node Module Dependencies

cd to the root directory of the project where package.json is. Run:

  • npm install

Database Configurations

Install MySQL Server. Connect to MySQL server using MySQL client and create a database for Trustnet-Backend to connect to. Create a user and grant them privileges on the database.

  • mysql -u root -p (type the root password when prompted)
  • CREATE DATABASE db_name;
  • CREATE USER user_name IDENTIFIED BY 'password';
  • GRANT ALL PRIVILEGES ON db_name.* TO user;
  • FLUSH PRIVILEGES;

โš ๏ธ If in trying to connect to the database, Node throws an authentication error, do the following:

  • ALTER USER user IDENTIFIED WITH MYSQL_NATIVE_PASSWORD BY 'password'

Sequelize Configurations

Trustnet-Backend uses Sequelize as an ORM to connect to the database. The database configurations for Sequelize should be in ./config/database.json. Copy the contents of ./config/example_database.json and change the fields username, password, database, and host for whichever environment you are running Trustnet-Backend in (the default environment is development).

Create OAuth 2.0 Credentials

Trustnet-Backend uses gmail to communicate with users, e.g., for verifying their email address or for password recovery. You will need to set up a project on the Google Developer Console, use it to create OAuth 2.0 API Credentials (client ID and secret), and get a refresh token from the OAuth 2.0 Playground. You can follow this tutorial for setting up the credentials.

Setup Environment Variables

The server uses dotenv to load environment variables from a .env file into process.env.

  • Create a .env file in the root directory of the project (no name before the extension)

  • Place the following variables in the file and assign values to them:

    • ADMIN_KEY=secret (ADMIN_KEY is used for registering RSS feeds of news publishing entities)
    • SESSION_KEY=secret
    • COOKIE_NAME=secret (the name of the sesssion ID cookie that is to be stored in the browser by the client)
    • NODE_ENV (one of 'development', 'test', or 'production'. The default is set to 'development')
    • LOG_LEVEL (refer to Winston's documentation)
    • EMAIL_USER (the email address from which to send account verification and password recovery instructions)
    • EMAIL_CLIENT_ID=ID
    • EMAIL_CLIENT_SECRET=secret
    • EMAIL_REFRESH_TOKEN=token

Redis Server

This Nodejs server stores session ids in a Redis store. In addition, Redis is used for message passing between the processes of the server. You should have Redis installed and running on your machine before launching the server.

Specify the Client

Upon user signup and also for retrieving an account whose password the user has forgotten, this server sends an email containing the full URL of the client path that should confirm activation/password recovery. Therefore, the client base URL needs to be specified in './lib/constants'

Run Trustnet-Backend Server

cd to the root directory of the project. Run:

  • npm start

trustnet-backend's People

Contributors

dependabot[bot] avatar farnazj avatar mcblastoise avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.