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.
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).
index.js: Define routes and generic handlers. Start server.helpers.js: Define helper functions.db/index.js: Define database connection. Loadpg-promisewith 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.
git clone https://github.com/falling-fruit/api.git
cd api
yarn- Copy
.env.exampleto.envand update the values as needed.
cp .env.example .envyarn startVisit http://localhost:3300.
Validate and build the OpenAPI documentation:
yarn validate && yarn build