1.4.2 • Published 6 months ago

connectivity-common-utils v1.4.2

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

connectivity-common-utils

Set of common utils reusable between any connectivity projects.

Installation

npm install git+ssh://git@github.com:homelike/connectivity-common-utils.git

Util Functions

S3 Services

This service class is used to store & retrieve data to/from the S3 bucket for the connectivity projects

Example

  1. import service
const { S3Services } = require('connectivity-common-utils');
  1. Create an instance from the class
const connectivityName = 'ICal';
const s3Bucket = process.env.S3_BUCKET; // Make sure the Bucket exist or create one.
const s3Region = process.env.AWS_REGION;
const fileExt = 'ics' // Raw file extension
const s3Services = new S3Services({connectivityName, s3Bucket, s3Region, fileExt});
  1. Now call the service you need.

Example: s3Services.pushRawData() to push raw data into S3

pushRawData()

When you call this method, it pushed the data into S3 and it set the .latest to point to this new file.

const icalData = `BEGIN:VCALENDAR
 PRODID:-//xyz Corp//NONSGML PDA Calendar Version 1.0//EN
 VERSION:2.0
 BEGIN:VEVENT
 DTSTAMP:19960704T120000Z
 UID:uid1@example.com
 ORGANIZER:mailto:jsmith@example.com
 DTSTART:19960918T143000Z
 DTEND:19960920T220000Z
 STATUS:CONFIRMED
 CATEGORIES:CONFERENCE
 SUMMARY:Networld+Interop Conference
 DESCRIPTION:Networld+Interop Conference
   and Exhibit\nAtlanta World Congress Center\n
  Atlanta\, Georgia
 END:VEVENT
 END:VCALENDAR`

await s3Services.pushRawData('propertyGroupId',icalData);

getLatestRawData

Get the latest Raw data of a property. It retrieves data by fetching the .latest of the given propertyGroupId and fetches the raw data.

const ical = await s3Services.getLatestRawData('propertyGroupId');