Skip to content

Commit 8326d42

Browse files
authored
Merge pull request #442 from kunalkapadia/develop
Update node and remove gulp, babel.
2 parents ddf6d0e + 3536307 commit 8326d42

23 files changed

+647
-2136
lines changed

.istanbul.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
verbose: false
22
instrumentation:
3-
excludes: ['dist/**', 'coverage/**', 'gulpfile.babel.js']
3+
excludes: ['dist/**', 'coverage/**', 'index.js']
44
include-all-sources: true
55
reporting:
66
print: summary

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
language: node_js
22
node_js:
3-
- "4.8"
4-
- "6.10"
5-
- "7.6"
3+
- "8.10"
4+
- "9.9"
65
services:
76
- mongodb
87
cache:
@@ -14,3 +13,6 @@ script:
1413
- yarn test:check-coverage
1514
after_script:
1615
- yarn report-coverage
16+
before_install:
17+
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.5.1
18+
- export PATH=$HOME/.yarn/bin:$PATH

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# take default image of node boron i.e node 6.x
2-
FROM node:6.10.1
1+
# Use latest node version 8.x
2+
FROM node:8.10.0
33

44
MAINTAINER Kunal Kapadia <[email protected]>
55

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# 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)
22

3-
[![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)
4-
[![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)
5-
[![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)
6-
[![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)
7-
[![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)
3+
[![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)
4+
[![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)
5+
[![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)
6+
[![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)
7+
[![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)
88
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/)
99
[![MIT License](https://img.shields.io/npm/l/stack-overflow-copy-paste.svg?style=flat-square)](http://opensource.org/licenses/MIT)
1010
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
1111
[![Support via Paypal](https://img.shields.io/badge/support-paypal-yellowgreen.svg?style=flat-square)](https://www.paypal.me/KunalKapadia)
1212

13-
[![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)
13+
[![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)
1414

15-
# [![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)
15+
# [![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)
1616

1717
## Overview
1818

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

4545
Clone the repo:
4646
```sh
47-
git clone [email protected]:KunalKapadia/express-mongoose-es6-rest-api.git
47+
git clone [email protected]:kunalkapadia/express-mongoose-es6-rest-api.git
4848
cd express-mongoose-es6-rest-api
4949
```
5050

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

148148
## Docker
149149

150+
#### Using Docker Compose for Development
150151
```sh
151-
# For Development
152152
# service restarts on file change
153-
1. bash bin/development.sh
153+
bash bin/development.sh
154154
```
155155

156+
#### Building and running without Docker Compose
157+
```bash
158+
# To use this option you need to make sure mongodb is listening on port 27017
159+
160+
# Build docker
161+
docker build -t express-mongoose-es6-rest-api .
162+
163+
# Run docker
164+
docker run -p 4040:4040 express-mongoose-es6-rest-api
165+
```
166+
167+
156168
## A Boilerplate-only Option
157169

158170
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.
@@ -166,7 +178,7 @@ If you would prefer not to use any of our tooling, delete the following files fr
166178
Contributions, questions and comments are all welcome and encouraged. For code contributions submit a pull request with unit test.
167179

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

171183
## Support Development
172184
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)
@@ -175,5 +187,5 @@ Your support is greatly appreciated.
175187

176188
## Meta
177189

178-
Kunal Kapadia – [@kunalkapadia12](https://twitter.com/KunalKapadia12)[email protected]
190+
Kunal Kapadia – [@kunalkapadia12](https://twitter.com/kunalkapadia12)[email protected]
179191

config/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Joi from 'joi';
1+
const Joi = require('joi');
22

33
// require and configure dotenv, will load vars in .env in PROCESS.ENV
44
require('dotenv').config();
@@ -41,4 +41,4 @@ const config = {
4141
}
4242
};
4343

44-
export default config;
44+
module.exports = config;

config/express.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import express from 'express';
2-
import logger from 'morgan';
3-
import bodyParser from 'body-parser';
4-
import cookieParser from 'cookie-parser';
5-
import compress from 'compression';
6-
import methodOverride from 'method-override';
7-
import cors from 'cors';
8-
import httpStatus from 'http-status';
9-
import expressWinston from 'express-winston';
10-
import expressValidation from 'express-validation';
11-
import helmet from 'helmet';
12-
import winstonInstance from './winston';
13-
import routes from '../server/routes/index.route';
14-
import config from './config';
15-
import APIError from '../server/helpers/APIError';
1+
const express = require('express');
2+
const logger = require('morgan');
3+
const bodyParser = require('body-parser');
4+
const cookieParser = require('cookie-parser');
5+
const compress = require('compression');
6+
const methodOverride = require('method-override');
7+
const cors = require('cors');
8+
const httpStatus = require('http-status');
9+
const expressWinston = require('express-winston');
10+
const expressValidation = require('express-validation');
11+
const helmet = require('helmet');
12+
const winstonInstance = require('./winston');
13+
const routes = require('../index.route');
14+
const config = require('./config');
15+
const APIError = require('../server/helpers/APIError');
1616

1717
const app = express();
1818

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

87-
export default app;
87+
module.exports = app;

config/param-validation.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Joi from 'joi';
1+
const Joi = require('joi');
22

3-
export default {
3+
module.exports = {
44
// POST /api/users
55
createUser: {
66
body: {

config/winston.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import winston from 'winston';
1+
const winston = require('winston');
22

33
const logger = new (winston.Logger)({
44
transports: [
@@ -9,4 +9,4 @@ const logger = new (winston.Logger)({
99
]
1010
});
1111

12-
export default logger;
12+
module.exports = logger;

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ services:
3333
links:
3434
- mongo
3535
mongo:
36-
image: "mongo:3.4.2"
36+
image: "mongo:3.4"
3737
ports:
3838
- "27017:27017"

gulpfile.babel.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import mongoose from 'mongoose';
2-
import util from 'util';
1+
const mongoose = require('mongoose');
2+
const util = require('util');
33

44
// config should be imported before importing any other file
5-
import config from './config/config';
6-
import app from './config/express';
5+
const config = require('./config/config');
6+
const app = require('./config/express');
77

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

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

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

39-
export default app;
39+
module.exports = app;
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
import express from 'express';
2-
import userRoutes from './user.route';
3-
import authRoutes from './auth.route';
1+
const express = require('express');
2+
const userRoutes = require('./server/user/user.route');
3+
const authRoutes = require('./server/auth/auth.route');
44

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

7+
// TODO: use glob to match *.route files
8+
79
/** GET /health-check - Check service health */
810
router.get('/health-check', (req, res) =>
911
res.send('OK')
@@ -15,4 +17,4 @@ router.use('/users', userRoutes);
1517
// mount auth routes at /auth
1618
router.use('/auth', authRoutes);
1719

18-
export default router;
20+
module.exports = router;

0 commit comments

Comments
 (0)