Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
var restify = require('restify')
var msRest = require('ms-rest')
var Connector = require('botconnector')
const Memes = require('./lib/memes')
const memes = new Memes()
// Initialize server
var server = restify.createServer()
server.use(restify.authorizationParser())
server.use(restify.bodyParser())
// Initialize credentials for connecting to Bot Connector Service
var appId = process.env.appId || 'textmeme'
var appSecret = process.env.appSecret || 'ec470402ed6d4f2c9e40e597bc4cff73'
var credentials = new msRest.BasicAuthenticationCredentials(appId, appSecret)
// Handle incoming message
server.post('/v1/messages', verifyBotFramework(credentials), (req, res) => {
var msg = req.body
console.log(req.body.text)
const [name] = req.body.text.split(';')
sendMessage(name)
if (name === 'memes') {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const botbuilder_1 = require("botbuilder");
const botbuilder_dialogs_1 = require("botbuilder-dialogs");
const restify = require("restify");
// Create server
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log(`${server.name} listening to ${server.url}`);
});
// Create adapter
const adapter = new botbuilder_1.BotFrameworkAdapter({
appId: process.env.MICROSOFT_APP_ID,
appPassword: process.env.MICROSOFT_APP_PASSWORD
});
// Add conversation state middleware
const conversationState = new botbuilder_1.ConversationState(new botbuilder_1.MemoryStorage());
adapter.use(conversationState);
// Listen for incoming requests
server.post('/api/messages', (req, res) => {
// Route received request to adapter for processing
adapter.processActivity(req, res, (context) => __awaiter(this, void 0, void 0, function* () {
if (context.activity.type === 'message') {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const botbuilder_1 = require("botbuilder");
const botbuilder_services_1 = require("botbuilder-services");
const restify = require("restify");
// Create server
let server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log(`${server.name} listening to ${server.url}`);
});
// Create adapter and listen to our servers '/api/messages' route.
const botFrameworkAdapter = new botbuilder_services_1.BotFrameworkAdapter({ appId: process.env.MICROSOFT_APP_ID, appPassword: process.env.MICROSOFT_APP_PASSWORD });
server.post('/api/messages', botFrameworkAdapter.listen());
// Initialize bot by passing it adapter
const bot = new botbuilder_1.Bot(botFrameworkAdapter);
// define the bot's onReceive message handler
bot.onReceive((context) => {
context.reply(`Hello World`);
});
// END OF LINE
/*-----------------------------------------------------------------------------
Name: react-msal-bot
Author: Franck Cornu (aequos) - Twitter @FranckCornu
Date: August 4th, 2018
Description: This sample shows how to handle Microsoft graph queries with an access token retrieved from a SharePoint site via the backchannel
-----------------------------------------------------------------------------*/
const restify = require('restify');
const builder = require('botbuilder');
const fetch = require('node-fetch');
// Setup Restify Server
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
const connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
stateEndpoint: process.env.BotStateEndpoint,
openIdMetadata: process.env.BotOpenIdMetadata
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
// Create an "in memory" bot storage.
// const STORAGE_CONFIGURATION_ID = '';
// // Default container name
// const DEFAULT_BOT_CONTAINER = '';
// // Get service configuration
// const blobStorageConfig = botConfig.findServiceByNameOrId(STORAGE_CONFIGURATION_ID);
// const blobStorage = new BlobStorage({
// containerName: (blobStorageConfig.container || DEFAULT_BOT_CONTAINER),
// storageAccountOrConnectionString: blobStorageConfig.connectionString,
// });
// conversationState = new ConversationState(blobStorage);
// Create the EchoBot.
const bot = new EchoBot(conversationState);
// Create HTTP server
const server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, () => {
console.log(`\n${ server.name } listening to ${ server.url }`);
console.log(`\nGet Bot Framework Emulator: https://aka.ms/botframework-emulator.`);
console.log(`\nTo talk to your bot, open echobot-with-counter.bot file in the Emulator.`);
});
// Listen for incoming activities and route them to your bot for processing.
server.post('/api/messages', (req, res) => {
adapter.processActivity(req, res, async (turnContext) => {
// Call bot.onTurn() to handle all incoming messages.
await bot.onTurn(turnContext);
});
});
const startGateway = (config, handler, done) => {
server = restify.createServer({});
server.use(restify.plugins.gzipResponse());
server.use(restify.plugins.bodyParser());
server.get('/', handler);
server.listen(port, function() {
console.log('API Server listening at %s', JSON.stringify(server.address()))
gateway = gatewayService(config)
done()
})
}
const startGateway = (config, handler, done) => {
server = restify.createServer({});
server.use(restify.gzipResponse());
server.use(restify.bodyParser());
server.get('/', handler);
server.listen(port, function() {
console.log('%s listening at %s', server.name, server.url)
gateway = gatewayService(config)
done()
})
}
function Restify() {
let app = restify.createServer()
app.use(restify.plugins.queryParser())
app.use(restify.plugins.bodyParser())
app.isRestify = true
return app
}
(function(log) {
var WordNet = require('node-wordnet'),
restify = require('restify'),
server = restify.createServer();
server.use(
function crossOrigin(request, response, next) {
response.header('Access-Control-Allow-Origin', '*');
response.header('Access-Control-Allow-Headers', 'X-Requested-With');
return next();
}
);
server.get('/:search', respond);
server.listen((process.env.PORT || 5000), function() {
log(server.name, 'listening at', server.url);
});
function respond(request, response, next) {
var wordnet = new WordNet(),
assert.number(options.port, 'options.port');
EventEmitter.call(this);
var self = this;
/** @type {Bunyan} The bunyan log object */
this._log = options.log.child({component: 'HeartbeatServer'}, true);
var log = self._log;
log.info('new heartbeat server with options', options);
/** @type {number} server port */
this._port = options.port;
/** @type {Restify} rest server */
this._server = restify.createServer({
log: log
});
/**
* @type {number}
* If no heartbeat has been received for this ms, expire the client.
*/
this._expirationTime = options.expirationTime;
/**
* @type {number}
* The period in ms used to check for heartbeats.
*/
this._pollInterval = options.pollInterval;
/**