evanhahn / express.js-in-action-code Goto Github PK
View Code? Open in Web Editor NEWCode from "Express.js in Action", a little book I wrote
Home Page: https://manning.com/hahn/?a_aid=express-in-action&a_bid=fe3fcff7
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
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.
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.
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.
`(!user.isModified("password"))
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?
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)
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 ?
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?
for the includes in index.ejs and new-entry.ejs in Chapter 3,
change from:
<% include header %>
to
<%- include('header'); %>
and likewise for footer
where:
"ejs": "^3.1.6",
"express": "^4.17.1",
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.