[Hapi.js] Managing State with Cookies】的更多相关文章

hapi has built-in support for parsing cookies from a request headers, and writing cookies to a response, making state management easy and straight-forward. It even has built in support for cookie encryption and auto detects when a cookie contains JSO…
 状态模式,在大的范畴中的定义为当一个对象的内在状态改变时允许改变其行为,这个对象看起来像是改变了其类.每种编程语言有不同的实现方式,运用的范围也多用于游戏之中. 这里我用javascript来模拟状态模式,主要思想是通过事件监听的效果来控制一个主要对象的状态.那么何为事件监听的效果呢?在其他语言中,可以通过多个对象的协作来完成状态模式,而我在javascript中可以通过对DOM节点进行事件操控来传递消息,使主要对象接收消息(当然不同状态接收到的消息所产生的反应是不一样的).而在javascr…
View engines, or template engines, allow you to maintain a clean separation between your presentation layer and the rest of your application. This post will demonstrate how to use the vision plugin with hapi to enable template support. index.js serve…
hapi is a rock solid server framework for Node.js. Its focus on modularity and configuration-over-convention makes it the perfect match for any size development team. Install: npm install --save hapi index.js 'use strict' var Hapi = require( 'hapi' )…
The scan operator in RxJS is the main key to managing values and states in your stream. Scan behaves just as a reduce function would, but scan is able to collect values from streams over time. This lesson covers using startWith to set the initial acc…
hapi supports request validation out of the box using the joi module. Request path parameters, payloads, and querystring parameters can be validated with joi's simple, 'use strict' const Hapi = require('hapi') const Joi = require('joi') const server…
hapi automatically responds with JSON for any error passed to a route's reply()method. But what if your application needs errors rendered in HTML? This lesson shows how to implement friendly HTML error messages using hapi extension events. const Hapi…
Instead of using middlware, hapi provides a number of points during the lifecycle of a request that you can hook-in to provide additional functionality, called "extension events". This lesson will give you an introduction to using extension even…
hapi makes handling POST and PUT payloads easy by buffering and parsing them automatically without requiring additional modules or middleware. This post will demonstrate how to handle JSON and form based request payloads via hapi's route configuratio…
hapi does not support serving static files out of the box. Instead it relies on a module called Inert. This lesson will cover serving static files using Inert's custom handlers. 'use strict' var Hapi = require( 'hapi' ); var Boom = require('boom'); v…