Giter Club home page Giter Club logo

node-api-template's Introduction

node-api-template

A mildly opinionated, RESTish API template built with Node.js

About

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.

Features

  • Versioning
  • Support for various data stores
  • Tests
  • Flexibility
  • Extensibility
  • The Javascript you know and love
  • Minimal abstractions

Organization

Each version of the API functions as a self-contained module, and therefore has its own package.json, README, and dependencies.

Install

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.example.js to vx/credentials.js and input your credentials.

Start

npm start

The API runs on port 5555 by default, and the root can be accessed by navigating to http://localhost:5555/api or http://localhost:5555/api/vX in your browser.

Testing

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 settings.js.

To run the tests:

npm test

Running in production

Both forever and pm2 are great for keeping the API alive (and load balancing in the case of pm2).

Author

John J Czaplewski, with inspiration and assistance from Puneet Kishor and Shanan Peters.

Funding

Development supported by NSF CAREER EAR-1150082 and NSF ICER-1440312.

License

CC-BY for all code unique to this API.

node-api-template's People

Contributors

jczaplew avatar aazaff avatar cambro avatar rudedog9d avatar

Watchers

James Cloos 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.