Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const express = require('express');
const bodyParser = require('body-parser');
const stream = require('stream');

function Middleware(logger, messageValidatorService) {
function Middleware(logger, messageValidatorService, path) {
this._logger = logger;
this._stream = this._createStream();
this._buffer = null;

this._path=path;
this._app = express();
this._app.use(bodyParser.text({ type: "*/*" }));

Expand All @@ -26,12 +26,12 @@ Middleware.prototype.getStream = function() {

Middleware.prototype._configureEndpoints = function() {
const self = this;
this._app.get("/ping", (request, response) => {
this._app.get(self._path+"/ping", (request, response) => {
response.send("pong");
response.end();
});

this._app.post("/", (request, response) => {
this._app.post(self._path+"/", (request, response) => {
self._logger.debug("Request data:", request.body);
self._stream.push(request.body);

Expand Down
2 changes: 1 addition & 1 deletion lib/viber-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function ViberBot(loggerOrConfiguration, configuration) {

this._logger = logger;
this._client = new ViberClient(this._logger, this, API_URL, configuration.registerToEvents || SUBSCRIBED_EVENTS);
this._middleware = new Middleware(this._logger, new MessageValidator(this._logger, this.authToken));
this._middleware = new Middleware(this._logger, new MessageValidator(this._logger, this.authToken),configuration.path);
this._messageFactory = new MessageFactory(this._logger);
this._regexMatcherRouter = new RegexMatcherRouter(this._logger);
this._callbacks = { [EventConsts.CONVERSATION_STARTED]: []};
Expand Down