Giter Club home page Giter Club logo

mail-my-ballot's Introduction

MailMyBallot.org

Getting Started

Manual Dependencies

Almost all dependnecies are listed in devDependencies. However, still depends on

  • Install yarn (< 1) globally (npm i -g yarn)
  • Install now globally (npm i -g now).
  • To deploy the server using Google Cloud, follow the steps in https://cloud.google.com/appengine/docs/standard/nodejs/quickstart.

Installation

In the root directory, run yarn install.

Starting the dev server

To start the client and backend dev servers, run

yarn server gulp start // server on localhost:8080
yarn client gulp start // client on localhost:3000

These commands will likely fail until you have setup the configuration correctly (see below).

Configuration

Running the app requires some configuration setting. All of those are exported in env/env.js. It has two dependencies that are not checked into source control:

  • Dev Overrides: env.dev.nogit.js: will generally work out of the box. To run the backend services, you will want to override the existing configuration.

  • Application Secrets: secrets.nogit.json: The secrets can be made empty strings (they must be defined for the server to work). You can set them as you need to

Configuration Details

Below are the settings that need to be set to get an environment to work.

  • Mailgun: You only need these to send emails (last step in signup flow). It's easy to get set up for free.

  • Twilio: You only need these to send faxes (last step in signup flow). It's easy to get set up for free.

  • Incoming fax numbers: To test Twilio, we setup an incoming fax number. (FaxBurner) offers a free temporary one. Set RECEIVE_FAX_NUMBER to this number.

  • Dev Firestore Access: Goto the Firebase Console and generate a new key and place it in packages/server/secrets/[...].json. Then make sure env.js has GOOGLE_APPLICATION_CREDENTIALS set to ./secrets/[...].json (override using developmentRaw).

  • Google OAuth: (development of organizer-facing pages only) Following the instructions here:

    1. Enable Google+ API from the Console
    2. Once you have done the above, you should be able to turn on the OAuth Conset screen
    3. Once you have done the above, you should be able to create OAuth Credentials

    Download and save these credentials for dev, prod, and staging. Thes eare the GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET fields.

Testing Individual services

To experiment with or verify an individual service, you can call the "prototype" files from the command line for the individual services, (e.g.):

yarn server gulp script --script src/service/mg.proto.ts --env development

To find a list of prototype calls, run:

git ls-files | grep proto

Google Maps API

You will have to enable Google Maps geolocation and set GOOGLE_MAPS_API_KEY in order to do the ZIP code to state and address to election official lookups. Instructions here.

Express session secrets

Set SESSION_SECRET to a random string of your choice to encrypt sessions.

Repo Structure

The code is a lerna repo split into three packages:

  • packages/client
  • packages/server
  • packages/common shared code symlinked between above to

Each package has it's own gulpfile.js.

Running tasks

To invoke the grunt file, run commands like

yarn server gulp script --env developement --file src/script/fetchData.ts

The command yarn server gulp and yarn client gulp run their respective gulpfiles. Check out the gulpfiles for more commands.

Checking repo

To check if the repo is working run the following four commands

yarn bootstrap && yarn build && yarn lint && yarn test

Please do this before you submit a PR.

Adding a State

To add a new state, you will need to complete the following steps:

  1. Increment version number and publish a new version of the elections official data.
  2. Match the version number in the environment variable ELECTIONS_OFFICIALS_VERSION
  3. Add the state to availableStates and implementedStates const arrays in common. This should start generating type errors from incomplete switch statements when you run
    yarn build
    Fixing those errors by pattern matching should get you a new state. Becareful to follow the state-by-state regulations for VBM signup. For reference, here are the core commits adding Arizona and New York.

Notes on Submitting Code

Please submit code via pull requests, ideally from this repo if you have access or from your own fork if you do not.

Hosting

The best way to showcase changes to your site is to host your own staging instance. Each instance has its own configuration (e.g. production or staging) and can be edited via the gulpfile via --env production. To add your own, copy and modify the contents the staging object in env/env.js using your own namespace (e.g. your GithubID).

Now (Client Hosting)

The client is hosted by Vercel, which is also called Zeit and Now. If you create and deploy to your own zeit hosting instance and point it to the dev or staging backend instance, you should be able to experiment / show off your own front-end.

App Engine (Server Hosting)

To get started, goto AppEngine Getting Started and follow the prompts.

Don't forget to set indexes. To do this, run the command resulting from

yarn server gulp deploy-index --env [environment]

(see the gulp file server's gulpfile.js).

Secrets in deployed App Engine

Configuration environment variables (and hence secrets) in Google Appengine is through app.yaml. We do not store this in git so that secrets are not exposed. Instead, we store app.tmpl.yaml without secrets and fill in the environment variables in app.yaml dynamically via gulp:

yarn server gulp appsubst --env staging [environment]

This is automatically run as a part of

yarn server gulp deploy --env staging [environment]

Alternative (not used): follow this SO answer, put all secrets in a special file that is not stored in source control.

Web Data

Development

Staging

Production

Resources

Asthetics

Markdown Library

We're using Marked, which has more dependents, downloads, and is smaller than Showdown. The documentation on how to run it in node is available here

Elections Resources

From Vote at Home Insitute

About Us

This repository is for MailMyBallot.org, a National Vote at Home Institute project.

Contributors

mail-my-ballot's People

Contributors

tianhuil avatar marcoacfilho avatar luca409 avatar

Watchers

James Cloos 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.