Skip to content

Commit

Permalink
update to pug, add docker, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
madhums committed Mar 13, 2019
1 parent 0674cb5 commit 39664db
Show file tree
Hide file tree
Showing 36 changed files with 7,039 additions and 219 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["stage-0"]
"presets": []
}
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SOME_ENV_ID=abc
MONGODB_URL=mongodb://mongo:27017/my_app_dev
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.vscode
.git
public
data
18 changes: 5 additions & 13 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
{
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:prettier/recommended"],
"env": {
"browser": false,
"es6": true,
"node": true
},
"parser": "babel-eslint",
"rules": {
"object-curly-spacing": [2, "always"],
"strict": 0,
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"space-before-function-paren": [2, "always"],
"keyword-spacing": [2, {"before": true, "after": true}],
"space-infix-ops": 2,
"spaced-comment": [2, "always"],
"arrow-spacing": 2,
"no-console": 0
},
"globals": {
"prettier/prettier": ["error", {
"singleQuote": true
}],
"no-console": "off"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
npm-debug.log
.env
data
.vscode
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ services:
- mongodb
language: node_js
node_js:
- "6.0.0"
- "6.1.0"
- "10.11.0"
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[![Build Status](https://img.shields.io/travis/madhums/node-express-mongoose.svg?style=flat)](https://travis-ci.org/madhums/node-express-mongoose)
[![Dependencies](https://img.shields.io/david/madhums/node-express-mongoose.svg?style=flat)](https://david-dm.org/madhums/node-express-mongoose)
[![Code Climate](https://codeclimate.com/github/madhums/node-express-mongoose/badges/gpa.svg)](https://codeclimate.com/github/madhums/node-express-mongoose)
[![Code Climate](https://codeclimate.com/github/codeclimate/codeclimate/badges/gpa.svg)](https://codeclimate.com/github/madhums/node-express-mongoose)
[![Greenkeeper badge](https://badges.greenkeeper.io/madhums/node-express-mongoose.svg)](https://greenkeeper.io/)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/madhums/node-express-mongoose?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Gittip](https://img.shields.io/gratipay/madhums.svg?style=flat)](https://www.gratipay.com/madhums/)

## Node Express Mongoose

Expand All @@ -21,6 +20,41 @@ Read the [wiki](https://github.com/madhums/node-express-mongoose/wiki) to unders

Checkout the [apps that are built using this approach](https://github.com/madhums/node-express-mongoose/wiki/Apps-built-using-this-approach)

## Docker

You can also use docker for development. Make sure you run npm install on your host machine so that code linting and everything works fine.

```sh
$ npm i
$ cp .env.example .env
```

Start the services

```sh
$ docker-compose up -d
```

View the logs

```sh
$ docker-compose logs -f
```

In case you install a npm module while developing, it should also be installed within docker container, to do this first install the module you want with simple `npm i module name`, then run it within docker container

```sh
$ docker-compose exec node npm i
```

If you make any changes to the file, nodemon should automatically pick up and restart within docker (you can see this in the logs)

To run tests

```sh
$ docker-compose exec node npm test
```

## License

MIT
3 changes: 1 addition & 2 deletions app/controllers/home.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

/*!
* Module dependencies.
*/

exports.index = function (req, res) {
exports.index = function(req, res) {
res.render('home/index', {
title: 'Node Express Mongoose Boilerplate'
});
Expand Down
16 changes: 2 additions & 14 deletions app/models/user.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

/*!
* Module dependencies
*/

var mongoose = require('mongoose');
var userPlugin = require('mongoose-user');
var Schema = mongoose.Schema;

/**
Expand All @@ -18,12 +16,6 @@ var UserSchema = new Schema({
salt: { type: String, default: '' }
});

/**
* User plugin
*/

UserSchema.plugin(userPlugin, {});

/**
* Add your
* - pre-save hooks
Expand All @@ -35,17 +27,13 @@ UserSchema.plugin(userPlugin, {});
* Methods
*/

UserSchema.method({

});
UserSchema.method({});

/**
* Statics
*/

UserSchema.static({

});
UserSchema.static({});

/**
* Register
Expand Down
2 changes: 1 addition & 1 deletion app/views/404.jade → app/views/404.pug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends layouts/default.jade
extends layouts/default.pug

block main
h2 404 - Not found
2 changes: 1 addition & 1 deletion app/views/500.jade → app/views/500.pug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends layouts/default.jade
extends layouts/default.pug

block main
h2 500 - Oops! Internal server error occured
Expand Down
4 changes: 2 additions & 2 deletions app/views/home/index.jade → app/views/home/index.pug
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends ../layouts/default.jade
extends ../layouts/default.pug

block page-header
h2 Todo
Expand All @@ -7,4 +7,4 @@ block content
ol
li Awesome! Now add some routes, models, views and controllers.
li Change the content of 
code app/views/home/index.jade
code app/views/home/index.pug
File renamed without changes.
File renamed without changes.
15 changes: 0 additions & 15 deletions app/views/includes/head.jade

This file was deleted.

14 changes: 14 additions & 0 deletions app/views/includes/head.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge,chrome=1")
meta(name="viewport", content="width=device-width,initial-scale=1")

if title
title= title
else
title= pkg.name

meta(name="description", content=pkg.description)

link(rel='stylesheet' href='https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css' integrity='sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T' crossorigin='anonymous')
link(rel="stylesheet" href="/css/app.css")
6 changes: 0 additions & 6 deletions app/views/includes/header.jade

This file was deleted.

8 changes: 8 additions & 0 deletions app/views/includes/header.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
nav.navbar.navbar-expand-md.navbar-dark.fixed-top.bg-dark
a.navbar-brand(href='/') Your App
button.navbar-toggler(type='button' data-toggle='collapse' data-target='#navbarCollapse' aria-controls='navbarCollapse' aria-expanded='false' aria-label='Toggle navigation')
span.navbar-toggler-icon
#navbarCollapse.collapse.navbar-collapse
ul.navbar-nav.mr-auto
li(class=isActive('/') ? 'active nav-item' : 'nav-item')
a.nav-link(href="/" title="Home") Home
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
if info && info.length
div(class='fade in alert alert-info')
.fade.show.alert.alert-info
button(class='close' type='button' data-dismiss='alert') ×
ul
for inf in info
li #{ inf }

if errors && errors.length
div(class='fade in alert alert-danger')
.fade.show.alert.alert-danger
button(class='close' type='button' data-dismiss='alert') ×
ul
for error in errors
li #{ error }

if success && success.length
div(class='fade in alert alert-success')
.fade.show.alert.alert-success
button(class ='close' type='button' data-dismiss='alert') ×
ul
for succ in success
li #{ succ }

if warning && warning.length
div(class='fade in alert alert-warning')
.fade.show.alert.alert-warning
button(class='close' type='button' data-dismiss='alert') ×
ul
for warn in warning
li #{ warn }
li #{ warn }
14 changes: 0 additions & 14 deletions app/views/layouts/default.jade

This file was deleted.

14 changes: 14 additions & 0 deletions app/views/layouts/default.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
doctype html
html(lang="en")
include ../includes/head.pug
body
include ../includes/header.pug
.container
.page-header
block page-header
.messages
include ../includes/messages.pug
.content
block content
include ../includes/footer.pug
include ../includes/foot.pug
11 changes: 3 additions & 8 deletions config/env/development.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@

/**
* Expose
*/

module.exports = {
db: 'mongodb://localhost/your_project_development',
db: process.env.MONGODB_URL || 'mongodb://localhost/my_app_development',
facebook: {
clientID: 'APP_ID',
clientSecret: 'SECRET',
callbackURL: 'http://localhost:3000/auth/facebook/callback',
scope: [
'email',
'user_about_me',
'user_friends'
]
scope: ['email', 'user_about_me', 'user_friends']
},
google: {
clientID: 'APP_ID',
Expand All @@ -22,7 +17,7 @@ module.exports = {
scope: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.google.com/m8/feeds',
'https://www.google.com/m8/feeds'
]
}
};
11 changes: 3 additions & 8 deletions config/env/production.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@

/**
* Expose
*/

module.exports = {
db: 'mongodb://localhost/your_project_production',
db: process.env.MONGODB_URL || 'mongodb://localhost/my_app_production',
facebook: {
clientID: 'APP_ID',
clientSecret: 'SECRET',
callbackURL: 'http://localhost:3000/auth/facebook/callback',
scope: [
'email',
'user_about_me',
'user_friends'
]
scope: ['email', 'user_about_me', 'user_friends']
},
google: {
clientID: 'APP_ID',
Expand All @@ -22,7 +17,7 @@ module.exports = {
scope: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.google.com/m8/feeds',
'https://www.google.com/m8/feeds'
]
}
};
11 changes: 3 additions & 8 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@

/**
* Expose
*/

module.exports = {
db: 'mongodb://localhost/your_project_test',
db: process.env.MONGODB_URL || 'mongodb://localhost/my_app_test',
facebook: {
clientID: 'APP_ID',
clientSecret: 'SECRET',
callbackURL: 'http://localhost:3000/auth/facebook/callback',
scope: [
'email',
'user_about_me',
'user_friends'
]
scope: ['email', 'user_about_me', 'user_friends']
},
google: {
clientID: 'APP_ID',
Expand All @@ -22,7 +17,7 @@ module.exports = {
scope: [
'https://www.googleapis.com/auth/userinfo.profile',
'https://www.googleapis.com/auth/userinfo.email',
'https://www.google.com/m8/feeds',
'https://www.google.com/m8/feeds'
]
}
};
Loading

0 comments on commit 39664db

Please sign in to comment.