diff --git a/app.js b/app.js index d22465f5..24d58882 100644 --- a/app.js +++ b/app.js @@ -29,7 +29,11 @@ const { // HTTP const express = require('express'); const app = express(); -app.locals.logger = logger; +Object.assign(app.locals, { + logger, + srf +}); + const httpRoutes = require('./lib/http-routes'); const InboundCallSession = require('./lib/session/inbound-call-session'); diff --git a/lib/http-routes/api/create-call.js b/lib/http-routes/api/create-call.js index dddd1b3b..e0afcd41 100644 --- a/lib/http-routes/api/create-call.js +++ b/lib/http-routes/api/create-call.js @@ -7,24 +7,13 @@ const SipError = require('drachtio-srf').SipError; const sysError = require('./error'); const Requestor = require('../../utils/requestor'); -/** - * Retrieve a connection to a drachtio server, lazily creating when first called - */ -function getSrfForOutdial(logger) { - const {srf} = require('../../../'); - const {getSrf} = srf.locals; - const srfForOutdial = getSrf(); - if (!srfForOutdial) throw new Error('no available feature servers for outbound call creation'); - return srfForOutdial; -} - router.post('/', async(req, res) => { - const logger = req.app.locals.logger; + const {logger, srf} = req.app.locals; + logger.debug({body: req.body}, 'got createCall request'); try { let uri, cs, to; const restDial = makeTask(logger, {'rest:dial': req.body}); - const srf = getSrfForOutdial(logger); const {getSBC, getFreeswitch} = srf.locals; const sbcAddress = getSBC(); if (!sbcAddress) throw new Error('no available SBCs for outbound call creation');