UNPKG

serverless-offline-python

Version:

Emulate AWS λ and API Gateway locally when developing your Serverless project

33 lines (29 loc) 1.03 kB
'use strict'; const _ = require('lodash'); module.exports = { toPlainOrEmptyObject: obj => _.isPlainObject(obj) ? obj : {}, random: (lower, upper, floating) => _.random(lower, upper, floating), nullIfEmpty: o => o && (Object.keys(o).length > 0 ? o : null), capitalizeKeys: o => { const capitalized = {}; for (let key in o) { // eslint-disable-line prefer-const capitalized[key.replace(/((?:^|-)[a-z])/g, x => x.toUpperCase())] = o[key]; } return capitalized; }, // Detect the toString encoding from the request headers content-type // enhance if further content types need to be non utf8 encoded. detectEncoding: request => _.includes(request.headers['content-type'], 'multipart/form-data') ? 'binary' : 'utf8', isProxyRuntime: runtime => { return runtime.startsWith('python') || runtime.startsWith('ruby') }, supportedRuntimes: [ 'nodejs8.10', 'nodejs10.x', 'nodejs12.x', 'babel', 'python2.7', 'python3.6', 'python3.7', 'python3.8', 'ruby2.5', ], };