Skip to content

Instantly share code, notes, and snippets.

@jrschumacher jrschumacher/stream.js
Last active Aug 29, 2015

Embed
What would you like to do?
Loopback get current context: remote vs observe
//...
Stream.observe('before save', function test(ctx, next) {
console.log('>>>>> Stream.observe::before-save >>>>>\n',
loopback.getCurrentContext(),
'\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
next();
});
Stream.createStream = function (cb) {
console.log('>>>>> Stream.observe::before-save >>>>>\n',
loopback.getCurrentContext(),
'\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>');
cb();
};
Stream.remoteMethod(
'createStream',
{
description: 'Create stream test',
accepts: [],
returns: {},
http: {path: '/', verb: 'post'}
}
);
//...
describe('/stream', function() {
lt.before.cleanDatasource();
lt.before.withApp(app);
lt.before.givenLoggedInUser(chai.create('person', env.chaiFactoryGenerate(['email'])));
var person;
describe('Test context the stream', function() {
lt.describe.whenCalledRemotely('POST', '/api/stream', {}, function() {
it('should have statusCode 200', function() {
expect(this.res).to.have.status(200);
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.