Betree / opencollective-api

OpenCollective's API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenCollective API

Circle CI Slack Status Dependency Status Coverage Status

How to get started

Note: If you see a step below that could be improved (or is outdated), please update instructions. We rarely go through this process ourselves, so your fresh pair of eyes and your recent experience with it, makes you the best candidate to improve them for other users.

Download the source code

Although this repository only contains the code for the API and the code for the UI is in a separate repository, these instructions will get both running on developer mode. That's why you need to download both codebases under the same directory. Here's an example of how it can be done if you have a git client setup and ready to work:

$ mkdir -p ~/src/github.com/opencollective
$ cd ~/src/github.com/opencollective
$ git clone https://github.com/opencollective/opencollective-api
$ git clone https://github.com/opencollective/frontend

Run the application

Vagrant setup

If you by any chance is a Vagrant user, just run the usual vagrant up within the opencollective-api directory and go to http://localhost:23000/ in your browser.

Docker setup

If you prefer using docker-compose make sure it's installed and working and then execute the following command:

$ docker-compose -f docker/docker-compose.yml up --build

Then you'll be able to access the UI from http://localhost:13000 and the API from the address http://localhost:13060.

Local setup

Requirements

  • A PostgreSQL installation (10.3, 9.6.8, 9.5.12, 9.4.17, 9.3.22 or newer)

Steps

Make sure you have python 2 as your active version. You can use pyenv to switch python versions.

Copy env.default and rename it to .env

Install the dependencies by running:

npm install

Troubleshooting:

  • If you're running into node-gyp issues related to Python 3 vs Python 2 you can run npm rebuild or run npm install again.
  • The postinstall script should set-up your default environment and bootstrap the database along with some seed data. If it is failing you can try to run: npm run db:setup && ./node_modules/.bin/babel-node ./scripts/db_restore.js opencollective_dvl

Start the API by running:

npm run dev

Once it's running

This new environment is created with the opencollective_dvl database. And it comes with enough data to play with most of the system.

However, trying to access the home page will lead you to a 404 page. That's because we're porting our old UI over to the new one. The repository opencollective-website is deprecated but it still powers our home page and the /discover page.

To see something interesting, please access one of the collectives that are present in this sanitized version of the database. Here are some examples:

Local Email

Email templates can be viewed locally by running npm run compile:email <template name> and making sure there is data for that template in scripts/compile-email.js.

Email sending can done by running npm run maildev locally and setting the MAILDEV environment variable to true. Then open http://localhost:1080 to see any outgoing emails from the opencollective-api server.

Participate on the discussion

If you have any questions, ping us on Slack (https://slack.opencollective.org) or on Twitter (@opencollect).

TODO

  • The User model is confusing with the concept of User Collective, we should merge the "User" model with the "ConnectedAccount" model so that we could have multiple emails per User.
  • CreatedByUserId is confusing, it should be "CreatedByCollectiveId"

About

OpenCollective's API

License:MIT License


Languages

Language:JavaScript 93.1%Language:HTML 6.3%Language:Shell 0.5%Language:Gherkin 0.1%Language:Dockerfile 0.0%Language:Makefile 0.0%