Coder Social home page Coder Social logo

andrewroy27 / rails-devise-graphql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zauberware/rails-devise-graphql

0.0 1.0 0.0 67 KB

A RubyOnRails boilerplate for authentication with devise and graphQL

Home Page: https://gatsby-redux.zauberware.com

License: MIT License

Ruby 99.69% HTML 0.31%

rails-devise-graphql's Introduction

Rails 5 API-only boilerplate with devise & JWT & graphQL

This is a boilerplate to build your next SaaS product. It's a RubyOnRails 5 API only backend with Authentication and GrpahQL API. It works nicely together with clients made with React.js & React.Native or any other frontend which implements the JSON Web Tokens philosophy. We have a demo frontend made with gatsbyJS available here: https://gatsby-redux.zauberware.com/.

Versions

  • Tested with ruby version 2.4.x
  • Rails version ~>5.2.3
  • Postgresql Server

Quick start

Deploy

or

clone the repo:

git clone https://github.com/zauberware/rails-devise-graphql my-saas-backend
cd my-saas-backend

Clone env_sample to .env for local development. We set it up with default rails 3000 and gatsby 8000 ports:

cp env_sample .env

Install the bundle:

bundle install

Make sure the postresql is running on localhost. You may have to change your credentials under /config/database.yml:

rake db:create
rake db:migrate
rake db:seed

Run the development server:

rails s

While this is an API-only application you will not be able to access any routes via browser. Download a GraphQL client like GraphiQL or others.

Point the GraphQL IDE to http://0.0.0.0:3000/graphql

Note: Make sure that the .env file is included in the root of your project and you have defined CLIENT_URL and DEVISE_JWT_SECRET_KEY. You can try out the Demo frontend or you implement the actions in any other client. Read more about the JSON Web Token this. There are plenty of packages available.

What's included?

1. Database

The app uses a postgresql database. It implements the connector with the gem pg. The app already includes a User model with basic setup.

2. Authentication

The app uses devise's logic for authentication. Emails are currently disabled in the environment settings.

3. JSON Web Token

devise-jwt is a devise extension which uses JWT tokens for user authentication. It follows secure by default principle.

4. GraphQL

graphql-ruby is a Ruby implementation of GraphQL. Sadly it's not 100% open source, but with the free version allows you amazing things to do. See the Getting Started Guide and the current implementations in this project under app/graphql/.

5. CORS

Protect your app and only allow specific domains to access your API. Set CLIENT_URL= in .env to your prefered client. If you need advanced options please change the CORS settings here config/initializers/cors.rb.

6. App server

The app uses Puma as the web serber. It is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications in development and production.

7. Testing

We are using the wonderful framework rspec. The testsuit also uses factory_bot_rails for fixtures.

Run rspec spec

8. Deployment

The project runs on every webhoster with ruby installed. The only dependency is a PostgreSQL database. Create a block production: in theconfig/database.yml for your connection.

Heroku

Deploy

Choose the one click installer or push a clone of this repo to heroku by yourself. We added a Profile to the project and heroku run the release: statement after deploying a new version. Heroku will automatically set the db settings for your project, so there is nothing to do in config/database.yml.

Make sure all ENV vars are set and the database settings are valid.

9. Frontend

GatsbyJS

If you need a frontend than have a look at this basic Gatsby boilerplate. A Gatsby Redux SaaS starter for your next SaaS product. Uses react-redux, apollo-client, magicsoup.io, styled-components, styled-system.

zauberware technologies

Author

Script: https://github.com/zauberware/rails-devise-graphql
Author website: https://www.zauberware.com

zauberware technologies

rails-devise-graphql's People

Contributors

simonfranzen 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.