Best JavaScript code snippet using mountebank
index.js
Source: index.js
1/*2 *3 * TradingDesk reducer4 *5 */6import moment from 'moment';7import { fromJS } from 'immutable';8import { handleActions } from 'redux-actions';9import {10 collectionRehydrateState,11 collectionInitialState,12 collectionReducer,13 listRehydrateState,14 listInitialState,15 listReducer,16} from 'utils/CollectionHelper/reducers';17import { ActionTypes } from 'utils/UploadHelper/actions';18import {19 statsInitialState,20 statsRehydrateState,21 statsReducer,22 statsCollectionInitialState,23 statsCollectionReducer,24} from 'utils/StatsHelper/reducer';25import onlineCountersMapReducer, {26 initialState as onlineCountersMapState,27 rehydrateState as onlineCountersRehydrateState,28} from './onlineCountersMapReducer';29import {30 COUNTERS_COLLECTION_NAME,31 FAQ_COLLECTION_NAME,32 CAMPAING_GROUPS_COLLECTION_NAME,33 CAMPAINGS_COLLECTION_NAME,34 CREATIVES_COLLECTION_NAME,35 DEVICETYPE_COLLECTION_NAME,36 TYPEOS_COLLENCTION_NAME,37 BROWSERTYPE_COLLENCTION_NAME,38 AGEGROUP_COLLENCTION_NAME,39 GENDER_COLLENCTION_NAME,40 SSP_COLLENCTION_NAME,41 STRATEGY_COLLENCTION_NAME,42 PLACEMENTPOSITION_COLLENCTION_NAME,43 SET_CAMPAIGN_FILTER,44 SET_ADBLOCK,45 SET_CREATIVE_FILTER,46 PAY_LINK,47 SET_FAQ_FILTER,48 BUDGETDISTRIBUTION_COLLECTION_NAME,49 TRANSFER_MONEY,50 BALANCE_COLLECTION_NAME,51 PAYMENTHISTORY_COLLECTION_NAME,52 SET_CHARTS_DATES,53 BANNERS_COLLECTION_NAME,54 ADSIZE_COLLECTION_NAME,55 LANGUAGE_COLLECTION_NAME,56 SET_PAGINATION_ITEMS_COUNT,57 CONTACT_FORM,58 VISITORS_COLLECTION_NAME,59 CAMPAIGNREPORT_COLLECTION_NAME,60 HOMEPAGESTATS_COLLECTION_NAME,61 TABLE_HOMEPAGESTATS_COLLECTION_NAME,62 CAMPAIGNREPORT_TABLE_COLLECTION_NAME,63 CREATIVEREPORT_COLLECTION_NAME,64 CREATIVEREPORT_TABLE_COLLECTION_NAME,65 COUNTER_VISITORS_COLLECTION_NAME,66 COUNTER_VISITORS_TABLE_COLLECTION_NAME,67 COUNTER_REGIONS_COLLECTION_NAME,68 COUNTER_REGIONS_TABLE_COLLECTION_NAME,69 COUNTER_DEVICES_COLLECTION_NAME,70 COUNTER_DEVICES_TABLE_COLLECTION_NAME,71 COUNTER_CHANNEL_COLLECTION_NAME,72 COUNTER_CHANNEL_TABLE_COLLECTION_NAME,73 SET_OPENED_GROUP,74 REGIONS_COLLECTION_NAME,75 CITIES_COLLECTION_NAME,76 SET_OPENED_FORMCARD,77 PAYMENT_VARIANTS,78 GROUPSHARING_COLLECTION_NAME,79 CREATIVESHARING_COLLECTION_NAME,80 ONLINE_COUNTERS_COLLECTION_NAME,81 COUNTERSHARING_COLLECTION_NAME,82 PUBLISHERS_CONFIG_COLLECTION_NAME,83 GROUPSTATS_COLLECTION_NAME,84 CAMPAIGNREPORT_CARDS_COLLECTION_NAME,85 FILTERS_COLLECTION_NAME,86 FILTERSHARING_COLLECTION_NAME,87 SET_ACTIVE_COUNTER_STATS,88 SET_ACTIVE_CAMPAIGN_STATS,89 SET_FAVORITE_GROUP,90 SET_FAVORITE_CREATIVE,91 SET_FAVORITE_FILTER,92} from '../constants';93export const initialState = fromJS({94 creativeUploadingProgress: 0,95 creativeIsUploading: false,96 dates: {97 startDate: moment()98 .startOf('day')99 .subtract('1', 'month')100 .format('YYYY-MM-DD'),101 endDate: moment()102 .startOf('day')103 .format('YYYY-MM-DD'),104 period: 'month',105 },106 campaignGroupFilters: {107 searchWord: null,108 statusFilter: 'active',109 request: null,110 },111 creativeFilters: {112 searchWord: null,113 typeFilter: 'all',114 },115 adBlock: {116 display: true,117 },118 FAQFilter: {119 searchWord: null,120 },121 paginationItemsCount: {122 creativesCount: 10,123 campaignGroupsCount: 10,124 },125 openedGroup: [],126 openedFormCards: [],127 activeCounterStats: null,128 activeCampaignStats: null,129 favoriteGroups: [],130 favoriteCreatives: [],131 favoriteFilters: [],132})133 .merge(listInitialState(FAQ_COLLECTION_NAME))134 .merge(collectionInitialState(CAMPAINGS_COLLECTION_NAME))135 .merge(collectionInitialState(CREATIVES_COLLECTION_NAME))136 .merge(collectionInitialState(COUNTERS_COLLECTION_NAME))137 .merge(collectionInitialState(CAMPAING_GROUPS_COLLECTION_NAME))138 .merge(collectionInitialState(BANNERS_COLLECTION_NAME))139 .merge(collectionInitialState(GROUPSHARING_COLLECTION_NAME))140 .merge(collectionInitialState(CREATIVESHARING_COLLECTION_NAME))141 .merge(collectionInitialState(COUNTERSHARING_COLLECTION_NAME))142 .merge(collectionInitialState(FILTERSHARING_COLLECTION_NAME))143 .merge(collectionInitialState(FILTERS_COLLECTION_NAME))144 .merge(listInitialState(PUBLISHERS_CONFIG_COLLECTION_NAME))145 .merge(listInitialState(REGIONS_COLLECTION_NAME))146 .merge(listInitialState(ONLINE_COUNTERS_COLLECTION_NAME))147 .merge(listInitialState(CITIES_COLLECTION_NAME))148 .merge(listInitialState(PLACEMENTPOSITION_COLLENCTION_NAME))149 .merge(listInitialState(STRATEGY_COLLENCTION_NAME))150 .merge(listInitialState(SSP_COLLENCTION_NAME))151 .merge(listInitialState(GENDER_COLLENCTION_NAME))152 .merge(listInitialState(AGEGROUP_COLLENCTION_NAME))153 .merge(listInitialState(LANGUAGE_COLLECTION_NAME))154 .merge(listInitialState(DEVICETYPE_COLLECTION_NAME))155 .merge(listInitialState(TYPEOS_COLLENCTION_NAME))156 .merge(listInitialState(BROWSERTYPE_COLLENCTION_NAME))157 .merge(listInitialState(PAY_LINK))158 .merge(collectionInitialState(PAYMENT_VARIANTS))159 .merge(listInitialState(TRANSFER_MONEY))160 .merge(listInitialState(CONTACT_FORM))161 .merge(listInitialState(BALANCE_COLLECTION_NAME))162 .merge(listInitialState(BUDGETDISTRIBUTION_COLLECTION_NAME))163 .merge(listInitialState(PAYMENTHISTORY_COLLECTION_NAME))164 .merge(listInitialState(ADSIZE_COLLECTION_NAME))165 .merge(statsInitialState(VISITORS_COLLECTION_NAME))166 .merge(statsInitialState(CAMPAIGNREPORT_COLLECTION_NAME))167 .merge(statsInitialState(HOMEPAGESTATS_COLLECTION_NAME))168 .merge(statsInitialState(TABLE_HOMEPAGESTATS_COLLECTION_NAME))169 .merge(statsInitialState(CAMPAIGNREPORT_TABLE_COLLECTION_NAME))170 .merge(statsInitialState(CAMPAIGNREPORT_CARDS_COLLECTION_NAME))171 .merge(statsInitialState(CREATIVEREPORT_COLLECTION_NAME))172 .merge(statsInitialState(CREATIVEREPORT_TABLE_COLLECTION_NAME))173 .merge(statsInitialState(COUNTER_VISITORS_COLLECTION_NAME))174 .merge(statsInitialState(COUNTER_VISITORS_TABLE_COLLECTION_NAME))175 .merge(statsInitialState(COUNTER_REGIONS_COLLECTION_NAME))176 .merge(statsInitialState(COUNTER_REGIONS_TABLE_COLLECTION_NAME))177 .merge(statsInitialState(COUNTER_DEVICES_COLLECTION_NAME))178 .merge(statsInitialState(COUNTER_DEVICES_TABLE_COLLECTION_NAME))179 .merge(statsInitialState(COUNTER_CHANNEL_COLLECTION_NAME))180 .merge(statsInitialState(COUNTER_CHANNEL_TABLE_COLLECTION_NAME))181 .merge(statsInitialState(GROUPSTATS_COLLECTION_NAME))182 .merge(onlineCountersMapState);183export const rehydrateState = {184 ...listRehydrateState(FAQ_COLLECTION_NAME),185 ...collectionRehydrateState(COUNTERS_COLLECTION_NAME),186 ...collectionRehydrateState(CAMPAING_GROUPS_COLLECTION_NAME),187 ...collectionRehydrateState(CAMPAINGS_COLLECTION_NAME),188 ...collectionRehydrateState(CREATIVES_COLLECTION_NAME),189 ...collectionRehydrateState(BANNERS_COLLECTION_NAME),190 ...collectionRehydrateState(GROUPSHARING_COLLECTION_NAME),191 ...collectionRehydrateState(CREATIVESHARING_COLLECTION_NAME),192 ...collectionRehydrateState(COUNTERSHARING_COLLECTION_NAME),193 ...collectionRehydrateState(FILTERS_COLLECTION_NAME),194 ...collectionRehydrateState(FILTERSHARING_COLLECTION_NAME),195 ...listRehydrateState(PUBLISHERS_CONFIG_COLLECTION_NAME),196 ...listRehydrateState(REGIONS_COLLECTION_NAME),197 ...listRehydrateState(ONLINE_COUNTERS_COLLECTION_NAME),198 ...listRehydrateState(CITIES_COLLECTION_NAME),199 ...listRehydrateState(PLACEMENTPOSITION_COLLENCTION_NAME),200 ...listRehydrateState(STRATEGY_COLLENCTION_NAME),201 ...listRehydrateState(SSP_COLLENCTION_NAME),202 ...listRehydrateState(GENDER_COLLENCTION_NAME),203 ...listRehydrateState(AGEGROUP_COLLENCTION_NAME),204 ...listRehydrateState(LANGUAGE_COLLECTION_NAME),205 ...listRehydrateState(DEVICETYPE_COLLECTION_NAME),206 ...listRehydrateState(TYPEOS_COLLENCTION_NAME),207 ...listRehydrateState(BROWSERTYPE_COLLENCTION_NAME),208 ...listRehydrateState(SET_CAMPAIGN_FILTER),209 ...listRehydrateState(SET_CREATIVE_FILTER),210 ...listRehydrateState(SET_ADBLOCK),211 ...listRehydrateState(SET_FAQ_FILTER),212 ...listRehydrateState(SET_OPENED_GROUP),213 ...listRehydrateState(SET_OPENED_FORMCARD),214 ...listRehydrateState(SET_ACTIVE_COUNTER_STATS),215 ...listRehydrateState(SET_ACTIVE_CAMPAIGN_STATS),216 ...listRehydrateState(SET_FAVORITE_GROUP),217 ...listRehydrateState(SET_FAVORITE_CREATIVE),218 ...listRehydrateState(SET_FAVORITE_FILTER),219 ...listRehydrateState(PAY_LINK),220 ...collectionRehydrateState(PAYMENT_VARIANTS),221 ...listRehydrateState(SET_PAGINATION_ITEMS_COUNT),222 ...listRehydrateState(TRANSFER_MONEY),223 ...listRehydrateState(CONTACT_FORM),224 ...listRehydrateState(BUDGETDISTRIBUTION_COLLECTION_NAME),225 ...listRehydrateState(BALANCE_COLLECTION_NAME),226 ...listRehydrateState(PAYMENTHISTORY_COLLECTION_NAME),227 ...listRehydrateState(ADSIZE_COLLECTION_NAME),228 ...statsRehydrateState(VISITORS_COLLECTION_NAME),229 ...statsRehydrateState(CAMPAIGNREPORT_COLLECTION_NAME),230 ...statsRehydrateState(HOMEPAGESTATS_COLLECTION_NAME),231 ...statsRehydrateState(TABLE_HOMEPAGESTATS_COLLECTION_NAME),232 ...statsRehydrateState(CAMPAIGNREPORT_TABLE_COLLECTION_NAME),233 ...statsRehydrateState(CAMPAIGNREPORT_CARDS_COLLECTION_NAME),234 ...statsRehydrateState(CREATIVEREPORT_COLLECTION_NAME),235 ...statsRehydrateState(CREATIVEREPORT_TABLE_COLLECTION_NAME),236 ...statsRehydrateState(COUNTER_VISITORS_COLLECTION_NAME),237 ...statsRehydrateState(COUNTER_VISITORS_TABLE_COLLECTION_NAME),238 ...statsRehydrateState(COUNTER_REGIONS_COLLECTION_NAME),239 ...statsRehydrateState(COUNTER_REGIONS_TABLE_COLLECTION_NAME),240 ...statsRehydrateState(COUNTER_DEVICES_COLLECTION_NAME),241 ...statsRehydrateState(COUNTER_DEVICES_TABLE_COLLECTION_NAME),242 ...statsRehydrateState(COUNTER_CHANNEL_COLLECTION_NAME),243 ...statsRehydrateState(COUNTER_CHANNEL_TABLE_COLLECTION_NAME),244 ...statsRehydrateState(GROUPSTATS_COLLECTION_NAME),245 ...onlineCountersRehydrateState,246};247export default handleActions(248 {249 ...collectionReducer(COUNTERS_COLLECTION_NAME),250 ...collectionReducer(CAMPAING_GROUPS_COLLECTION_NAME),251 ...collectionReducer(CAMPAINGS_COLLECTION_NAME),252 ...collectionReducer(CREATIVES_COLLECTION_NAME),253 ...collectionReducer(BANNERS_COLLECTION_NAME),254 ...collectionReducer(GROUPSHARING_COLLECTION_NAME),255 ...collectionReducer(CREATIVESHARING_COLLECTION_NAME),256 ...collectionReducer(COUNTERSHARING_COLLECTION_NAME),257 ...collectionReducer(FILTERS_COLLECTION_NAME),258 ...collectionReducer(FILTERSHARING_COLLECTION_NAME),259 ...listReducer(PUBLISHERS_CONFIG_COLLECTION_NAME),260 ...listReducer(REGIONS_COLLECTION_NAME),261 ...listReducer(ONLINE_COUNTERS_COLLECTION_NAME),262 ...listReducer(CITIES_COLLECTION_NAME),263 ...listReducer(FAQ_COLLECTION_NAME),264 ...listReducer(PLACEMENTPOSITION_COLLENCTION_NAME),265 ...listReducer(STRATEGY_COLLENCTION_NAME),266 ...listReducer(SSP_COLLENCTION_NAME),267 ...listReducer(GENDER_COLLENCTION_NAME),268 ...listReducer(AGEGROUP_COLLENCTION_NAME),269 ...listReducer(LANGUAGE_COLLECTION_NAME),270 ...listReducer(DEVICETYPE_COLLECTION_NAME),271 ...listReducer(TYPEOS_COLLENCTION_NAME),272 ...listReducer(BROWSERTYPE_COLLENCTION_NAME),273 ...listReducer(PAY_LINK),274 ...collectionReducer(PAYMENT_VARIANTS),275 ...listReducer(TRANSFER_MONEY),276 ...listReducer(CONTACT_FORM),277 ...listReducer(BUDGETDISTRIBUTION_COLLECTION_NAME),278 ...listReducer(BALANCE_COLLECTION_NAME),279 ...listReducer(PAYMENTHISTORY_COLLECTION_NAME),280 ...listReducer(ADSIZE_COLLECTION_NAME),281 ...statsReducer(VISITORS_COLLECTION_NAME),282 ...statsReducer(CAMPAIGNREPORT_COLLECTION_NAME),283 ...statsReducer(HOMEPAGESTATS_COLLECTION_NAME),284 ...statsReducer(TABLE_HOMEPAGESTATS_COLLECTION_NAME),285 ...statsReducer(CAMPAIGNREPORT_TABLE_COLLECTION_NAME),286 ...statsReducer(CAMPAIGNREPORT_CARDS_COLLECTION_NAME),287 ...statsReducer(CREATIVEREPORT_COLLECTION_NAME),288 ...statsReducer(CREATIVEREPORT_TABLE_COLLECTION_NAME),289 ...statsReducer(COUNTER_VISITORS_COLLECTION_NAME),290 ...statsReducer(COUNTER_VISITORS_TABLE_COLLECTION_NAME),291 ...statsReducer(COUNTER_REGIONS_COLLECTION_NAME),292 ...statsReducer(COUNTER_REGIONS_TABLE_COLLECTION_NAME),293 ...statsReducer(COUNTER_DEVICES_COLLECTION_NAME),294 ...statsReducer(COUNTER_DEVICES_TABLE_COLLECTION_NAME),295 ...statsReducer(COUNTER_CHANNEL_COLLECTION_NAME),296 ...statsReducer(COUNTER_CHANNEL_TABLE_COLLECTION_NAME),297 ...statsReducer(GROUPSTATS_COLLECTION_NAME),298 ...onlineCountersMapReducer,299 [ActionTypes.UPLOAD_REQUEST]: state => state.set('creativeIsUploading', true),300 [ActionTypes.UPLOAD_PROGRESS]: (state, { payload }) => state.set('creativeUploadingProgress', payload),301 [ActionTypes.UPLOAD_SUCCESS]: state =>302 state.set('creativeUploadingProgress', 0).set('creativeIsUploading', false),303 [ActionTypes.UPLOAD_FAILURE]: state =>304 state.set('creativeUploadingProgress', 0).set('creativeIsUploading', false),305 [SET_CAMPAIGN_FILTER]: (state, { payload }) =>306 state.update('campaignGroupFilters', filter => filter.merge(payload)),307 [SET_CREATIVE_FILTER]: (state, { payload }) => state.update('creativeFilters', filter => filter.merge(payload)),308 [SET_ADBLOCK]: (state, { payload }) => state.update('adBlock', filter => filter.merge(payload)),309 [SET_FAQ_FILTER]: (state, { payload }) => state.update('FAQFilter', filter => filter.merge(payload)),310 [SET_CHARTS_DATES]: (state, { payload }) => state.update('dates', filter => filter.merge(payload)),311 [SET_OPENED_GROUP]: (state, { payload }) => state.set('openedGroup', fromJS(payload)),312 [SET_OPENED_FORMCARD]: (state, { payload }) => state.set('openedFormCards', fromJS(payload)),313 [SET_ACTIVE_COUNTER_STATS]: (state, { payload }) => state.set('activeCounterStats', fromJS(payload)),314 [SET_ACTIVE_CAMPAIGN_STATS]: (state, { payload }) => state.set('activeCampaignStats', fromJS(payload)),315 [SET_PAGINATION_ITEMS_COUNT]: (state, { payload }) =>316 state.update('paginationItemsCount', filter => filter.merge(payload)),317 [SET_FAVORITE_GROUP]: (state, { payload }) => state.set('favoriteGroups', fromJS(payload)),318 [SET_FAVORITE_CREATIVE]: (state, { payload }) => state.set('favoriteCreatives', fromJS(payload)),319 [SET_FAVORITE_FILTER]: (state, { payload }) => state.set('favoriteFilters', fromJS(payload)),320 },321 initialState,...
deployResources.mjs
Source: deployResources.mjs
1import { LAMBDA_DEPLOYMENT_PACKAGE_S3_BUCKET_NAME, REHYDRATION_LAMBDA_NAME } from '../../constants/general.mjs';2import 'dotenv/config.js';3import Configstore from 'configstore';4import { v4 as uuidv4 } from 'uuid';5import createEventSourceMapping from '../../lambda/createEventSourceMapping.mjs';6import pause from '../../../utils/pause.js';7import deployLambdaDeploymentPackage from './deployLambdaDeploymentPackage.mjs';8import deployRehydrateSQSDLQ from './deployRehydrateSQSDLQ.mjs';9import deployStatusSQSDLQ from './deployStatusSQSDLQ.mjs';10import deployRehydrateSQS from './deployRehydrateSQS.mjs';11import deployStatusSQS from './deployStatusSQS.mjs';12import fs from 'fs';13import deployLambdaRole from './deployLambdaRole.mjs';14import deployRehydrateLambda from './deployRehydrateLambda.mjs';15import arroyoHeader from '../../../utils/figlet.mjs';16import chalk from 'chalk';17import ora from 'ora';18const log = console.log;19const errorMessage = chalk.bold.red;20const uuid = uuidv4();21const packageJson = JSON.parse(fs.readFileSync('./AWSconfig.json', 'utf8'));22const config = new Configstore(packageJson.name, {});23config.clear();24config.set('uuid', uuid);25const deployResources = async () => {26 const lambdaS3BucketName = `${LAMBDA_DEPLOYMENT_PACKAGE_S3_BUCKET_NAME}-${uuid}`;27 arroyoHeader();28 await pause(2000);29 const spinner = ora({30 text: 'Getting ready to deploy AWS infrastructure',31 color: 'yellow'32 }).start();33 await pause(2000);34 35 spinner.stop();36 await pause(1000);37 spinner.start('Creating Deployment package for Lambda Function');38 try {39 await deployLambdaDeploymentPackage({ lambdaS3BucketName });40 await pause(8000);41 spinner.succeed('Deployment package for Lambda Function has been created');42 } catch (error) {43 spinner.fail('There was an error when creating deployment package for Lambda function. Error: ', error);44 log(errorMessage(error));45 }46 47 let rehydrateSQSDLQArn;48 try {49 spinner.start('Creating Rehydrate SQS Dead Letter Queue');50 await pause(2000);51 rehydrateSQSDLQArn = await deployRehydrateSQSDLQ({ uuid });52 await pause(2000);53 spinner.succeed('Rehydrate SQS Dead Letter Queue has been created')54 } catch (error) {55 spinner.fail('There was an error when creating Rehydrate SQS Dead Letter Queue');56 log(errorMessage(error));57 }58 let statusSQSDLQArn;59 try {60 spinner.start('Creating Status SQS Dead Letter Queue');61 statusSQSDLQArn = await deployStatusSQSDLQ({ uuid });62 await pause(5000);63 spinner.succeed('Status SQS Dead Letter Queue has been created');64 } catch (error) {65 spinner.fail('There was an error when creating Status SQS Dead Letter Queue');66 log(errorMessage(error));67 }68 let rehydrateSQSArn;69 try {70 spinner.start('Creating Rehydrate SQS Queue');71 rehydrateSQSArn = await deployRehydrateSQS({ uuid, rehydrateSQSDLQArn });72 await pause(3000);73 spinner.succeed('Rehydrate SQS Queue has been created');74 } catch (error) {75 spinner.fail('There was an error when creating Rehydrate SQS Queue');76 log(errorMessage(error));77 }78 79 80 let statusSQSArn;81 let statusSQSUrl;82 try {83 spinner.start('Creating Status SQS Queue');84 ({ statusSQSArn, statusSQSUrl } = await deployStatusSQS({ uuid, statusSQSDLQArn }));85 await pause(3000);86 spinner.succeed('Status SQS Queue has been created');87 } catch(error) {88 spinner.fail('There was an error when creating Status SQS Queue');89 log(errorMessage(error));90 }91 92 93 try {94 spinner.start('Creating IAM role for Lambda');95 await deployLambdaRole({ uuid, statusSQSArn });96 await pause(5000);97 spinner.succeed('IAM role for Lambda has been created');98 } catch (error) {99 spinner.fail('There was an error when creating IAM role for Lambda');100 log(errorMessage(error));101 }102 103 const rehydrateLambdaName = `${REHYDRATION_LAMBDA_NAME}-${uuid}`;104 105 const lambdaRoleArn = config.get('lambdaRoleArn');106 try {107 spinner.start('Creating Lambda Function');108 await deployRehydrateLambda({ lambdaS3BucketName, statusSQSUrl, lambdaRoleArn, rehydrateLambdaName });109 await pause(8000);110 spinner.succeed('Lambda Function has been created');111 } catch(error) {112 spinner.fail('There was an error when creating Lambda Function');113 log(errorMessage(error));114 }115 116 117 try {118 spinner.start('Creating Event source mapping');119 const eventSourceMappingUUID = await createEventSourceMapping({ 120 functionName: rehydrateLambdaName, 121 eventSourceArn: rehydrateSQSArn122 });123 124 config.set('eventSourceMappingUUID', eventSourceMappingUUID);125 await pause(2000);126 spinner.succeed('Event source mapping has been created');127 } catch(error) {128 spinner.fail('There was an error when creating Event source mapping');129 log(errorMessage(error));130 }131 spinner.stopAndPersist({132 text: '\nArroyo AWS infrastructure has been deployed!',133 })134}135export default deployResources;...
deployRehydrateSQS.mjs
Source: deployRehydrateSQS.mjs
1import { REHYDRATION_QUEUE_NAME } from '../../constants/general.mjs';2import createQueue from '../../sqs/createQueue.mjs';3import getQueueArn from '../../sqs/getQueueArn.mjs';4import pause from '../../../utils/pause.js';5import fs from 'fs';6import Configstore from 'configstore';7const packageJson = JSON.parse(fs.readFileSync('./AWSconfig.json', 'utf8'));8const config = new Configstore(packageJson.name, {});9const deployRehydrateSQS = async ({ uuid, rehydrateSQSDLQArn }) => {10 try {11 const rehydrateSQSName = `${REHYDRATION_QUEUE_NAME}-${uuid}`;12 const rehydrateSQSUrl = await createQueue({13 QueueName: rehydrateSQSName,14 Attributes: {15 MessageRetentionPeriod: '86400',16 RedrivePolicy: JSON.stringify({17 deadLetterTargetArn: rehydrateSQSDLQArn,18 maxReceiveCount: 119 })20 }21 });22 await pause(5000);23 config.set('RehydrateSQSUrl', rehydrateSQSUrl);24 25 const rehydrateSQSArn = await getQueueArn({ attributesArray: ['QueueArn'], queueURL: rehydrateSQSUrl });26 config.set('RehydrateSQSArn', rehydrateSQSArn);27 return rehydrateSQSArn;28 } catch (error) {29 throw new Error(error);30 }31}...
Using AI Code Generation
1const mb = require('mountebank');2const imposter = {3 stubs: [{4 responses: [{5 is: {6 }7 }]8 }]9};10mb.create(imposter)11 .then(() => {12 return mb.rehydrate('./imposters.ejs');13 })14 .then(() => {15 console.log('Imposter rehydrated');16 })17 .catch(err => {18 console.error(err);19 });20{21 {22 {23 {24 "is": {25 }26 }27 }28 }29}30const imposter = [{31 stubs: [{32 responses: [{33 is: {34 }35 }]36 }]37},38{39 stubs: [{40 responses: [{41 is: {42 }43 }]44 }]45}];46mb.rehydrate(imposter)47 .then(() => {48 console.log('Imposter rehydrated');49 })50 .catch(err => {51 console.error(err);52 });53mb.rehydrate('./imposters.ejs')54 .then(() => {55 console.log('Imposter rehydrated');56 })57 .catch(err => {58 console.error(err);59 });
Using AI Code Generation
1var mb = require('mountebank');2mb.start({3}).then(function (imposter) {4 return imposter.rehydrate({5 {6 {7 {8 is: {9 headers: {10 },11 body: JSON.stringify({ name: 'Test' })12 }13 }14 }15 }16 });17}).then(function () {18 console.log('Mountebank is ready');19}).catch(function (error) {20 console.error('Error starting mountebank', error);21});22var mb = require('mountebank');23mb.start({24}).then(function (imposter) {25 imposter.rehydrate({26 {27 {28 {29 is: {30 headers: {31 },32 body: JSON.stringify({ name: 'Test' })33 }34 }35 }36 }37 }).then(function () {38 console.log('Mountebank is ready');39 }).catch(function (error) {40 console.error('Error starting mountebank', error);41 });42});43var mb = require('mountebank');44mb.start({45}).then(function (imposter) {46 imposter.rehydrate({47 {
Using AI Code Generation
1const mb = require('mountebank');2mb.create({3}, function (error, server) {4 server.replay({5 {6 {7 {8 equals: {9 }10 }11 {12 is: {13 }14 }15 }16 }17 }, function (error, result) {18 });19});20const mb = require('mountebank');21mb.create({22}, function (error, server) {23 server.replay({24 {25 {26 {27 equals: {28 }29 }30 {31 is: {32 }33 }34 }35 }36 }, function (error, result) {37 });38});39const mb = require('mountebank');40mb.create({41}, function (error, server) {42 server.replay({43 {44 {45 {46 equals: {47 }48 }49 {50 is: {
Using AI Code Generation
1var mb = require('mountebank');2var fs = require('fs');3var imposter = JSON.parse(fs.readFileSync('imposter.json', 'utf8'));4mb.rehydrate(imposter, function(error, imposters) {5 if (error) {6 console.log("error is "+ error);7 }8 else {9 console.log("imposters are "+ imposters);10 }11});12{13 {14 {15 "is": {16 "headers": {17 }18 }19 }20 }21}22imposters are [ { port: 4545, protocol: 'http', numberOfRequests: 0, stubs: [ [Object] ] } ]
Using AI Code Generation
1var request = require('request');2var fs = require('fs');3var mbPort = 2525;4var mbHost = 'localhost';5var imposter = {6 {7 {8 "is": {9 }10 }11 }12};13var options = {14};15request(options, function (error, response, body) {16 if (!error && response.statusCode == 201) {17 console.log('Imposter created');18 var imposterUrl = mbUrl + '/imposters/' + body.port;19 var options = {20 };21 request(options, function (error, response, body) {22 if (!error && response.statusCode == 200) {23 console.log('Imposter deleted');24 var options = {25 };26 request(options, function (error, response, body) {27 if (!error && response.statusCode == 200) {28 console.log('Imposter rehydrated');29 }30 });31 }32 });33 }34});
Using AI Code Generation
1const mb = require('mountebank');2const imposters = require('./imposters.json');3const options = {replayable: true, removeProxies: true};4mb.start({port: 2525, pidfile: 'mb.pid', logfile: 'mb.log', loglevel: 'debug', ipWhitelist: ['*']}, () => {5 mb.replay('imposters.json', options, () => {6 console.log('Imposters replayed');7 });8});9{10 {11 {12 {13 "is" : {14 }15 }16 {17 "equals" : {18 }19 }20 }21 }22}
Using AI Code Generation
1var mb = require('mountebank');2mb.rehydrate({ imposters: [] }, function (error, response) {3 console.log(response);4});5{6 "scripts": {7 },8 "dependencies": {9 }10}
Using AI Code Generation
1const Imposter = require('mountebank').Imposter;2const rehydrate = require('mountebank').rehydrate;3const imposter = Imposter.create(8080);4imposter.addStub({5 {6 is: {7 }8 }9});10rehydrate(imposter).then(() => console.log('Imposter has been rehydrated'));11const Imposter = require('mountebank').Imposter;12const rehydrate = require('mountebank').rehydrate;13const imposter = Imposter.create(8080);14imposter.addStub({15 {16 is: {17 }18 }19});20rehydrate(imposter).then(() => console.log('Imposter has been rehydrated'));21const Imposter = require('mountebank').Imposter;22const rehydrate = require('mountebank').rehydrate;23const imposter = Imposter.create(8080);24imposter.addStub({25 {26 is: {27 }28 }29});30rehydrate(imposter).then(() => console.log('Imposter has been rehydrated'));31const Imposter = require('mountebank').Imposter;32const rehydrate = require('mountebank').rehydrate;33const imposter = Imposter.create(8080);34imposter.addStub({35 {36 is: {37 }38 }39});
Check out the latest blogs from LambdaTest on this topic:
Agile software development stems from a philosophy that being agile means creating and responding to change swiftly. Agile means having the ability to adapt and respond to change without dissolving into chaos. Being Agile involves teamwork built on diverse capabilities, skills, and talents. Team members include both the business and software development sides working together to produce working software that meets or exceeds customer expectations continuously.
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
In 2007, Steve Jobs launched the first iPhone, which revolutionized the world. But because of that, many businesses dealt with the problem of changing the layout of websites from desktop to mobile by delivering completely different mobile-compatible websites under the subdomain of ‘m’ (e.g., https://m.facebook.com). And we were all trying to figure out how to work in this new world of contending with mobile and desktop screen sizes.
Technical debt was originally defined as code restructuring, but in today’s fast-paced software delivery environment, it has evolved. Technical debt may be anything that the software development team puts off for later, such as ineffective code, unfixed defects, lacking unit tests, excessive manual tests, or missing automated tests. And, like financial debt, it is challenging to pay back.
Software Risk Management (SRM) combines a set of tools, processes, and methods for managing risks in the software development lifecycle. In SRM, we want to make informed decisions about what can go wrong at various levels within a company (e.g., business, project, and software related).
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!