Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Logger.setLevel("Performance", LogLevel.Error); // Change to Info to capture
if (TestbedConfig.cloudRpc) {
if (TestbedConfig.useHttp2) {
const http2Options = { key: fs.readFileSync(path.join(__dirname, "../../local_dev_server.key")), cert: fs.readFileSync(path.join(__dirname, "../../local_dev_server.crt")) };
http2.createSecureServer(http2Options, (req2, res2) => {
if (req2.method === "GET") {
handleHttp2Get(req2, res2);
} else if (req2.method === "POST") {
handleHttp2Post(req2, res2); // tslint:disable-line:no-floating-promises
}
}).listen(TestbedConfig.serverPort);
} else {
const app = express();
app.use(bodyParser.text());
app.use(bodyParser.raw());
app.use(express.static(__dirname + "/public"));
app.get(TestbedConfig.swaggerURI, (req, res) => TestbedConfig.cloudRpc.protocol.handleOpenApiDescriptionRequest(req, res));
app.post("*", (req, res) => {
if (handlePending(req, res)) {
return;
}
TestbedConfig.cloudRpc.protocol.handleOperationPostRequest(req, res); // tslint:disable-line:no-floating-promises
});
app.get(/\/imodel\//, (req, res) => {
TestbedConfig.cloudRpc.protocol.handleOperationGetRequest(req, res); // tslint:disable-line:no-floating-promises
});
app.listen(TestbedConfig.serverPort);
async function serveFunctions(settings) {
const app = express();
const dir = settings.functionsDir;
const port = await getPort({
port: assignLoudly(settings.port, defaultPort)
});
app.use(
bodyParser.text({
limit: "6mb",
type: ["text/*", "application/json", "multipart/form-data"]
})
);
app.use(bodyParser.raw({ limit: "6mb", type: "*/*" }));
app.use(
expressLogging(console, {
blacklist: ["/favicon.ico"]
})
);
app.get("/favicon.ico", function(req, res) {
res.status(204).end();
});
app.all("*", createHandler(dir));
app.listen(port, function(err) {
if (err) {
console.error(`${NETLIFYDEVERR} Unable to start lambda server: `, err); // eslint-disable-line no-console
process.exit(1);
}
const express = require('express');
const router = express.Router();
const axios = require('axios');
const bodyParser = require('body-parser');
const fb_client_secret = require('../../config/fb_client_secrets.json');
var { findByEmail, createOAuthUser } = require('../../controllers/userController');
const app_id = fb_client_secret['web']['app_id'];
const app_secret = fb_client_secret['web']['app_secret'];
var rawParser = bodyParser.raw();
router.post('/', rawParser,function(req, res, next) {
if (req.query.state !== req.session.STATE){
console.log('Invalid state parameter.');
res.set('Content-Type', 'application/json');
res.status(401);
res.json({"error":"Invalid state parameter."});
return;
}
// Obtain authorization code
let token = req.body.toString('utf8');
let url1 = 'https://graph.facebook.com/oauth/access_token?' +
'grant_type=fb_exchange_token&client_id='+app_id
+'&client_secret='+app_secret
+'&fb_exchange_token='+token;
console.log(url1);
'Store-Sample',
'Store-Transcription',
'User-Agent',
'X-Requested-With',
].join(',')
);
// Prevent browsers mistaking user provided content as HTML
res.header('X-Content-Type-Options', 'nosniff');
res.header('X-Frame-Options', 'DENY');
next();
});
app.use(
bodyParser.raw({
limit: 1024000,
type: function() {
return true;
},
})
);
app.get('/__version__', function(req, res, next) {
fs.readFile('version.json', (read_error, version) => {
if (read_error) {
return next(read_error);
}
res.json(JSON.parse(version));
});
});
async function runHub() {
var app = express()
const port = 8080
app.use(bodyParser.raw({
inflate: true,
limit: '500kb',
type: 'application/jwt'
}))
// TODO: Register DID, provision & format keys, write to fs during npm setup
const privateJwk = JSON.parse(fs.readFileSync(privateKeyFilePath, 'utf8'))
const hubPrivateKey = { [privateJwk.kid] : didAuth.PrivateKeyRsa.wrapJwk(privateJwk.kid, privateJwk) }
const hubCryptoSuites = [new didAuth.RsaCryptoSuite(), new didAuth.AesCryptoSuite(), new didAuth.Secp256k1CryptoSuite()]
mongoStore = new hubMongo.MongoDBStore({
url: mongoUrl,
databaseId: 'identity-hub',
commitCollectionId: 'hub-commits',
objectCollectionId: 'hub-objects',
function stripeWebHooks({ server }) {
server.post(
'/api/v1/public/stripe-invoice-payment-failed',
bodyParser.raw({ type: '*/*' }),
async (req, res, next) => {
try {
const event = await verifyWebHook(req);
// logger.info(JSON.stringify(event.data.object));
// @ts-ignore
// some problem with @types/stripe ?
const { subscription } = event.data.object;
// logger.info(JSON.stringify(subscription));
await Team.cancelSubscriptionAfterFailedPayment({
subscriptionId: JSON.stringify(subscription),
});
res.sendStatus(200);
} catch (err) {
next(err);
}
age: moment.duration(1, "day").asSeconds()
},{
test: /.+/,
etag: false,
lastModified: false,
cacheControl: false,
expires: false,
age: 0
}
]));
// Configuring the BIRD Main server.
app.use("/", bodyParser.urlencoded({
extended: true
}));
app.use("/", bodyParser.raw({
limit: "50mb"
}));
app.use("/", multiparty(config.version));
app.use("/", cookies());
app.use(function(req, res, next){
// A throw-together session implementation.
var RedisSession = function(rdKey, afterCb){
var key = this._key = "BIRD3.Session."+rdKey;
var self = this;
redis.get(key, function(err, res){
if(err) return afterCb(err);
try{
self._store = require("phpjs").unserialize(res);
}catch(e){
self._store = {};
}
const swaggerUi = require('swagger-ui-express')
const debug = require('debug')('botium-speech-processing-server')
const app = express()
const port = process.env.PORT || 56000
const apiTokens = (process.env.BOTIUM_API_TOKENS && process.env.BOTIUM_API_TOKENS.split(/[\s,]+/)) || []
if (apiTokens.length === 0) {
console.log('WARNING: BOTIUM_API_TOKENS not set, all clients will be accepted')
} else {
console.log('Add BOTIUM_API_TOKEN header to all HTTP requests, or BOTIUM_API_TOKEN URL parameter')
}
app.use(bodyParser.json())
app.use(bodyParser.text())
app.use(bodyParser.raw({ type: 'audio/*', limit: process.env.BOTIUM_SPEECH_UPLOAD_LIMIT }))
app.use(bodyParser.urlencoded({ extended: false }))
if (debug.enabled) {
app.use(expressWinston.logger({
transports: [
new winston.transports.Console()
],
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
),
meta: false
}))
}
app.use('/api/*', (req, res, next) => {
const clientApiToken = req.headers.BOTIUM_API_TOKEN || req.headers.botium_api_token || req.query.BOTIUM_API_TOKEN || req.query.botium_api_token || req.body.BOTIUM_API_TOKEN || req.body.botium_api_token
function createApp(workerContent, opts = {}) {
let workersByOrigin = {};
const kvStores = buildKVStores(new InMemoryKVStore(), opts.kvStores || []);
const app = express();
app.use(bodyParser.raw({ type: "*/*", limit: "100GB" }));
app.use(async (req, res) => {
try {
const origin = req.headers.host;
workersByOrigin[origin] = workersByOrigin[origin] || new Worker(origin, workerContent, { ...opts, kvStores });
const worker = workersByOrigin[origin];
await callWorker(worker, req, res);
} catch (e) {
console.warn(e);
res.status(520);
res.end("Something Went Wrong!");
}
});
app.updateWorker = contents => {
workerContent = contents;
workersByOrigin = {};
};
private buildRawBodyParserMiddleware(bodyParserOptions: any) {
let middleware: express.RequestHandler;
this.debugger.build('Creating raw body parser with options %j.', bodyParserOptions || {});
if (bodyParserOptions) {
middleware = bodyParser.raw(bodyParserOptions);
}
else {
middleware = bodyParser.raw();
}
return middleware;
}