Code Monkey home page Code Monkey logo

autoclip-customendpoint-example's Introduction

autoclip-customEndpoint-example

Note: Setting up a custom endpoint for the autoclip app to point to requires some general programming experience, including javascript, databases, and hosting. This repo is a guide to give users an idea of how they can set up their own endpoint so they can store their own data instead of having autoclip store it

This is an example NODE.js app that points to an example postgres database

Step 1. Clone this repo

Step 2. Navigate to https://dashboard.heroku.com/apps and create an account

Step 3. Create a new app in heroku and name it whatever you want. We will use the example example-autoclip-endpoint

Step 4. Create a database with an appropriate table, an example is given in initDB.sql. We reccomend using postgres, find out more here https://www.postgresql.org/docs/9.4/tutorial-start.html We used the heroku postgres addon and it made the whole experience very easy and user friendly

Step 5. In queries.js replace the credentials in the database credentials section with your own that you just made

Step 6. In your terminal run heroku git:remote -a custom-endpoint-example, NOTE: you made need to install heroku and add it to your ~.zshrc file or add it to your command line if you are on a windows machine

Step 7. Now run git push heroku. And voila, you have your node datasource hosting locally. Look at the logs in heroku and whatever url it says the app is hosted add that + / + whatever you named your custom endpoint in index.js (the example is /submitanswers) So if heroky says host=custom-endpoint-example.herokuapp.com you would enter https://custom-endpoint-example.herokuapp.com/submitanswers in the customDatasource textbox when creating a form

Now all submitted answers to that form will be POST'd to the endpoint you defined via an http request body. For example the submitted answers body may look like:

{
    "title": "How many fish did you catch today?",
    "answer": "3",
    "formId": "2",
    "userId": "5"
}

LOCALLY/DEBUGGING

If you want to run your node endpoint locally just run npm i && npm start if you are on OSX/Linux and have npm installed.

If you want to run the postgres database locally just download postgres & we suggest pgadmin. Run them locally and update the database credentials in queries.js to use your local credentials

autoclip-customendpoint-example's People

Contributors

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