GithubHelp home page GithubHelp logo

madhums / node-express-mongoose Goto Github PK

View Code? Open in Web Editor NEW
1.4K 43.0 385.0 753 KB

A boilerplate application for building web apps using node and mongodb

License: MIT License

JavaScript 49.07% CSS 0.42% Dockerfile 1.81% Shell 32.40% Pug 16.19% Procfile 0.11%
mongoose passport nodejs boilerplate express node

node-express-mongoose's Introduction

tests Code Climate

Node Express Mongoose

A boilerplate application for building web apps using express, mongoose and passport.

Read the wiki to understand how the application is structured.

Usage

git clone https://github.com/madhums/node-express-mongoose.git
cd node-express-mongoose
npm install
cp .env.example .env
npm start

Checkout the apps that are 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.

npm i
cp .env.example .env

Start the services

docker-compose up -d

View the logs

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

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

docker-compose exec -e MONGODB_URL=mongodb://mongo:27017/noobjs_test node npm test

Note that we are overriding the environment variable set in .env file because we don't want our data erased by the tests.

Note: The difference between exec and run is that, exec executes the command within the running container and run will spin up a new container to run that command. So if you want to run only the tests without docker-compose up, you may do so by running docker-compose run -e MONGODB_URL=mongodb://mongo:27017/my_app_test node npm test

Deployment

If you want to deploy to heroku, you can follow this article

License

MIT

node-express-mongoose's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar iagowp avatar madhums avatar pratik60 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-express-mongoose's Issues

Error finding home.js

Hi.
Great app. I'm using this for a demo. Thanks for sharing it.
I think there's an error on config/routes.js line 13

var home = require('home')

should be

var home = require('../app/controllers/home')

Enabling CORS

Hi
Thank you for your time in creating this boilerplate app for us.
I want to use this app as REST API. How can I enable CORS on the project.

Thanks.

Linking social login with standalone websites

Hi Madhums

First of all what thank you for this wonderful boilerplate app. Loved the code segmentation.

The issue I have is not an issue with the app itself, which is running fine. My issue is that I am creating a standalone bootstrap site (not serving the html through node) and I am using your app as REST API. I want to signup using Facebook OAuth2. There is an option that I add the oauth script to my client app and then send the info I receive (email, name) to server.

But I want to use PassportJS to facilitate this signup. Is this possible with the structure that I have, or am I asking too much.

Thanks.

Getting error for middleware

I have installed all the middleware referred at https://github.com/senchalabs/connect#middleware but still getting the same error.. can you please help me resolve this

Error: Most middleware (like session) is no longer bundled with Express and must
be installed separately. Please see https://github.com/senchalabs/connect#middl
eware.
at Function.Object.defineProperty.get (C:\node\studio\node_modules\express\l
ib\express.js:89:13)
at module.exports (\node_modules\connect-mongo\lib\connect-mon
go.js:30:22)
at Object. (\config\express.js:6:42)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (\server.js:43:1)

I have error when I try "npm start"

Hello Madhums ,
I Downloaded last version and install "npm install" - Work good - ,
but when I try " npm start " get error
"
E:\NodeJS\node-Sherif>npm start
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules
npm\bin\npm-cli.js" "start"
npm ERR! node v0.12.6
npm ERR! npm v2.11.2
npm ERR! file E:\NodeJS\node-Sherif\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! No value found for key start at 22:14
npm ERR! "start": set "NODE_PATH=./config:./app/controllers NODE_ENV=development ./n
npm ERR! ^
npm ERR! File: E:\NodeJS\node-Sherif\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse
npm ERR! Please include the following file with any support request:
npm ERR! E:\NodeJS\node-Sherif\npm-debug.log
"

and when try "node server.js" get error too "

module.js:338
throw err;
^
Error: Cannot find module 'config'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object. (E:\NodeJS\node-Sherif\server.js:16:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
"

What Can I do For throw this problem
"I Work on Windows 8.1"

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Specify Express version in package.json

Hello.
package.json specifies a dependency on Express "latest" on line 18. The demo doesn't work in Express 4. Perhaps specify Express 3?

    "express": "3.x",

npm start does not work on windows

Hello!
Checked out your repo, npm install worked fine. However, npm start gives me

D:\Documents\node-express-mongoose>npm start
> [email protected] start D:\Documents\node-express-mongoose
> NODE_PATH=./app/controllers NODE_ENV=development ./node_modules/.bin/nodemon server.js

Der Befehl "NODE_PATH" ist entweder falsch geschrieben oder
konnte nicht gefunden werden. [Translation: The command "NODE_PATH" has a typo or couldn't be found]
npm ERR! weird error 1
npm ERR! not ok code 0

Windows 7 64 Bit, Node 0.10.15, npm 1.3.7
Node.exe & nmp are in PATH

Missing 'config' ?

This line of code:
var config = require('config');
exists in several places, e.g. server.js, local.js, express.js and maybe others.
The system will not compile.

On speculation, npm install --save config
just moves errors around.

Curious situation.

Error: Cannot find module 'config'

Hey Madhu, I am trying to run the app but getting the error "Error: Cannot find module 'config' in my console. Even when I try to load the config like 'var config = require('./config/config');' it throws the same error.

about upLoad Image

Hi Madhums ~

I hava a question about node-express-mongoose ,When I published an article, I uploaded a picture, it's wrong! if I published an article without uploaded ~It's nothings;
why?? can you tell me ?

   events.js:72
            throw er; // Unhandled 'error' event
                   ^
           Error: spawn ENOENT
                         at errnoException (child_process.js:980:11)
                        at Process.ChildProcess._handle.onexit (child_process.js:771:34)
           6 Oct 18:48:46 - [nodemon] app crashed - waiting for file changes before starting...

From a Chinese Boy ,use Google translate

Mac issue requiring models

// Bootstrap models
fs.readdirSync(__dirname + '/app/models').forEach(function (file) {
  require(__dirname + '/app/models/' + file)
})

On Mac is gonna find .DS_Store and force the app to crash because "." is considered ILLEGAL

/node-express-mongoose-master/app/models/.DS_Store:1
(function (exports, require, module, __filename, __dirname) { 
                                                              ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)

-quick fix requiring models manually

Custom get route

Hi Madhum,
We are working on top of your app(which is very nice) but we ran into a very weird problem, We have a controller and created a show method for it, the route is 'app.get("/:id/details, controller.action")' but when we hit the route from the browser we get errors, something on the lines of 'cast to objectID',

Will appreciate any kind of help.

Regards,
Babar Rehman

Latest version in package.json

Hi.
What is the reason for always using the latest versions of packages in package.json?
In some cases it could break application.

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.