UNPKG

newbeely-nodejs

Version:

简单易用的轻量级nodejs服务框架. 框架简单到只有组件逻辑,不同的组件提供不同的服务,使用外部的配置文件(只有一个配置文件)方便的组合成一个完整的服务框架. 整个服务使用bearcat(网易开源的nodejs面向切面编程的轻量级框架(AOP))管理,极大的解耦组件间的耦合.(关于代码热更新后续开放).

45 lines (43 loc) 1.45 kB
var Bearcat = require('bearcat'); describe('redis component test', function () { before('init bearcat', function (done) { function application() { this.$id = "application"; } Bearcat.createApp(); Bearcat.module(application); Bearcat.use(['application']); Bearcat.start(function () { done(); }); }); it('Redis execute test', function (done) { var redisComponent = Bearcat.getBean(require('../../lib/components/redisComponent/redisComponent'), 'redis', { host: "localhost", port: 6379, pass: "" }); redisComponent.execute(function (client, release) { client.set("test", "hello!", function (error, state) { console.log("redis set test:hello!", error, state); release(); done(); }); }); }); it('Redis command test', function (done) { var redisComponent = Bearcat.getBean(require('../../lib/components/redisComponent/redisComponent'), 'redis', { host: "localhost", port: 6379, pass: "" }); redisComponent.command('get', 'test', function (error, value) { console.log("redis command get test", value); done(); }); }); after('release bearcat', function (done) { Bearcat.stop(); done(); }); });