Giter VIP home page Giter VIP logo

api's Introduction

ToS;DR APIs

Testing locally

In production our APIs run via open-runtimes on self-hosted AppWrite functions.

Locally, you can test by running server.js

First, build whatever API Functions you wish to test. cd into the function's directory within functions containing package.json, and run npm install && npm run build.

Then to start the server:

  • cd function_server && npm install
  • Set the following environment variables
    • PGUSER - Postgres User of the Phoenix DB
    • PGHOST - Hostname of the Phoenix DB
    • PGPASSWORD - Password of the Phoenix DB
    • PGDATABASE - Database Name
    • PGPORT - Port of the Phoenix DB
  • npm run start

The server will listen on localhost port 3000. Test an API by adding its path within functions to the end of the URL. For example, the following tests Case GET:

curl -d '{"payload": {"id": 120}}' localhost:3000/Case/GET/v2

Or to get all cases: curl -d '{}' localhost:3000/Case/GET/v2

Model changes

Some REST objects are defined in models, which needs to be built and deployed separately here.

Deploying

(Copied from the AppWrite documentation)

There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience.

Using CLI

Make sure you have Appwrite CLI installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command appwrite client --debug and it should respond with green text โœ“ Success.

Make sure you are in the same folder as your appwrite.json file and run appwrite deploy function to deploy your function. You will be prompted to select which functions you want to deploy.

Manual using tar.gz

Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating .tar.gz file, visit Appwrite Console, click on the Deploy Tag button and switch to the Manual tab. There, set the entrypoint to src/index.js, and upload the file we just generated.

api's People

Contributors

justinback avatar madoleary avatar radkoff 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.