Skip to content

Google Cloud Function helper to log and transform bucket events to Promises of new json file metadata and json data

License

Notifications You must be signed in to change notification settings

DrPaulBrewer/maybe-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maybe-json

Google Cloud Function helper to log and transform bucket events to Promises of new json file metadata and json data

This is a helper or skeleton for writing back-end events that trigger on change to a google storage bucket.

All uploaded json file contents are logged, and then returned from a new Promise, provided file size < 1 MB

Usage

const maybejSON = require('maybe-json');

exports.myGoogleCloudFunction = function myGoogleCloudFunction(event){
    return (maybeJSON(event)
        .then(function(filedata){
	   if (filedata) {  // note, filedata can be "undefined" for non-file events or deletion events
	       const file = filedata.file;   // the google cloud function file event
	       const data = filedata.data;   // the parsed json data contained in the new file
	       // do something useful with the data
	   }
	 })
	 );
}

Copyright

Copyright 2017, Paul Brewer, Economic and Financial Technology Consulting LLC [email protected]

License

MIT

About

Google Cloud Function helper to log and transform bucket events to Promises of new json file metadata and json data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published