Backend-Starter-Kit

:truck: A boilerplate for :star2: Node.js :star2:, Express, Mongoose, Heroku, mLab, Nodemon, PM2, and Babel.

2 years after

Backend Starter Kit (Beta)

:truck: A boilerplate for :star2: Node.js :star2:, Express, Mongoose, Heroku, mLab, Nodemon, PM2, and Babel.

Build Status // Dependency Status devDependency Status

Live Demo

This seed repository provides the following features:

  • ---------- Primary Key ----------
  • [x] Server-side platform with Node.
  • [x] Application framework with Express.
  • [x] Dadabase object modeling with Mongoose.
  • [x] Application cloud hosting with Heroku.
  • [x] Dadabase cloud hosting with mLab.
  • ---------- Secondary Key ----------
  • [x] Utility functions with Lodash.
  • [x] Reactive extensions with ReactiveX.
  • [x] Authentication with JWT.
  • [x] Data query language with GraphQL.
  • [x] Realtime application with Socket.
  • ---------- Dev Tools ----------
  • [x] Automatically restart application with Nodemon.
  • [x] Keeping application alive with PM2.
  • [x] Next generation JavaScript with Babel.
  • ---------- Test Tools ----------
  • [x] Static code analyzer with ESLint.
  • [x] Test framework with Mocha.
  • [x] Assertion library with Chai.
  • [x] Test spies with Sinon.
  • ---------- Environment ----------
  • [x] Operating system with Linux.
  • [x] Text editor with Atom.
  • [x] Version control with Git.
  • [x] Fast and deterministic builds with Yarn.
  • [ ] Reverse proxy and caching with Nginx.
  • [ ] Software container with Docker.
  • [ ] Continuous integration with Travis.

Table of Contents

Getting Started

1) Clone this Boilerplate

$ git clone --depth 1 https://github.com/Shyam-Chen/Backend-Starter-Kit.git <PROJECT_NAME>
$ cd <PROJECT_NAME>

2) Install Dependencies

$ yarn install

3) Run the Application

$ yarn start

4) Stay up-to-date

$ git remote add upstream https://github.com/Shyam-Chen/Backend-Starter-Kit.git
$ git pull upstream master

Dockerization

1) Build the Image

$ docker build -t Backend-Starter-Kit .

2) Run the Container

$ docker run -it -p 8000:8000 --name app Backend-Starter-Kit

3) Just Compose

$ docker-compose up

Configuration

Application configuration

app.set('port', (process.env.PORT || 8000));

Using Libraries

Example of Route

import express from 'express';

Example of Model

import mongoose, { Schema } from 'mongoose';

Example of Lodash

import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { lowerFirst, pad } from 'lodash';

Observable::of(lowerFirst('Hello'), pad('World', 5))
  .subscribe(value => console.log(value));
  // hello
  // World

Example of ReactiveX

import { Observable } from 'rxjs/Observable';
import { timer } from 'rxjs/observable/timer';
import { of } from 'rxjs/observable/of';
import { mapTo } from 'rxjs/operator/mapTo';
import { combineAll } from 'rxjs/operator/combineAll';

Observable::timer(2000)
  ::mapTo(Observable::of('Hello', 'World'))
  ::combineAll()
  .subscribe(value => console.log(value));
  // ["Hello"]
  // ["World"]

Example of JWT

import jwt from 'express-jwt';

Example of GraphQL

import graphql from 'express-graphql';

Example of Socket.IO

import io from 'socket.io';

const socket = io.listen(server);

socket.on('connection', (client) => {
  console.log('Establish a connection');
  client.on('B', (message) => {
    console.log(message);
    socket.emit('A', 'A: Hi, B!');
  });
});
const socket = io.connect('http://localhost:8000');

socket.on('connect', () => console.log('Accept a connection'));
socket.on('A', (message) => console.log(message));
socket.emit('B', 'B: What\'s up?');

All Commands

$ yarn run dev
$ yarn run test
$ yarn run prod

$ yarn run clean
$ yarn run reset
$ yarn run reinstall

Directory Structure

.
├── public
│   ├── favicon.ico
│   └── index.html
├── scripts
│   └── build|deploy|install|test.sh
├── src
│   ├── models
│   │   └── index.js ...
│   ├── routes
│   │   └── index.js ...
│   ├── types
│   │   └── index.js ...
│   ├── utils
│   │   └── index.js ...
│   ├── index.js
│   ├── schema.js
│   └── server.js
├── test
│   └── test.js ...
├── .babelrc
├── .editorconfig
├── .eslintrc
├── .gitattributes
├── .gitignore
├── .travis.yml
├── Dockerfile
├── LICENSE
├── Procfile
├── README.md
├── docker-compose.yml
├── nginx.conf
├── package.json
└── yarn.lock

To-Do List

  • ...

Related Repositories

react-starter-kit

react-starter-kit

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, R ...

yii2-starter-kit

yii2-starter-kit

Yii2 Starter Kit ...

aspnet-starter-kit

aspnet-starter-kit

Cross-platform web development with Visual Studio Code, C#, F#, JavaScript, ASP. ...

apollo-universal-starter-kit

apollo-universal-starter-kit

Apollo Universal Starter Kit — Universal web and mobile app boilerplate with Hot ...

react-apollo-starter-kit

react-apollo-starter-kit

A production-ready starter kit for making a React/Apollo application. ...