Skip to content

falling-fruit/falling-fruit-api

Repository files navigation

Status

Falling Fruit API

NodeJS API using express, pg-promise, and bluebird. The code structure is inspired by this pg-promise demo and this more general tutorial.

You can browse the OpenAPI definition for the main branch here, and for the live API here.

Status

Live at https://fallingfruit.org/api/0.3. Used by https://fallingfruit.org (falling-fruit) and extensively by https://beta.fallingfruit.org (falling-fruit-web).

Layout

  • index.js: Define routes and generic handlers. Start server.
  • helpers.js: Define helper functions.
  • db/
    • index.js: Define database connection. Load pg-promise with repos:
    • repos/
      • index.js: Compile all classes:
      • {class}.js: Class definition with methods.
    • sql/
      • index.js: Load all SQL query files:
      • {class}/
        • *.sql: Raw SQL with variable substitutions.

Development

Installation

  • Clone the repo and change into the new directory.

    git clone https://github.com/falling-fruit/falling-fruit-api
    cd falling-fruit-api
  • Install the node version specified in the .nvmrc file. This is easiest using nvm.

    nvm install
    nvm use
  • yarn is already provided (see .yarn/releases). Use it to install dependencies.

    yarn
  • Copy .env.example to .env and update the values as needed.

cp .env.example .env

Usage

yarn start

Visit http://localhost:3300.

Documentation

Validate and build the OpenAPI documentation:

yarn validate && yarn build

About

API (v0.3) for Falling Fruit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors