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
.
In the root directory, run yarn install
.
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).
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
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 sureenv.js
hasGOOGLE_APPLICATION_CREDENTIALS
set to./secrets/[...].json
(override usingdevelopmentRaw
). -
Google OAuth: (development of organizer-facing pages only) Following the instructions here:
- Enable Google+ API from the Console
- Once you have done the above, you should be able to turn on the OAuth Conset screen
- 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
andGOOGLE_CLIENT_SECRET
fields.
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
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.
Set SESSION_SECRET
to a random string of your choice to encrypt sessions.
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
.
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.
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.
To add a new state, you will need to complete the following steps:
- Increment version number and publish a new version of the elections official data.
- Match the version number in the environment variable
ELECTIONS_OFFICIALS_VERSION
- Add the state to
availableStates
andimplementedStates
const arrays incommon
. This should start generating type errors from incomplete switch statements when you runFixing 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.yarn build
Please submit code via pull requests, ideally from this repo if you have access or from your own fork if you do not.
- We strive to only use rebase merges
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).
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.
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
).
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.
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
This repository is for MailMyBallot.org, a National Vote at Home Institute project.