GithubHelp home page GithubHelp logo

litor / nodejs-restful-jsonapi-seed Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nuxy/nodejs-restful-jsonapi-seed

0.0 1.0 0.0 998 KB

Everything you need to start building a scalable web application.

Home Page: https://www.npmjs.com/package/nodejs-restful-jsonapi-seed

License: MIT License

JavaScript 98.72% Dockerfile 1.28%

nodejs-restful-jsonapi-seed's Introduction

Node.js Express restful JSON API seed

npm version Build Status

Everything you need to start building a scalable web application.

the "seed" app

Features

  • ECMAScript 2015 (ES6) compatible.
  • RESTful application interface.
  • JSON API standard request/responses.
  • ABAC (Attribute-Based Access Control)
  • HTTP/1/2 and SSL support.
  • Database driver support.
  • Session handling using cookies.
  • Schema-based validation.
  • Stream-based logging and file rotation.
  • Production process manager.
  • ESDoc App/Swagger API documentation.
  • Deployable as a Docker service.

Dependencies

Installation

seed-cli

Install the command-line utility using NPM.

$ npm install -g nodejs-restful-jsonapi-seed
$ seed-cli --help

Usage: seed-cli [options]

Options:
  --create <project-name>  Create a new seed example project
  --build                  Transpile ES6 sources (using Babel) to a distribution
  --start                  Launch a single server instance from a transpiled distribution
  --deploy                 Launch a server cluster from a transpiled distribution
  --watch                  Launch the server (development mode)
  --lint                   Run ESLint on project sources
  --test                   Run Mocha integration tests
  --docker                 Deploy your application as a Docker service
  --gendoc                 Generate documentation using ESDoc
  --env <environment>      Set the NODE_ENV (default: development)
  -h, --help               output usage information

Manual

Clone the repository, or download the latest release.

$ git clone https://github.com/nuxy/nodejs-restful-jsonapi-seed.git

Install package dependencies using NPM.

$ npm install

Developers

While seed-cli provided with this package can execute NPM scripts, it's not a requirement. You can also achieve this using npm-run-script.

CLI options

Set your environment. If NODE_ENV is not defined, the default config development is used.

$ export NODE_ENV=<production|staging|qa>

Transpile ES6 sources (using Babel) to a distribution:

$ npm run build

Launch a single server instance from a transpiled distribution:

$ npm run start

Launch a server cluster from a transpiled distribution:

$ npm run deploy

Launch the server (development mode) with nodemon:

$ npm run watch

Run ESLint on project sources:

$ npm run lint

Run Mocha integration tests:

$ npm run test

Deploy your application as a Docker service:

$ npm run docker

Generate documentation using ESDoc:

$ npm run gendoc

API Examples

The following routes have been enabled in the application. When the server is running in development mode Swagger generated documentation can be accessed at: http://localhost:3000/api-doc

Documentation

When the server is running in development mode ESDoc generated documentation can be accessed at: http://localhost:3000/app-doc

Enabling HTTP/2

The http2 module is an experimental API which relies on the Latest Current Version of Node.js to work. Furthermore, since there are no browsers known that support unencrypted HTTP/2, the use of X.509 certificates is necessary when communicating with browser clients.

To set-up the server, first you must generate the certificate and key files:

$ openssl req -x509 -newkey rsa:2048 -nodes -sha256 -keyout localhost-key.pem -out localhost-cert.pem

Then output each file as a string, manually adding the value to the server config:

$ cat localhost-<key|cert>.pem | perl -pe 's/\n/\\n/g'

See the Node.js documentation for information regarding client-side set-up.

Common questions

What was your motivation for creating this package?

I wanted a package that was lightweight and provided all of the Production features needed to create a scalable API server. While there are many packages available, most are lacking or require you to sacrifice simplicity or features for little gain.

This package provides everything you need to quickly build your application using a consistent and secure set of standards.

Why use Babel, and not TypeScript?

If you are using ESDoc types and an IDE/Editor that supports Intellisense (code completion and typing). Complexity like this is not necessary.

How do you set-up this package to use a custom database?

You can update the database wrapper example to use any DBMS package available while extending the application SessionStore to use a compatible Connection Session Store module.

Windows support

This package has limited support for Windows due to cross-platform compatibility issues, most notably SHELL environment differences. Due to this, you can either run this package in Docker or switch to a UNIX-like operating system.

Contributions

If you fix a bug, or have a code you want to contribute, please send a pull-request with your changes. (Note: Before committing your code please ensure that you are following the Node.js style guide)

Versioning

This package is maintained under the Semantic Versioning guidelines.

License and Warranty

This package is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

nodejs-restful-jsonapi-seed is provided under the terms of the MIT license

Author

Marc S. Brooks

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.