A Simple MVC Setup In Node.JS
2011-04-12 16:24
316 查看
文章来源:http://www.travisglines.com/
I’m sure many of you have heard about the new server side javascript
project called node.js. I’ve been using myself to build full stack
dynamic websites and find it a very nice environment to create a dynamic
website. When I first started out I had no idea what sort of way one
should create an MVC style framework with node or what modules would
help me to achieve the model, view, controller ideal. Heres my stack:
Node.js
(http://nodejs.org/
) of course
NPM
(http://npmjs.org/
) to easily install packages for node.
Express
(http://expressjs.com/
) – a very nice web development framework built on connect (allows “controllers”)
Mongoose
(http://mongoosejs.com/
) – a solid orm for mongodb in node.js that just released a much improved version (allows “models”)
Jade
(http://jade-lang.com/
) – a template engine for node that allows some cool shorthand (allows “views”)
Other tools were used of course but those were the essentials.
The application directory looks something like this:
Inside the application I instantiate express, include my mongoose
models and include my routes/controllers from the controllers directory
at the bottom. Inside the controllers I call res.render to render the
jade views and it all works very nicely. If people would like me to
elaborate on this more let me know.
A huge shoutout and thank you to the LearnBoost guys (TJ Holowaychuk,
Guillermo Rauch, Aaron Heckmann, and many more that aren’t associated
with LearnBoost) who’ve made Node.js web application development a
breeze.
I’m sure many of you have heard about the new server side javascript
project called node.js. I’ve been using myself to build full stack
dynamic websites and find it a very nice environment to create a dynamic
website. When I first started out I had no idea what sort of way one
should create an MVC style framework with node or what modules would
help me to achieve the model, view, controller ideal. Heres my stack:
Node.js
(http://nodejs.org/
) of course
NPM
(http://npmjs.org/
) to easily install packages for node.
Express
(http://expressjs.com/
) – a very nice web development framework built on connect (allows “controllers”)
Mongoose
(http://mongoosejs.com/
) – a solid orm for mongodb in node.js that just released a much improved version (allows “models”)
Jade
(http://jade-lang.com/
) – a template engine for node that allows some cool shorthand (allows “views”)
Other tools were used of course but those were the essentials.
The application directory looks something like this:
/app-root /models /views /controllers /public /tests /scripts /logs /tmp app.js
Inside the application I instantiate express, include my mongoose
models and include my routes/controllers from the controllers directory
at the bottom. Inside the controllers I call res.render to render the
jade views and it all works very nicely. If people would like me to
elaborate on this more let me know.
A huge shoutout and thank you to the LearnBoost guys (TJ Holowaychuk,
Guillermo Rauch, Aaron Heckmann, and many more that aren’t associated
with LearnBoost) who’ve made Node.js web application development a
breeze.
相关文章推荐
- A Simple Web Service In Node.Js + CouchDB
- Writing files in Node.js
- Is the built-in Promise of nodejs ready?
- Enable Password Resetting with Simple Membership in MVC 4
- Node.js 国产 MVC 框架 ThinkJS 开发 入门
- http://venkatbaggu.com/file-upload-in-asp-net-mvc-using-dropzone-js-and-html5/
- Node.js async in practice: When to use what?
- Node.js与Sails ~项目结构与Mvc实现及日志机制
- A Simple MVC Framework With Node and Express
- Debug in Node.js
- Node.js的原型继承函数 util.inherits
- what is app.use in NodeJS/Express
- Node.js: What is the best "full stack web framework" (with scaffolding, MVC, ORM, etc.) based on Node.js / server-side JavaScript? - Quora
- 10node.js工具类util.inherits和util.inspect
- Nodejs in Visual Studio Code 07.学习Oracle
- Node.js in Practice总结2
- detach process in nodejs
- node.js 之 Hello,World in Node !
- 基于AngularJS+NodeJS+Bootstrap+SpringMVC构建项目(1)