I have existing code which implements an express middleware. How can I use this middleware in a Koa application?
When I try to call app.use(expressMiddleware) in order to use the middleware in my Koa app, Koa complains that a generator function is…
How do I redirect the user to a different route without redirecting the URL in vanilla Express? For example, if I have the routes
express = require('express');
app = express();
app.route('/old').get(function(req, res, next) {
…
I have been searching all over for how to do this - I am trying to redirect after a DELETE request is made - here is the code I am using WITHOUT THE REDIRECT:
exports.remove = function(req, res) {
var postId = req.params.id;
Post.remove({ _id:…
I created an application with
$ express -c stylus express_example
I can start my server with
$ npm start
but
$ node app.js
&
$ nodemon app.js
don't seem to work. I don't get any error messages though, terminal just goes to the next line. …
I have an index.jade in my 'views' folder.
doctype html
html
head
title= title
link(rel='stylesheet', href='/stylesheets/main.css')
script(src='../node_modules/some_package/package_script.min.js')
I have index.js in my routes folder…
I have created a new Express application. It generated app.js for me and I have then created the following index.js bringing in socket.io:
var app = require('./app');
server=app.listen(3000);
var io = require('socket.io');
var socket =…
In express 3 I use connect-mongo for session store.
var mongoStore = require('connect-mongo')(express);
But after I switched to express 4 it doesn't work. I got this error:
Error: Most middleware (like session) is no longer bundled with Express and…
I'm lost as to where this error is coming from, and I'm hoping you can help me. I'm new to node and am trying to resize an image with imagemagick:
var express = require('express'),
fs = require('fs'),
gm = require('gm'),
imagemagick =…
Let's say I am building a discussion forum using Node.js, and mongoose. A user can have multiple forums, and a forum can have multiple comments. A user can also invite other users to join a forum too. Thus, my question is about the model design…
I really apologize if I'm leaving something out and am totally stupid, but I've checked and checked over again a number of times, and the file upload functionality is just not working over here. I made a super minimal app to demonstate. Just…
I'm building an Express.js Node app and using Jade templates. Jade provides a :markdown filter which enables embedding Markdown code inside Jade:
h1 This is Jade
:markdown
## And this is Markdown
h3 Back in Jade
(Note: In order to use this filter…
I have been working on this problem for two days now, and I am stuck. I am using Node.js with Express, and I am trying to implement an upload form. Basically, I want the form to do the following:
Check the size of the file and cancel the upload if…
Maybe there is not a definitive answer here but I would like to know where to handle data validation when dealing with express.js and mongoose. Which of the following is the best practice (I currently use a combination and it's starting to feel very…
I am trying to create an ejs conditional based on a URL parameter, for example, if the test parameter exists at localhost:3000/page?test, then show a div, else dont show it.
My ejs template looks something like:
<% include header %>
What is the recommended technique for handling aggressive caching and URL fingerprinting in an NGINX (proxy) and Node / Express stack?
Google recommends to "use fingerprinting to dynamically enable caching." in their best practice guidelines and…