app.get('/healthz', function (req, res) { // do app logic here to determine if app is truly healthy // you should return 200 if healthy, and anything else will fail // if you want, you should be able to restrict this to localhost (include ipv4 and ipv6) res.send('I am happy and healthy\n'); });
describe('functions_bearer_token', () => { it('should run', async () => { const {sample, mocks} = getSample(); await sample.callingFunction(null, mocks.res); assert(mocks.axios.get.calledTwice); assert.deepEqual(mocks.axios.get.firstCall.args[1], { headers: {'Metadata-Flavor': 'Google'}, }); assert(mocks.res.send.calledWith('function-response')); }); });
/** * @param {string} message */ sendRawMessage(message) { this._channel.send(message); }
listMethods(user, services, method, args, callback) { const request = new ClientRequest(user, services); request.listMethods({method, args}); request.onComplete(callback); request.send(); }
/** * @api {post} /api/v1/service/rtsp-camera/camera/test Test connection * @apiName TestConnection * @apiGroup RtspCamera */ async function testConnection(req, res) { const cameraImage = await rtspCameraHandler.getImage(req.body); res.send(cameraImage); }
it('should be chainable', function() { expect(base.setHeader('one', '1')).to.equal(base); expect(base.setHeaders({ one: '1' })).to.equal(base); expect(base.type('text/plain')).to.equal(base); expect(base.send('body')).to.equal(base); expect(base.json({ foo: 'bar' })).to.equal(base); expect(base.end()).to.equal(base); });
it('.json() - should not override existing type', function() { const obj = { foo: 'bar' }; base.type('text/plain; charset=utf-9000'); base.send(obj); expect(base.body).to.equal(stringify(obj)); expect(base.getHeader('Content-Type')).to.equal( 'text/plain; charset=utf-9000' ); });
supertest('https://192.168.99.100:8080') .post('/notification/sendEmail') .send({payload}) .end((err, res) => { if (err) { reject(new Error('An error occured with the payment service, err: ' + err)) } resolve(res.body) })
/** * @description On listening event. * @example * xiaomi.listening(); */ function listening() { this.socket.addMembership(MULTICAST_ADDRESS); const payload = '{"cmd": "whois"}'; this.socket.send(payload, 0, payload.length, DISCOVERY_PORT, MULTICAST_ADDRESS); }
it('.send() - string', function() { base.send('foo'); expect(base.body).to.equal('foo'); expect(base.getHeader('Content-Type')).to.equal( 'text/html; charset=utf-8' ); });
startTorrent(user, services, hashes, callback) { const request = new ClientRequest(user, services); request.startTorrents({hashes}); request.onComplete((response, error) => { services.torrentService.fetchTorrentList(); callback(response, error); }); request.send(); }
function dispatch(type, id, arg) { let selectedID = lastID+1; if (selectedID > numCPUs-1) selectedID = 0; cluster.workers[workers[selectedID]].send(JSON.stringify({ id, type, arg })); lastID = selectedID; }
it('.send() - boolean, number, & object', function() { [true, 200, {}].forEach(body => { base.type(); base.send(body); expect(base.body).to.equal(stringify(body)); expect(base.getHeader('Content-Type')).to.equal( 'application/json; charset=utf-8' ); }); });
sendStatus(status) { this.status(status); this.type('text/plain'); return this.send(this.statusText); }
sendStatus(status) { this.status(status); this.type('text/plain'); return this.send(this.statusText); }