Category Archives: Nodejs

Modern Web Development

A list of technologies for modern web development.

Introduction

With this article I want to share a compilation of some well known top technologies that can be used today to develop a modern web application. The web development world has changed a lot because of its adaptation to the mobile and social media context, and a lot of new technologies, including servers, databases, development frameworks, and libraries have emerged to help us to  resolve several new problems and challenges.

Background

If you are a project manager, an architect, or a developer, you must choose the appropriate server, database,  language, framework or library for the design and implementation of the entire architecture or for some modules of your modern web application. This article references some of the principal and more used technologies that can help you to achieve this.

Servers

Nginx

Ngin is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Unlike traditional servers, Nginx doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load.

http://wiki.nginx.org/Main

NodeJs  

Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

http://nodejs.org 

Databases

MongoDb

MongoDB (from “humongous”) is an open-source  document database, and the leading NoSQL database, designed for ease of development and scaling. Instead of storing data in tables as is done in a “classical” relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.

http://www.mongodb.org 

Redis

Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets. In its outer layer, the Redis data model is a dictionary where keys are mapped to values. One of the main differences between Redis and other structured storage systems is that values are not limited to strings.

http://redis.io 

General purpose Frameworks / Libraries

Backbone.JS

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

http://backbonejs.org 

Underscore.Js

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It’s the tie to go along with jQuery’s tux, and Backbone.js’s suspenders.

 http://documentcloud.github.com/underscore 

Sencha frameworks

Sencha creates development frameworks and tools that help you design,  develop, and deploy applications for desktop and mobile devices. Their  goal is to enhance your development experience and final results by  providing well-structured, Web standards-based frameworks and tools that make drafting functional UI and CSS3 animations a breeze, and cloud  services for supporting your application available anytime, anywhere.

http://www.sencha.com/

Zepto.Js

Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. If you use jQuery, you already know how to use Zepto.

http://zeptojs.com

Angular JS

HTML enhanced for web apps! HTML is great for declaring static documents, but it falters when we try to use it for declaring dynamic views in web-applications. AngularJS lets you extend HTML vocabulary for your  application. The resulting environment is extraordinarily expressive, readable, and quick to develop.

http://angularjs.org

Bootstrap

Sleek, intuitive, and powerful front-end framework for faster and easier web development. Bootstrap utilizes LESS CSS, is compiled via Node, and is managed through GitHub to help nerds do awesome stuff on the web. Bootstrap was made to not  only look and behave great in the  latest desktop browsers (as well as IE7!), but in tablet and smartphone browsers via responsive CSS as well.

http://twitter.github.io/bootstrap

Specific Libraries

Modernizr

Modernizr is a small JavaScript library that detects the availability of native implementations for next-generation web technologies, i.e. features that stem from the HTML5 and CSS3 specifications. Many of these features are already implemented in at least one major browser (most of them in two or more), and what Modernizr does is, very simply, tell you whether the current browser has this feature natively implemented or  not.

http://modernizr.com

Knockout

Knockout is a JavaScript library that helps you to create rich, responsive display and editor user interfaces with a clean underlying data model. Any time you have sections of UI that update dynamically  (e.g., changing depending on the user’s actions or when an external data source changes), KO can help you implement it more simply and  maintainably.

http://knockoutjs.com 

Require.Js

RequireJS is a JavaScript file and module loader. It is optimized for in-browser use, but it can be used in other JavaScript environments,  like Rhino and Node. Using a modular script loader like RequireJS will  improve the speed and quality of your code.

http://requirejs.org 

Amplify Js

AmplifyJS solves the following problems:

  • AJAX Request Management: amplify.request provides a clean and elegant request abstraction for all types of data, even allowing for transformation prior to consumption.
  • Client Side Component Communication : amplify.publish/subscribe provides a clean, performant API for component to component communication.
  • Client Side Browser & Mobile Device Storage : amplify.store takes the  confusion out of HTML5 localStorage. It doesn’t get simpler than using amplify.store(key, data)! It even works flawlessly on mobile devices.
http://amplifyjs.com 

Moment.Js

A 4.8k JavaScript date library for parsing, validating, manipulating, and formatting dates.

http://momentjs.com 

D3 JS

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful  visualization components and a data-driven approach to DOM manipulation. http://d3js.org 

Breezze 

Breeze is a JavaScript library that helps you manage data in rich client applications. If you store data in a relational database, query and save those data as complex object graphs, and share these graphs across multiple screens of your JavaScript client, Breeze is for you.

http://www.breezejs.com/home 

Mongoose JS

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.  Woks fine with Node JS.

http://mongoosejs.com 

Meta -Languages

CoffeScript   

CoffeeScript is a little language that compiles into JavaScript. Underneath all those awkward braces and semicolons, JavaScript has always had a gorgeous object model at its heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

 http://coffeescript.org 

TypeScript

TypeScript is a language for application-scale JavaScript development. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. Any browser. Any host. Any OS. Open Source.

http://www.typescriptlang.org

Less

The dynamic stylesheet language. LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions.LESS runs on both the server-side (with Node.js and Rhino) or client-side (modern browsers only).

http://lesscss.org 

Application containers

PhoneGap (Apache Cordova)  

Is an HTML5 app platform that allows you to author native applications with web technologies and get access to APIs and app stores. PhoneGap leverages web technologies developers already know best… HTML and JavaScript.

http://www.phonegap.com 

AppCelerator

Create rich native iOS, Android, hybrid, and mobile web apps from a single JavaScript-based SDK. Titanium empowers you to choose the right way to reach your end users on any device.

http://www.appcelerator.com 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

from:http://www.codeproject.com/Reference/597538/Modern-Web-Development

nodejs 快速入门

node.js开发指南.pdf

 

开篇:如果你还不知道Node.js是什么,那么你可以先看看这篇:Node.js 究竟是什么?或者任何关于它的介绍。

第一步:安装Node.js

Node官网下载安装包进行安装(这里使用的是Windows环境)

安装完成后进入cmd输入”node+ender“测试是否安装成功

PS:两次ctrl+c退出node

第二步:安装全局支持包

仍然是在cmd中输入以下命令(注意:一定要退出node)

npm install express@3.26 -g  //express是node中最常用的web框架,如果安装不了则更改镜像,命令:npm set registry http://registyr.npmjs.org

npm install nodemon -g //nodemon用于实时监听app.js文件

npm install grunt-cli -g  //grunt是一款任务构建工具,可以使用它完成自动编译/压缩等工作

npm install bower -g   //bower是一款页面引入文件管理工具

PS:npm是node的包管理器,使用它安装/卸载支持包非常方便

PS:安装完成后,均可以通过输入”包名称 – h“测试是否安装成功及查看使用帮助

第三步:创建Web项目

使用命令或手动在相应磁盘下创建用于放置项目的文件夹(cmd命令大全)

这里使用的是本机D盘下的apps文件夹

执行”express APPNAME“命令,进行项目创建(这里以TEST作为项目名称)

PS:public中是我们熟悉的images、javascript、CSS

PS:routes是路由文件

PS:views中视图文件,express默认使用的模板引擎是jade

第四步:完善项目架构

  使用任意的文本编辑器打开package.json文件,可以看到:

项目中已经有了express和jade,但我们想要完成项目,这些还远远不够,

我们会需要像watch、less、copy等等这样的包来进行辅助

你可以像我一样直接把它们全部写入到这个文件里,像这样:

当然:你也可以根据自己的需要,一个个进行安装,但记得在你的npm命令中不需要再使用 -g 了

好了,现在执行”cd appname && npm install“命令

PS:很明显,它的意思是进入项目的同时检测package.json文件安装里面列举出的所有包

  PS:这样是不是很省事儿,免去了一条条的npm install …命令

好的,接下来,你需要创建一个”Gruntfile.js“文件放在package.json的同级目录下,

你可以把这里的代码拷贝,做一些相应的改动即可

它用于控制那些需要执行的包,比如它们:

第五步:规范化前端引入文件

  前端总会因为各种原因,而需要引入一些文件支持

我们熟悉的就有jQueryBootstraphtml5shivrespond

这些文件愈多,当我们管理、更换版本时就愈不方便

这时,前面安装的bower就起到作用了,可以这么做:

在public文件夹下创建”bower.json“文件

它的写法就像这样:——代码你可以在bower官网首页找到

紧接着,再创建”.bowerrc“文件控制它们的存放目录(比如放到当前目录的libs文件夹下)

里面写上这么一条就行:

好嘞,现在在该目录下执行”cd public && bower install“命令

原理还是那样:进入public的同时检测bower.json文件,下载所有列举的文件,放入.bowerrc文件指定的目录

第六步:启动

使用cmd在app.js文件所在位置,执行”nodemon app.js“命令

这时,就可以在浏览器中输入 localhost:3000 来试试你的成果了

如果,你希望改动了某些文件(比如coffe、less等)后,会自动进行编译等操作,

那得再开启grunt的监听:

新开一个cmd,执行”grunt watch“命令,像这样:

PS:想要执行watch命令,一定要安装相应的包哦 ^_^

 

总结:在Node.js下搭建项目,难免会跟大量的包打交道,搞清楚它们的作用,按需使用。

参考:
How to install Node.js and NPM on Windows

Node.js Get Started and Miscellaneous

Basics of Node.js for MEAN Stack Development
from:http://www.cnblogs.com/prolifes/articles/3659623.html