basemkhirat / express-mvc Goto Github PK
View Code? Open in Web Editor NEWA light-weight mvc pattern for express framework with minimum dependencies
A light-weight mvc pattern for express framework with minimum dependencies
hi great job, but i think
nodemon and reload is missing
Hello,
I am using your mvc solution and I get the [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
error sometimes.
Here is an example:
0|server | Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
0|server | at ServerResponse.setHeader (_http_outgoing.js:470:11)
0|server | at ServerResponse.header (/var/www/scrapper-node/node_modules/express/lib/response.js:767:10)
0|server | at ServerResponse.send (/var/www/scrapper-node/node_modules/express/lib/response.js:170:12)
0|server | at done (/var/www/scrapper-node/node_modules/express/lib/response.js:1004:10)
0|server | at tryHandleCache (/var/www/scrapper-node/node_modules/ejs/lib/ejs.js:257:5)
0|server | at View.exports.renderFile [as engine] (/var/www/scrapper-node/node_modules/ejs/lib/ejs.js:482:10)
0|server | at View.render (/var/www/scrapper-node/node_modules/express/lib/view.js:135:8)
0|server | at tryRender (/var/www/scrapper-node/node_modules/express/lib/application.js:640:10)
0|server | at Function.render (/var/www/scrapper-node/node_modules/express/lib/application.js:592:3)
0|server | at ServerResponse.render (/var/www/scrapper-node/node_modules/express/lib/response.js:1008:7)
0|server | at ServerResponse.res.render (/var/www/scrapper-node/node_modules/express-flash/lib/express-flash.js:29:16)
0|server | at ServerResponse.res.render (/var/www/scrapper-node/app/kernel.js:129:20)
0|server | at index (/var/www/scrapper-node/app/controllers/VideoController.js:13:28)
0|server | at process._tickCallback (internal/process/next_tick.js:68:7)
VideoController.js looks like this:
module.exports = {
/**
* @param {Object} req
* @param {Object} res
* @param {Function} next
*/
index: async(req, res, next) => {
const id = req.params.id
if(typeof id === 'undefined') return res.notFound('Invalid video id')
try {
const cached = await CacheService.get(id)
if (cached) {
return res.render('video', JSON.parse(cached)) ### // Here is line 13
}
else {
const video = await Video.findById(id)
if (video === null) return res.notFound('Video not found')
const links = VideoStreamService.create(req, res, id, video)
if (links.status === 500) {
return res.notFound('No active sources found')
}
CacheService.set(id, JSON.stringify({
links: links.data
}))
return res.render('video', {
links: links.data
})
}
}
catch (err) {
// next(err)
return res.badRequest('Temporary error. Try again later or choose another mirror.')
}
},
}
great quickstart code , but can you plz add a fix for the producion env : i got
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
maybe something in
app.use(require("express-session")(_config("session")));
Please merge the changes of mongoose branch to master so that we could get updated npm versions for which I've been waiting from so long
I've been using this module to design my application's folder structure. Its working fine. But now it's giving errors when am using some other modules which are dependent on mongoose and mongodb. This module still has older versions of mongoose and mongodb as it wasn't updated in last 2 years. But I've to update the mongoose to the newest version as per my requirements. But I couldn't able to do that. I've got mongoose and mongodb modules as part of this module. How to update both mongo db and mongoose node modules?
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.