Skip to content

Commit

Permalink
Merge pull request #442 from kunalkapadia/develop
Browse files Browse the repository at this point in the history
Update node and remove gulp, babel.
  • Loading branch information
kunalkapadia authored Mar 23, 2018
2 parents ddf6d0e + 3536307 commit 8326d42
Show file tree
Hide file tree
Showing 23 changed files with 647 additions and 2,136 deletions.
2 changes: 1 addition & 1 deletion .istanbul.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
verbose: false
instrumentation:
excludes: ['dist/**', 'coverage/**', 'gulpfile.babel.js']
excludes: ['dist/**', 'coverage/**', 'index.js']
include-all-sources: true
reporting:
print: summary
Expand Down
8 changes: 5 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
language: node_js
node_js:
- "4.8"
- "6.10"
- "7.6"
- "8.10"
- "9.9"
services:
- mongodb
cache:
Expand All @@ -14,3 +13,6 @@ script:
- yarn test:check-coverage
after_script:
- yarn report-coverage
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.5.1
- export PATH=$HOME/.yarn/bin:$PATH
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# take default image of node boron i.e node 6.x
FROM node:6.10.1
# Use latest node version 8.x
FROM node:8.10.0

MAINTAINER Kunal Kapadia <kunalkapadia12@gmail.com>

Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Express & mongoose REST API Boilerplate in ES6 with Code Coverage [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)

[![Build Status](https://img.shields.io/travis/KunalKapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://travis-ci.org/KunalKapadia/express-mongoose-es6-rest-api)
[![Coverage Status](https://img.shields.io/coveralls/KunalKapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://coveralls.io/github/KunalKapadia/express-mongoose-es6-rest-api?branch=master)
[![Code Climate](https://img.shields.io/codeclimate/github/KunalKapadia/express-mongoose-es6-rest-api.svg?style=flat-square)](https://codeclimate.com/github/KunalKapadia/express-mongoose-es6-rest-api)
[![bitHound Overall Score](https://www.bithound.io/github/KunalKapadia/express-es6-rest-api-starter/badges/score.svg)](https://www.bithound.io/github/KunalKapadia/express-es6-rest-api-starter)
[![bitHound Dependencies](https://www.bithound.io/github/KunalKapadia/express-mongoose-es6-rest-api/badges/dependencies.svg)](https://www.bithound.io/github/KunalKapadia/express-mongoose-es6-rest-api/master/dependencies/npm)
[![Build Status](https://img.shields.io/travis/kunalkapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://travis-ci.org/kunalkapadia/express-mongoose-es6-rest-api)
[![Coverage Status](https://img.shields.io/coveralls/kunalkapadia/express-mongoose-es6-rest-api/master.svg?style=flat-square)](https://coveralls.io/github/kunalkapadia/express-mongoose-es6-rest-api?branch=master)
[![Code Climate](https://img.shields.io/codeclimate/github/kunalkapadia/express-mongoose-es6-rest-api.svg?style=flat-square)](https://codeclimate.com/github/kunalkapadia/express-mongoose-es6-rest-api)
[![bitHound Overall Score](https://www.bithound.io/github/kunalkapadia/express-es6-rest-api-starter/badges/score.svg)](https://www.bithound.io/github/kunalkapadia/express-es6-rest-api-starter)
[![bitHound Dependencies](https://www.bithound.io/github/kunalkapadia/express-mongoose-es6-rest-api/badges/dependencies.svg)](https://www.bithound.io/github/kunalkapadia/express-mongoose-es6-rest-api/master/dependencies/npm)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
[![MIT License](https://img.shields.io/npm/l/stack-overflow-copy-paste.svg?style=flat-square)](http://opensource.org/licenses/MIT)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)

[![Code Sponsor](https://app.codesponsor.io/embed/J9YBdeLoqYqrG8tmMKF4p6Pv/KunalKapadia/express-mongoose-es6-rest-api.svg)](https://app.codesponsor.io/link/J9YBdeLoqYqrG8tmMKF4p6Pv/KunalKapadia/express-mongoose-es6-rest-api)
[![Code Sponsor](https://app.codesponsor.io/embed/J9YBdeLoqYqrG8tmMKF4p6Pv/kunalkapadia/express-mongoose-es6-rest-api.svg)](https://app.codesponsor.io/link/J9YBdeLoqYqrG8tmMKF4p6Pv/kunalkapadia/express-mongoose-es6-rest-api)

# [![Express ES6 REST API Starter](https://cloud.githubusercontent.com/assets/4172932/12660610/90f5b856-c63a-11e5-878e-c9f0bbf33090.jpg)](https://github.com/KunalKapadia/express-mongoose-es6-rest-api)
# [![Express ES6 REST API Starter](https://cloud.githubusercontent.com/assets/4172932/12660610/90f5b856-c63a-11e5-878e-c9f0bbf33090.jpg)](https://github.com/kunalkapadia/express-mongoose-es6-rest-api)

## Overview

Expand Down Expand Up @@ -44,7 +44,7 @@ Heavily inspired from [Egghead.io - How to Write an Open Source JavaScript Libra

Clone the repo:
```sh
git clone git@github.com:KunalKapadia/express-mongoose-es6-rest-api.git
git clone git@github.com:kunalkapadia/express-mongoose-es6-rest-api.git
cd express-mongoose-es6-rest-api
```

Expand Down Expand Up @@ -147,12 +147,24 @@ Get code coverage summary on executing `yarn test`

## Docker

#### Using Docker Compose for Development
```sh
# For Development
# service restarts on file change
1. bash bin/development.sh
bash bin/development.sh
```

#### Building and running without Docker Compose
```bash
# To use this option you need to make sure mongodb is listening on port 27017

# Build docker
docker build -t express-mongoose-es6-rest-api .

# Run docker
docker run -p 4040:4040 express-mongoose-es6-rest-api
```


## A Boilerplate-only Option

If you would prefer not to use any of our tooling, delete the following files from the project: `package.json`, `gulpfile.babel.js`, `.eslintrc` and `.travis.yml`. You can now safely use the boilerplate with an alternative build-system or no build-system at all if you choose.
Expand All @@ -166,7 +178,7 @@ If you would prefer not to use any of our tooling, delete the following files fr
Contributions, questions and comments are all welcome and encouraged. For code contributions submit a pull request with unit test.

## License
This project is licensed under the [MIT License](https://github.com/KunalKapadia/express-mongoose-es6-rest-api/blob/master/LICENSE)
This project is licensed under the [MIT License](https://github.com/kunalkapadia/express-mongoose-es6-rest-api/blob/master/LICENSE)

## Support Development
If this project saved your valuable time in getting your service up, and you feel like buying me coffee, you can donate either at my BTC address: `1LkW5UoERR1jjJsChMheKuo6vn95x2mzWg` or at [![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)
Expand All @@ -175,5 +187,5 @@ Your support is greatly appreciated.

## Meta

Kunal Kapadia – [@kunalkapadia12](https://twitter.com/KunalKapadia12)kunalkapadia12@gmail.com
Kunal Kapadia – [@kunalkapadia12](https://twitter.com/kunalkapadia12)kunalkapadia12@gmail.com

4 changes: 2 additions & 2 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Joi from 'joi';
const Joi = require('joi');

// require and configure dotenv, will load vars in .env in PROCESS.ENV
require('dotenv').config();
Expand Down Expand Up @@ -41,4 +41,4 @@ const config = {
}
};

export default config;
module.exports = config;
32 changes: 16 additions & 16 deletions config/express.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import express from 'express';
import logger from 'morgan';
import bodyParser from 'body-parser';
import cookieParser from 'cookie-parser';
import compress from 'compression';
import methodOverride from 'method-override';
import cors from 'cors';
import httpStatus from 'http-status';
import expressWinston from 'express-winston';
import expressValidation from 'express-validation';
import helmet from 'helmet';
import winstonInstance from './winston';
import routes from '../server/routes/index.route';
import config from './config';
import APIError from '../server/helpers/APIError';
const express = require('express');
const logger = require('morgan');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const compress = require('compression');
const methodOverride = require('method-override');
const cors = require('cors');
const httpStatus = require('http-status');
const expressWinston = require('express-winston');
const expressValidation = require('express-validation');
const helmet = require('helmet');
const winstonInstance = require('./winston');
const routes = require('../index.route');
const config = require('./config');
const APIError = require('../server/helpers/APIError');

const app = express();

Expand Down Expand Up @@ -84,4 +84,4 @@ app.use((err, req, res, next) => // eslint-disable-line no-unused-vars
})
);

export default app;
module.exports = app;
4 changes: 2 additions & 2 deletions config/param-validation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Joi from 'joi';
const Joi = require('joi');

export default {
module.exports = {
// POST /api/users
createUser: {
body: {
Expand Down
4 changes: 2 additions & 2 deletions config/winston.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import winston from 'winston';
const winston = require('winston');

const logger = new (winston.Logger)({
transports: [
Expand All @@ -9,4 +9,4 @@ const logger = new (winston.Logger)({
]
});

export default logger;
module.exports = logger;
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ services:
links:
- mongo
mongo:
image: "mongo:3.4.2"
image: "mongo:3.4"
ports:
- "27017:27017"
60 changes: 0 additions & 60 deletions gulpfile.babel.js

This file was deleted.

12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import mongoose from 'mongoose';
import util from 'util';
const mongoose = require('mongoose');
const util = require('util');

// config should be imported before importing any other file
import config from './config/config';
import app from './config/express';
const config = require('./config/config');
const app = require('./config/express');

const debug = require('debug')('express-mongoose-es6-rest-api:index');

Expand All @@ -21,7 +21,7 @@ mongoose.connection.on('error', () => {
});

// print mongoose logs in dev env
if (config.MONGOOSE_DEBUG) {
if (config.mongooseDebug) {
mongoose.set('debug', (collectionName, method, query, doc) => {
debug(`${collectionName}.${method}`, util.inspect(query, false, 20), doc);
});
Expand All @@ -36,4 +36,4 @@ if (!module.parent) {
});
}

export default app;
module.exports = app;
10 changes: 6 additions & 4 deletions server/routes/index.route.js → index.route.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import express from 'express';
import userRoutes from './user.route';
import authRoutes from './auth.route';
const express = require('express');
const userRoutes = require('./server/user/user.route');
const authRoutes = require('./server/auth/auth.route');

const router = express.Router(); // eslint-disable-line new-cap

// TODO: use glob to match *.route files

/** GET /health-check - Check service health */
router.get('/health-check', (req, res) =>
res.send('OK')
Expand All @@ -15,4 +17,4 @@ router.use('/users', userRoutes);
// mount auth routes at /auth
router.use('/auth', authRoutes);

export default router;
module.exports = router;
Loading

0 comments on commit 8326d42

Please sign in to comment.