Coder Social home page Coder Social logo

postgrest-heroku's Introduction

PostgREST on Heroku

The best way to build an API, now for Heroku.

Updated for PostgREST v7.0.1.

NOTE: The free tier Heroku PostgreSQL addon will not work because it does not support having multiple database roles. Heroku Postgres paid tiers do support multiple database roles, though you'll have to create them through Heroku Postgres Credentials.

We recommend spinning up a Postgres database with Amazon RDS. Make sure you create it in the Virginia region because that's where Heroku's dynos are and it will decrease latency between the server and db.

Alternatively you could create it on ElephantSQL for free tier usage.

To Deploy PostgREST on Heroku

  1. Log into Heroku using the Heroku CLI:

    # If you have multiple Heroku accounts, use flag '--interactive' to switch between them
    heroku login --interactive
  2. Create a new Heroku app using this Heroku buildpack:

    heroku apps:create ${YOUR_APP_NAME} --buildpack https://github.com/PostgREST/postgrest-heroku
    heroku git:remote -a ${YOUR_APP_NAME}
  3. Create the necessary user roles according to the PostgREST documentation and allow them role switch from the psql console:

    GRANT user123 TO authenticator;
    GRANT web_anon TO authenticator;
  4. Create a configuration file postgrest.conf:

    db-uri = "postgres://authenticator:[email protected]:5432/postgres"
    db-schema = "api"
    db-anon-role = "web_anon"
    db-pool = 10

    and the Procfile:

    ./env-to-config ./postgrest postgrest.conf

    It is also possible to set variables directly on Heroku:

    heroku config:set POSTGREST_VER=0.5.0.0
    heroku config:set DB_URI=postgres://postgrest_test:postgrest111@postgrest-test.crbxuv1p3j1c.us-west-1.rds.amazonaws.com/postgrest_test
    heroku config:set DB_SCHEMA=public
    heroku config:set DB_ANON_ROLE=postgrest_test
    heroku config:set DB_POOL=60
    

    To determine the best value for PostgREST environment variable DB_POOL, ask the database by running this SQL:

    show max_connections;

    See https://postgrest.org/en/stable/configuration.html for the full list of configuration parameters.

  5. Create the Heroku dyno:

    git push heroku master

Your Heroku app should be live at ${YOUR_APP_NAME}.herokuapp.com.

postgrest-heroku's People

Contributors

begriffs avatar steve-chavez avatar jamiefolsom avatar diogob avatar hugomrdias avatar wub avatar christiaanwesterbeek avatar kofigumbs avatar fohlen avatar martingms avatar wolfgangwalther avatar

Watchers

James Cloos avatar  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.