Giter Site home page Giter Site logo

samuelralak / code-corps-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from code-corps/deprecated-code-corps-rails-api

0.0 1.0 0.0 1.36 MB

Rails API for Code Corps.

Home Page: https://codecorps.org

License: MIT License

Ruby 99.06% HTML 0.76% Shell 0.18%

code-corps-api's Introduction

Code Corps Rails API

Code Corps Rails Logo

Circle CI Dependency Status Code Climate Test Coverage Inline docs Slack Status

The Code Corps API is an open source Rails::API backend that powers the Code Corps platform. It includes:

  • developer and project matchmaking
  • project management tooling
  • a donations engine that distributes donations to projects

Contributing

We'd love to have you contribute to Code Corps directly!

To do so, please read the guidelines in our CONTRIBUTING.md.

Then head over to Code Corps, where we manage contributions.

Developer installation guide

Install Rails, PostgreSQL, Redis, and ElasticSearch

We need to install the Ruby on Rails framework, the PostgreSQL database, and the Redis data store.

  1. Install Rails.
  2. Install and configure PostgreSQL 9.3+.
  3. Run postgres -V to see if you already have it.
  4. Make sure that the server's messages language is English; this is required by the ActiveRecord Postgres adapter.
  5. Install and make sure you can run redis:
    • Follow the official quickstart guide
    • It's best to install it as a service instead of running it manually
    • To make sure everything works and the service is running, execute redis-cli ping in the console. It should respond with PONG
  6. Install ElasticSearch
    • On Mac, run brew install elasticsearch
    • Or for Linux or Windows, consult the setup guide
  7. Install ImageMagik
    • On Mac, run brew install imagemagick
    • Or for Linux or Windows, consult the guide

Clone this git repository

You'll want to clone this repository with git clone https://github.com/code-corps/code-corps-api.git.

Set up the Rails app

  1. Run bin/setup to set up and seed the database.
  2. Try running the specs: bundle exec rake spec

From here, we need to start the web server, Redis, and Sidekiq processes. You can either:

Use foreman to run your application's processes

  1. Stop your existing redis-server process
  2. Run the api with foreman start -f Procfile.dev. This will start any service listed in that Procfile.

Alternatively, run your application's processes individually

  1. You already have redis-server running. In the future, you'll need to run it, as well.
  2. Start Sidekiq with bundle exec sidekiq
  3. Start the Rails server with rails s

To make sure the API is running properly

Point your browser (or make a direct request) to http://api.lvh.me:3000/ping. There should be a {"ping":"pong"} response from it.

Working with Ember

The CodeCorps API is intended to work alongside a client written in Ember. For that purpose, the rails application exposes all of it's API endpoints behind an api. subdomain.

On the Ember client side of things, we use ember-cli-deploy with a redis plugin to deploy the client application to redis. Multiple revisions are maintained this way.

Any server request pointing to the main domain and not the api. subdomain is redirected to ember_index_controller#index. There, depending on the remainder of the request path and the current environment, a specific revision of the ember app is retrieved from redis and rendered. This can be

  • the development revision, if the current environment is development
  • a specific deployed revision in production if the request contains a revision parameter in SHORT_UUID format
  • the latest deployed revision in production if the request does not contain a revision parameter
  • A plain text string containing "INDEX NOT FOUND" if a revision was specified, but the key for the specified revision was not found by redis

Debugging the API

Because the app is running foreman, debugging use pry won't work the same way. If you want to use pry, you'll need to debug remotely.

Add binding.remote_pry where you want to pause:

class UsersController < ApplicationController
  def index
    binding.remote_pry
    ...
  end
end

Load a page that triggers the code. Connect to the session:

$ bundle exec pry-remote

Built with

  • Rails::API — Our backend API is a Rails::API app which uses JSON API to respond RESTfully to requests.
  • Ember.js — Our frontend is an Ember.js app that communicates with the Rails API.
  • PostgreSQL — Our primary data store uses Postgres.

code-corps-api's People

Contributors

begedin avatar christopherstyles avatar ethantanner avatar joshsmith avatar madisonsites avatar ptrikutam avatar rigelstpierre avatar scarfdestroyer avatar schneidmaster avatar

Watchers

 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.