Giter Site home page Giter Site logo

evanhahn / express.js-in-action-code Goto Github PK

View Code? Open in Web Editor NEW
169.0 15.0 85.0 283 KB

Code from "Express.js in Action", a little book I wrote

Home Page: https://manning.com/hahn/?a_aid=express-in-action&a_bid=fe3fcff7

JavaScript 77.77% CSS 1.22% HTML 21.01%

express.js-in-action-code's Introduction

This is the code from the book Express.js in Action.

I've provided a Vagrant virtual machine with Node (installed with nvm), the Express application generator, and MongoDB. To use it, install Vagrant, and then:

vagrant up   # to start the virtual machine
vagrant ssh  # to SSH into the virtual machine
cd /vagrant  # to get to the code

Note that many of the dependencies in this project are out of date, as the book is now several years old. Please upgrade to newer versions if using this code for real!

express.js-in-action-code's People

Contributors

evanhahn avatar madriver44 avatar mikeshhoffman 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

express.js-in-action-code's Issues

isModified("password" ) return true if it is modified.


from mongooes doc :

Document.prototype.isModified()
Parameters
[path] «String» optional
Returns:
«Boolean»
Returns true if any of the given paths is modified, else false. If no arguments, returns true if any path in this document is modified.


So how could the below function return true if we set the password for the first time.

`(!user.isModified("password"))

Erratum on page 175

The screenshot describing use of JSHINT in a text editor, specified "Sublime Text Editior" is not actually Sublime Text but Atom Editor if looked carefully on the logo adjacent to file name on title bar of text editor.

Body of guestbook entry doesn't appear in guestbook

In Express.js-in-Action-code/Chapter_03/guestbook/views/index.ejs
<%= entry.content %>
should be
<%= entry.body %>
since app.js pushes the object member name "body" into the array of entries:
entries.push({
title: req.body.title,
body: req.body.body,
Otherwise, the body of the guestbook entry isn't shown in the guestbook; only the title of the entry is shown.

best-practice: cluster

In your ebook you didn't mentioned the "cluster" module, to speed up express apps exploiting the multi-core architectures.
Can't this be considered a best practice?

Unknown authentication strategy "login"

After adding new user I am getting the following error

Error: Unknown authentication strategy "login"
    at attempt (D:\express_learn\LAM\node_modules\passport\lib\middleware\authenticate.js:166:37)
    at authenticate (D:\express_learn\LAM\node_modules\passport\lib\middleware\authenticate.js:342:7)
    at Layer.handle [as handle_request] (D:\express_learn\LAM\node_modules\express\lib\router\layer.js:95:5)
    at next (D:\express_learn\LAM\node_modules\express\lib\router\route.js:137:13)
    at D:\express_learn\LAM\node_modules\mongoose\lib\model.js:3800:16
    at D:\express_learn\LAM\node_modules\mongoose\lib\services\model\applyHooks.js:150:20
    at _combinedTickCallback (internal/process/next_tick.js:95:7)
    at process._tickCallback (internal/process/next_tick.js:161:9)

Why is that ?

Unknow authentication strategy "login"

Error: Unknown authentication strategy "login"
at attempt (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\passport\lib\middleware\authenticate.js:193:39)
at authenticate (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\passport\lib\middleware\authenticate.js:370:7)
at exports.postSignIn (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\controllers\auth.js:47:6)
at Layer.handle [as handle_request] (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\route.js:144:13)
at Route.dispatch (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\route.js:114:3)
at Layer.handle [as handle_request] (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\index.js:284:15
at Function.process_params (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\index.js:346:12)
at next (C:\Users\HP\Documents\personal\AltSchool\nodejs\blogging api\node_modules\express\lib\router\index.js:280:10)

The chapter 8 code does not render

I have copied the code exactly as it is listed in github, but I get this error everytime:

SyntaxError: Unexpected identifier in /app/views/index.ejs while compiling ejs

I think the issue is with the include statements, I don't think they're in the correct format, but I couldn't figure out what they should be based off the ejs docs. If I remove the include for the header and footer and copy the contents of _header and _footer into index.ejs, I get the following error:

    32|     
    33|     <div class="container">
 >> 34|       <% errors.forEach(function(error){ %>
    35|         <div class="alert alert-danger" role="alert">
    36|           <%= error %>
    37|         </div>

errors is not defined

What does error reference? When I looked at the routes, I didn't see where error was defined, can you help?

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.