A mildly opinionated, RESTish API template built with Node.js
Designed to minimally abstract database logic, this template scaffolds common API design decisions and allows you to quickly distribute your data in common formats, such as JSON and CSV. This is meant to serve as a boilerplate for quickly establishing an API for an existing database system. We have succesfully and deployed this API framework on top of MariaDB, Postgres, and MongoDB.
While researching API design with Node.js, there were many questions, such as versioning and handling of relational databases, that did not have obvious answers. This template is one opinion on a set of answers to many common API design questions.
- Support for various data stores
- Minimal abstractions
Each version of the API functions as a self-contained module, and therefore has its own
README, and dependencies.
curl -LOk https://github.com/UW-Macrostrat/node-api-template/archive/master.zip unzip master.zip cd node-api-template-master npm install
If using MySQL or Postgres, you will need to update rename
vx/credentials.js and input your credentials.
The API runs on port
5555 by default, and the root can be accessed by navigating to
http://localhost:5555/api/vX in your browser.
The tests for each version of the API can be found in
vx/test, and each route has its own test file. Functions used for testing the validity of each response can be found in
validators.js, and various settings in
To run the tests:
Running in production
Development supported by NSF CAREER EAR-1150082 and NSF ICER-1440312.
CC-BY for all code unique to this API.