Git Product home page Git Product logo

node-express-mongoose-demo's Introduction

tests

Nodejs Express Mongoose Demo

This is a demo application illustrating various features used in everyday web development, with a fine touch of best practices. The demo app is a blog application where users can signup, create an article, delete an article and add comments etc.

Table of contents:

Boilerplate

Want to build something from scratch? use the boilerplate

Install

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

Then visit http://localhost:3000/

NOTE: Do not forget to set the twitter, google, linkedin and github CLIENT_IDs and SECRETs. In development env, you can set the env variables in .env and replace the values there. In production env, it is not safe to keep the ids and secrets in a file, so you need to set it up via commandline. If you are using heroku checkout how environment variables are set here.

Tests

npm test

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/noobjs_test node npm test

License

MIT

node-express-mongoose-demo's People

Contributors

alisanalacam avatar amragaey avatar anthonygore avatar anto-acube avatar bazh avatar birsi avatar brubrant avatar chaschev avatar dependabot[bot] avatar eseca avatar gotjosh avatar greenkeeper[bot] avatar greenkeeperio-bot avatar madhums avatar nickforddev avatar panzhangwang avatar pawe avatar raywire avatar recodify avatar shuding avatar yoshuawuyts 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  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

node-express-mongoose-demo's Issues

Add support for Mobile

I'm thinking if you were to have this customized for a mobile alternative, would you simply create a views-mobile, or would it be more involved than that?

Attachment upload to the blog app

The demo app is a very good starting point app..Is there anyway you can add the attachment upload and the tinymce editor to the blog app..

MissingSchemaError while deploying to Heroku

Hi;

My activity schema is:

 var ActivitySchema = new Schema({
    venue: {type : Schema.ObjectId, ref : 'Venue'}
    , user: {type : Schema.ObjectId, ref : 'User'}
     , createdAt: {type : Date, default : Date.now}
   })
  mongoose.model('Activity', ActivitySchema)

It is working in local. But when I deploy it to Heroku, I am getting:

2012-12-27T23:12:02+00:00 app[web.1]: MissingSchemaError: Schema hasn't been registered for model "Activity".
2012-12-27T23:12:02+00:00 app[web.1]: Use mongoose.model(name, schema)
2012-12-27T23:12:02+00:00 app[web.1]:     at Mongoose.model (/app/node_modules/mongoose/lib/index.js:261:13)
2012-12-27T23:12:02+00:00 app[web.1]:     at Object.<anonymous> (/app/app/models/user.js:8:25) 
2012-12-27T23:12:02+00:00 app[web.1]:     at Module._compile (module.js:449:26)
2012-12-27T23:12:02+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:467:10) 
2012-12-27T23:12:02+00:00 app[web.1]:     at Module.load (module.js:356:32)
2012-12-27T23:12:02+00:00 app[web.1]:     at Function.Module._load (module.js:312:12)
2012-12-27T23:12:02+00:00 app[web.1]:     at Module.require (module.js:362:17)
2012-12-27T23:12:02+00:00 app[web.1]:     at require (module.js:378:17)
2012-12-27T23:12:02+00:00 app[web.1]:     at /app/server.js:24:3
2012-12-27T23:12:02+00:00 app[web.1]:     at Array.forEach (native)
2012-12-27T23:12:04+00:00 heroku[web.1]: Process exited with status 1
2012-12-27T23:12:04+00:00 heroku[web.1]: State changed from starting to crashed

Any idea why I am getting this error?

Delete works in Safari but not Firefox

Am able to delete articles in Safari on Mac OS x, but not in Firefox. The confirmation dialog ("'Are you really sure you want to delete this item?'") appears, but inspecting in Firebug, no DELETE message is sent to the server.

Run app on cloudfoundry.com

Hello!
I'm try run app on cloudfoundry.com but it had problem with error

module.js:340
throw err;
^
Error: Cannot find module '/var/vcap/data/dea/apps/blogtest2-0-b62bf0c2012c6adcc1c866144d55e2be/app/NODE_ENV=development'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Can you tell me why?
Thank you!

Not able to execute npm install

$npm install -> npm not ok

npm http 304 https://registry.npmjs.org/mongoose/2.4.9
npm http 304 https://registry.npmjs.org/gzippo/0.1.2
npm WARN deprecated [email protected]: critical bug fixed in v0.1.4
npm http 304 https://registry.npmjs.org/yaml-config/0.1.0
npm ERR! git clone [email protected]:madhums/node-compress.git Cloning into /tmp/npm-1332758574868/1332758574868-0.8424466820433736...
npm ERR! git clone [email protected]:madhums/node-compress.git
npm ERR! git clone [email protected]:madhums/node-compress.git Permission denied (publickey).
npm ERR! git clone [email protected]:madhums/node-compress.git fatal: The remote end hung up unexpectedly

npm ERR! Error: git "clone" "[email protected]:madhums/node-compress.git" "/tmp/npm-1332758574868/1332758574868-0.8424466820433736" failed with 128
npm ERR! at ChildProcess. (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! at ChildProcess.emit (events.js:70:17)
npm ERR! at maybeExit (child_process.js:361:16)
npm ERR! at Socket. (child_process.js:466:7)
npm ERR! at Socket.emit (events.js:67:17)
npm ERR! at Array.0 (net.js:320:10)
npm ERR! at EventEmitter._tickCallback (node.js:192:40)
npm ERR! You may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]
npm ERR!
npm ERR! System Linux 3.0.0-16-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/abhishek/nodebase/demo
npm ERR! node -v v0.6.8
npm ERR! npm -v 1.1.0-2
npm ERR! message git "clone" "[email protected]:madhums/node-compress.git" "/tmp/npm-1332758574868/1332758574868-0.8424466820433736" failed with 128
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/abhishek/nodebase/demo/npm-debug.log
npm not ok

throw an exception when uploading image to S3

logs:

{ [Error: getaddrinfo ENOENT] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
[ '' ]

stream.js:81
throw er; // Unhandled stream error in pipe.
^
Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer as oncomplete


I am sure the S3 [key / secret / bucket / region] are correct in imager.js.

thanks.
/edgar

GoogleStrategy is not saving the user.google

in the user model.

var UserSchema = new Schema({
    name: String
    , email: String
    , username: String
    , provider: String
    , hashed_password: String
    , salt: String
    , facebook: {}
    , twitter: {}
    , github: {}
})

the , google: {} is missing.

However, after added, it can't create the user record.

any hints?

Extension with additional Model does not work

Hi, since some weeks I am experimenting with node and came across your very nice example. I am trying to extend this to work with socket.io, cluster, i18n and so on. First thing I tried was to create a new model of a “blog”.
Now here comes the catch: I created the model, controller, routes and extended the authorization following your best practices pattern. All works fine but when I save a new article the controller sometimes has the article ID or the blog ID in memory. It cannot differentiate between both models and constantly mixes them up randomly.

Would like to send the example to you but email bounces back.

Google-Login not working

Hey,

I cloned this projekt and followed the instructions.
I set up my googleId, googleSecret and my mongoUrl.

When i execute this code i cannot login via Google-Login.
I get the following error:

[Error: key $t must not start with '$']
Error: key $t must not start with '$'
at Error (unknown source)
at Function.checkKey (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:1419:11)
at serializeObject (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:355:14)
at packElement (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:359:15)
at packElement (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:343:15)
at packElement (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:359:15)
at packElement (/var/lib/stickshift/5136d6df5973ca3eab0003b4/app-root/data/426887/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)

I cannot push the google response to mongodb.

When i comment profile._json assigned to google
// , google: profile._json
everything is working fine.

Maybe it is more an mongoose error?
How to handle this error?

spawn ENOENT when uploading picture

node -v

v0.10.10

GET /articles/51da5bae0fd27eb10d000003/edit 200 63ms

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)

Number pages starting at 1 not 0

I love this demo! Thank you so much. It's very helpful.

There's a small problem with the pagination system: the first page number called 0, but the pagination control starts numbering at 1. Usually pagination systems have links like the following. Assuming we are on page three of a five-page list:

First: goes to first page
Prev: goes to previous (second) page
1: goes to first page
2: goes to second page
3: is not a link
4: goes to fourth page
5: goes to fifth page
Next: goes to next (fourth) page
Last: goes to last (fifth) page

Login not working after initial signup

On regular user signup, the registration is done and user gets logged just fine. But after user logsout and tries to login again with the same email/password, login fails with err: "Invalid email or password."

  • Trying this on localhost.
    Any idea what could be the cause?

Thanks
Amir

Error alert on Invalid login

Currently it is not showing the error on invalid login and just the page refreshes clearing up the email and password field.

connect-mongo vs connect-mongodb

for some reason i seem to be getting this error [1] on starting a copy of this app. I tracked it down to
this bit of code in config/express.js

app.use(express.session({
      secret: 'noobjs',
      store: new mongoStore({
        url: config.db,
        collection : 'sessions'
      })
    }))

looking at the mongoStore variable in config/express.js higher in the code we find:

  , mongoStore = require('connect-mongodb')

[2]^^

I can't seem to figure out what the difference between connect-mongo and connect-mongodb. If I change the module used in the project to from connect-mongodb to connect-mongo the nasty error [1] goes away. From what I've been able to find the two are forks of each other, with connect-mongo being more heavily updated. Is there a reason for choosing one over the other?

If not, I would propose changing to connect-mongo as it seems to be used more and is updated more recently, and it doesn't produce that error [1].

To change simply replace [2] in ``config/express.js` with this:

  , mongoStore = require('connect-mongo')(express)

as well as in the package.json

[1]

========================================================================================
=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowlegement                                                       =
=     journal: true/false, wait for flush to journal before acknowlegement             =
=     fsync: true/false, wait for flush to file system before acknowlegement           =
=                                                                                      =
=  For backward compatibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb.org/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowlegement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================```

Feature Request: EveryAuth

I'd love to see EveryAuth or some sort of Authentication implemented (preferably using password or openID).

Thanks for an awesome demo!

Get Error when Uploading Picture

Hi thanks for building this app, its been really helpful.

So I was trying to upload images with the node-imager linked to my S3 bucket.
I get an error saying "Have you installed graphicsmagick", when i try to upload an image.

I did the following:

  1. npm install gm - didnt work
  2. Downloaded/cloned the git - didnt work
  3. Change file name from gm to graphicsmagick - didnt work

Anyone have any idea whats causing it, or how to fix this?
Thanks its probably something simple.

Command line stack:
Express app started on port 3000
GET / 304 519ms
GET /articles/new 304 101ms
{ [Error: Command failed: CreateProcessW: The system cannot find the file specified.
** Have you installed graphicsmagick? **
] code: 127, signal: null }
[ '' ]

Why it is slow

I ran projects in local with mongolab db.

This project request took 900-1500ms, it is obviously slow than other project with same mongolab db , those projects' request only took only 100-200ms, including compoundjs project.

And I found every request called article function two times, for example, I put console.log in getTag and always seeing tags for 2 times by each request.

Why it is slow?

BTW, how does console show req.method and req routes info each request, I didn't find the middleware doing that.

Error when login with Google account

hello, i'm try login with Google authentication but error

Oops something went wrong

500
Error: key $t must not start with '$'
at Error ()
at Function.checkKey (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:1419:11)
at serializeObject (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:355:14)
at packElement (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:343:15)
at packElement (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:359:15)
at packElement (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)
at serializeObject (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:343:15)
at packElement (/app/node_modules/mongoose/node_modules/mongodb/node_modules/bson/lib/bson/bson.js:854:23)

Image Attach
untitled

Users with Multiple Social Accounts, how to handle?

This is one reason I've looked at Singly.com, which I think helps tie all of the user's different accounts together, although I haven't gotten that deep into the passport/node GitHub example, which doesn't use a DB but is only for authentication.

Would doing that with this app be possible? It's easy for users to forget which account they signed in with last time, and then they create a whole new account, and get frustrated at the fact that all the information they saved is gone(I'm developing an elearning app so they are saving all their data to the db).

I'll take another look at the singly example, and see if I could integrate it in this app - but this is way beyond my current js coding abilities!

yaml-config

Hi madhums,

I run app.js show error follow
module.js:337
throw new Error("Cannot find module '" + request + "'");
^
Error: Cannot find module 'yaml-config'
at Function._resolveFilename (module.js:337:11)
at Function._load (module.js:279:25)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object. (C:\E-Learning\1_development\1_code\Elearning_V1\app.js:16:19)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Array.0 (module.js:484:10)

I not yaml-config file,woudl you give me it

Thanks

TypeError: Cannot call method 'addComment' of undefined

at exports.create (d:\dev\node_apps\biosync\app\controllers\comments.js:18:11)

I don't know what I did, but I can't add comments anymore.

req.articles is always undefined.

exports.create = function (req, res) {
  var article = req.article;
  var user = req.user;
  console.log(req);
  if (!req.body.body) return res.redirect('/articles/'+ article.id);

  article.addComment(user, req.body, function (err) {
    if (err) return res.render('500');
    res.redirect('/articles/'+ article.id);
  });
};

Any ideas ? Thanks

NPM install error

npm install not ok

npm ERR! git clone ssh://git://github.com/madhums/node-compress.git cloning into /tmp/npm-1338396012955/1338396012955-0.1640495721548796....
npm ERR! git clone ssh://git://github.com/madhums/node-compress.git ssh: could not resolve hostname git:: Name or service not know
npm ERR! git clone ssh://git://github.com/madhums/node-compress.git fatal: the remote end hung up unexpectedly
npm ERR! ErrorL 'git' "clone" ssh://git://github.com/madhums/node-compress.git /tmp/npm-1338396012955/1338396012955-0.1640495721548796 failed with 128
npm ERR! at ChildProcess. (/usr/lib/node_modules/npm/lib/utils/exec.js:58:20)
npm ERR! at ChildProcess.emit (event.js:70:17)
npm ERR! at maybeExit (child_process.js:362:16)
.....
npm ERR! system Linux 3.0.0-12-generic
npm ERR! command 'node' '/usr/bin/npm' 'install'
npm ERR! node -v 0.6.18
npm ERR! npm -v 1.1.23

...
npm not ok

Use Chai over Should

I'm not too deep in the specifics, but wherever I go Chai seems to be the recommended library for Mocha tests. Maybe you could consider replacing Should with Chai.

Unable to run locally or on Appfrog. Heroku works.

It may seem pretty weird/trivial, but I'm able to upload any images locally, then the server hangs and there is no write to the database. On Appfrog, the images are uploaded to the S3 bucket but then it times out to a 502 Bad Gateway.

However, on Heroku I'm able to upload images and publish articles. Is there some configuration setting that I'm missing?

(Using a MongoHQ to host the database.)

Add production steps

It could be very cool if you add production steps like minimisation assets, several config for dev and prod and anything else

Thousands of Files in /tmp when trying to upload file

Using Ubuntu 12.04, I'm seeing a loop that is creating thousands of duplicate images and fillng up the /tmp directory. Imager successfully creates and uploads mini_ and detail_ files, but then goes nuts on the thumbnail (thumb_*), and all of those end up in the /tmp dir.

I think the problem is in the config/imager.js file. I will create a pull request if I get it sorted out.

TomV

Issue with first time setup of the app. when there are no users and Articles the index.jade gives error

I think u did not handled the articles properly in the index.jade.
for the first time article is null hence the jade parser throws this errors .

TypeError: C:\Program Files (x86)\nodejs\nodemdb\node-express-mongoose-demo\app\views\articles\index.jade:21
19| - var name = article.user ? article.user.name : {}
20|

21| a(href="/users/"+article.user._id)= name
22|   -  
23| - if (article.tags)
24| - each tag in article.tags.split(',')

Cannot read property '_id' of null

Passport Local Strategy Failure Messages

I've been playing around with this demo and it is very good. I have an issue with trying to display the error messages from the passport local strategy e.g. Unknown user, Invalid password

In passport.js the messages are being set correctly.
In reading up about Passport the messaging seem to use the deprecated flash messaging. These are triggered by setting the failureFlash variable in the routes file.

//current format
app.post('/users/session', passport.authenticate('local', {failureRedirect: '/login'}), users.session)
//failureFlash set to true
app.post('/users/session', passport.authenticate('local', {failureRedirect: '/login', failureFlash: true}), users.session)

As Express 3.x doesn't support flash messages the connect-flash module would be required. I have been playing around with this set-up but haven't been able to get the messages to display. Have you found a way to display the message using this approach or another approach?

wrong url path

You should modify:
$ git clone git://github.com/qed42/nodejs-express-mongoose-demo.git

To be:
$ git clone git://github.com/madhums/nodejs-express-mongoose-demo.git

In the readme

Routing with Socket.io

Hey there. Thank you so much for this example. I'm a noob at node and express so seeing this is awesome for 'best practices'. Thanks for posting!

I am attempting to add Socket.io into this project for some realtime updating, but, it looks like the routing is kicking back a 404 on the client-side line: <script src="/socket.io/socket.io.js"></script>

I'm not even sure that I'm on the right path to figuring this out, but my question is, how would you ignore that route (my guess is it's looking in /public/ ... which doesn't exist), and let it go through to wherever that file is (i'm not event sure where that is...)

Paging Issue

Hey, nice job on this. Very useful. Just noticed a small issue. If you select "9" or "10" on the pagination you get a 500 error. I've logged in a couple of times and played around a little. Seems to only happen on 9 or 10, 11 is fine.

config and mongostore

today i made a clone of your project and i found out some bugs/crashes:

  1. the config.js file is not loading
  2. the facebook variables called in passport.js is wrong (it's 'clientId' instead of 'appId')
  3. mongoStore is crashing and i could only get 500 page. can you tell me your working version of it?

thank you a lot

server crash

login ->logout -> new articles
the server will always crash.....

throw exception:
Error: Can't set headers after they are sent.
at ServerResponse. (http.js:523:11)
at ServerResponse.setHeader (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/node_modules/connect/lib/patch.js:62:20)
at next (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/node_modules/connect/lib/http.js:166:13)
at pass (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:219:24)
at nextRoute (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:209:7)
at callbacks (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:274:11)
at callbacks (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:277:9)
at callbacks (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:277:9)
at callbacks (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:277:9)
at callbacks (/Users/zj/Develop/NodeJS/qed42-nodejs-express-mongoose-demo-63c6fb4/node_modules/express/lib/router/index.js:277:9)

config and mongostore

today i made a clone of your project and i found out some bugs/crashes:

  1. the config.js file is not loading
  2. the facebook variables called in passport.js is wrong (it's 'clientId' instead of 'appId')
  3. mongoStore is crashing and i could only get 500 page. can you tell me your working version of it?

thank you a lot

Getting mongoose can not recompile error when modifying schema.

/home/emkei/projects/mg/node_modules/mongoose/lib/index.js:272
throw new mongoose.Error.OverwriteModelError(name);
^
OverwriteModelError: Cannot overwrite Resorts model once compiled.
at Mongoose.model (/home/emkei/projects/mg/node_modules/mongoose/lib/index.js:272:13)
at Object. (/home/emkei/projects/mg/app/models/resort.js:16:10)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at /home/emkei/projects/mg/server.js:16:3
at Array.forEach (native)

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.