Giter Site home page Giter Site logo

robertgz / sdvv-backend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from opensandiego/sdvv-backend

0.0 1.0 0.0 16.71 MB

Backend repository for Voter's Voice website.

License: MIT License

JavaScript 0.27% Procfile 0.03% TypeScript 99.54% Dockerfile 0.16%

sdvv-backend's Introduction

Campaign Finance Transparency Dashboard - backend

Installation

  • Install Docker https://docs.docker.com/get-docker/

  • Fork this repo to your personal GitHub.

  • Use git to clone your fork to your local development environment.

  • Checkout the develop branch

  • Install the dependencies

npm install

Create a .env file in the root of your local repository then copy and paste in the following:

DATABASE_URL=postgres://postgres:example@localhost:54321/postgres
REDIS_URL=redis://:secret@localhost:6379
  • Install the three Docker containers (Postgres, pgAdmin, Redis) using:
docker compose up -d
  • Create the database tables using:
npm run db:migration:run

Load the data into the database

  • Run the worker process. This starts up the queue to wait for tasks. The console for this process will update after each item in the queue is completed.
npm run start:worker:dev
  • Run the console command to add the database initialization tasks to the queue. This command completes immediately. The console running the worker process will update as the queue is processed.
npm run db:initialize:data

The worker process will fetch and add the data to the database. This may take a few minutes. When you see 'Populating Database with Zip Codes by jurisdiction Complete' in the worker console then the update has been complete. The worker process can be stopped after the update is complete.

Run the web part of the backend

npm run start:web:dev

To test the backend server browse to http://localhost:3000/

Deploying to Heroku for development testing

This repo can be deployed to Heroku using a free account but billing will need to be added to the account unless Redis is disabled before deploying.

  1. Open the Heroku website and create a new app.
  2. Add the following Heroku addons to the app:
  • Heroku Postgres
  • Heroku Redis (requires billing)
  1. On your local development computer Install Git, the Heroku CLI, and create a Heroku remote. (see: https://devcenter.heroku.com/articles/git)
  2. Deploy the app to Heroku from the nestjs branch using: git push heroku nestjs:main
  3. Open the Heroku website in a browser and then choose the app from https://dashboard.heroku.com/apps.
  4. Verify that the app is deployed by viewing the logs from the More menu. Also click the Open app button.
  5. Use Run console from the More menu.
  6. First run: npm run typeorm schema:log. This should show something like Schema syncronization will execute following sql queries:
  7. To create the tables in the database run the migrations using the Run console with:
npm run db:migration:run

If there is a need to reverse the migrations use:

npm run db:migration:revert

It is recommended to connect to the Heroku database using pgAdmin to monitor contents of the database.

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.