/GitHunt-API

:train: The server shared by all of the GitHunt client examples

Primary LanguageJavaScriptMIT LicenseMIT

GitHunt

The Apollo Server backend shared by all Apollo client example apps.

Interact with the API yourself at http://api.githunt.com/graphiql.

Get on Slack Build Status

Demonstrates:

  1. GraphQL schema, resolvers, models, and connectors to read from two different data sources, GitHub REST API and SQL
  2. Web server with authentication and basic authorization using Express, Passport, and Apollo Server

Please submit a pull request if you see anything that can be improved!

Running the server

  1. Install Node/npm. Make sure you have Node.js 4 or newer installed.
  2. Clone and install dependencies. Run the following commands:
git clone https://github.com/apollostack/GitHunt-API.git
cd GitHunt-API
npm install
  1. Run migrations. Set up the SQLite database and run migrations/seed data with the following commands:
npm run migrate
npm run seed
  1. Get GitHub API keys.

  2. Go to OAuth applications > Developer applications in GitHub settings

  3. Click 'Register a new application' button

  4. Register your application like below

  5. Click 'Register application' button at the bottom. It should look like this screenshot of the app setup page.

  6. On the following page, grab the Client ID and Client Secret, as indicated in this screenshot of the GitHub OAuth keys page.

  7. Add Environment Variables. Set your Client ID and Client Secret Environment variables in the terminal like this:

export GITHUB_CLIENT_ID="your Client ID"
export GITHUB_CLIENT_SECRET="your Client Secret"

Or you can use dotenv, to do this cp .env.default .env and edit with your Github keys.

  1. Run the app.
npm run dev
  1. Open the app. Open http://localhost:3010/ to see what to do next.