SlideShare une entreprise Scribd logo
1  sur  21
Cloud Function For Firebase
GITS Indonesia
Sudaryatno
Technical Lead GITS Indonesia
Serverless, function as service (Faas)
Adalah cloud computing code execution model dimana cloud provider dapat
memanage secara meyeluruh, menjalankan dan memberhentikan container
dari setiam function.
Dan harga yang harus dibayarkan adalah ekesuti dari function tersebut bukan
per VM, per hit API, per Jam
Progression Serverless
Vendor Severless
AWS Lamda
Firebase Function
Microsoft Azure
IBM OpenWisk
Price Firebase Function
Intro
Cloud Function adalah tempat hosting yang private dan scalable untuk Node.js
environment.
Firebase SDK sekarang sudah terintegrasi dengan Cloud Function yang dapat
meresponse dan merequest fitur lain dari Firebase
Key capabilities
● Integrate The Firebase Platform
● Zero maintenance
● Keep your logic private and secure
Implement Path
Set up Functions Write Functions Deploy & Monitor
Function Start
npm install -g firebase-tools
myproject
+- .firebaserc # Hidden file that helps you quickly switch between
| # projects with `firebase use`
+- firebase.json # Describes properties for your project
+- functions/ # Directory containing all your functions code
+- package.json # npm package file describing your Cloud Functions code
+- index.js # main source file for your Cloud Functions code
+- node_modules/ # directory where your dependencies (declared in
# package.json) are installed
Perform Realtime
Database sanitization
and maintenance
1. Event user melakukan write di
database realtime
2. Function membaca action dan
juga dapat membrikan logic
dari action tersebut
3. Function menulis kembali di
database realtime dengan path
yang sama atau berbeda
GITS CODE Perform Realtime Database sanitization and maintenance
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original').onWrite(event => {
// Grab the current value of what was written to the Realtime Database.
const original = event.data.val();
console.log('Uppercasing', event.params.pushId, original);
const uppercase = original.toUpperCase();
// You must return a Promise when performing asynchronous tasks inside a Functions such as
// writing to the Firebase Realtime Database.
// Setting an "uppercase" sibling in the Realtime Database returns a Promise.
return event.data.ref.parent.child('uppercase').set(uppercase);
Execute intensive task in
the cloud instead of in
your app
1. Function mendapatkan trigger
dari user yang upload image
2. Function download image dan
membuat versi thumbnail
3. Function menyimpan path
thumbnail di database
4. Function upload ulang ke
firebase storage
GITS CODE
return mkdirp(tempLocalDir).then(() => {
// Download file from bucket.
const bucket = gcs.bucket(event.data.bucket);
return bucket.file(filePath).download({
destination: tempLocalFile
}).then(() => {
console.log('The file has been downloaded to', tempLocalFile);
// Generate a thumbnail using ImageMagick.
return spawn('convert', [tempLocalFile, '-thumbnail', `${THUMB_MAX_WIDTH}x${THUMB_MAX_HEIGHT}>`, tempLocalThumbFile]).then(() => {
console.log('Thumbnail created at', tempLocalThumbFile);
// Uploading the Thumbnail.
return bucket.upload(tempLocalThumbFile, {
destination: thumbFilePath
}).then(() => {
console.log('Thumbnail uploaded to Storage at', thumbFilePath);
});
});
});
});
Integrate with third-party
service and APIs
1. Function dapat triger dari
webhook github
2. Function memanggil api
postMessage
GITS CODE
exports.githubWebhook = functions.https.onRequest((req, res) => {
const cipher = 'sha1';
const signature = req.headers['x-hub-signature'];
// TODO: Configure the `github.secret` Google Cloud environment variables.
const hmac = crypto.createHmac(cipher, functions.config().github.secret)
// The JSON body is automatically parsed by Cloud Functions so we re-stringify it.
.update(JSON.stringify(req.body, null, 0))
.digest('hex');
const expectedSignature = `${cipher}=${hmac}`;
// Check that the body of the request has been signed with the GitHub Secret.
if (signature === expectedSignature) {
postToSlack(req.body.compare, req.body.commits.length, req.body.repository).then(() => {
res.end();
}).catch(error => {
console.error(error);
res.status(500).send('Something went wrong while posting the message to Slack.');
});
} else {
console.error('x-hub-signature', signature, 'did not match', expectedSignature);
res.status(403).send('Your x-hub-signature's bad and you should feel bad!');
}});
Full Sample
https://github.com/firebase/functions-
samples
Google Cloud Functions is Google's serverless compute
solution for creating event-driven applications. It is a joint
product between the Google Cloud Platform team and the
Firebase team.
Thanks!
Contact us:
Sudaryatno
GITS Indonesia
Bandung, Mars Barat 1 no 9
yatnosudar@gits.co.id
www.gits.id

Contenu connexe

Tendances

Gwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoGwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoRay Cromwell
 
Turducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teamsTurducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teamsRobert Keane
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDBChun-Kai Wang
 
I/O Extended (GDG Bogor) - Andrew Kurniadi
I/O Extended (GDG Bogor) - Andrew KurniadiI/O Extended (GDG Bogor) - Andrew Kurniadi
I/O Extended (GDG Bogor) - Andrew KurniadiDicoding
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page AppsZachary Klein
 
Blue whale, jail and Microsoft
Blue whale, jail and MicrosoftBlue whale, jail and Microsoft
Blue whale, jail and MicrosoftLukasz Kaluzny
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSunghyouk Bae
 
Getting started with Google App Engine
Getting started with Google App EngineGetting started with Google App Engine
Getting started with Google App EngineMilindu Sanoj Kumarage
 
Day 2 Kubernetes - Tools for Operability (KubeCon)
Day 2 Kubernetes - Tools for Operability (KubeCon)Day 2 Kubernetes - Tools for Operability (KubeCon)
Day 2 Kubernetes - Tools for Operability (KubeCon)bridgetkromhout
 
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...AZUG FR
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Matt Raible
 
Budowanie szablonów Azure Resource Manager w praktyce od podstaw
Budowanie szablonów Azure Resource Manager w praktyce od podstawBudowanie szablonów Azure Resource Manager w praktyce od podstaw
Budowanie szablonów Azure Resource Manager w praktyce od podstawLukasz Kaluzny
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-pythonDeepak Garg
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor appRitik Malhotra
 
Build and ship apps with MeteorJS, Docker and Azure
Build and ship apps with MeteorJS, Docker and AzureBuild and ship apps with MeteorJS, Docker and Azure
Build and ship apps with MeteorJS, Docker and AzureInvolved IT
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Matt Raible
 

Tendances (20)

Gwt.Create Keynote San Francisco
Gwt.Create Keynote San FranciscoGwt.Create Keynote San Francisco
Gwt.Create Keynote San Francisco
 
Turducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teamsTurducken - Divide and Conquer large GWT apps with multiple teams
Turducken - Divide and Conquer large GWT apps with multiple teams
 
F1
F1F1
F1
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
I/O Extended (GDG Bogor) - Andrew Kurniadi
I/O Extended (GDG Bogor) - Andrew KurniadiI/O Extended (GDG Bogor) - Andrew Kurniadi
I/O Extended (GDG Bogor) - Andrew Kurniadi
 
Micronaut For Single Page Apps
Micronaut For Single Page AppsMicronaut For Single Page Apps
Micronaut For Single Page Apps
 
Micronaut Launchpad
Micronaut LaunchpadMicronaut Launchpad
Micronaut Launchpad
 
Blue whale, jail and Microsoft
Blue whale, jail and MicrosoftBlue whale, jail and Microsoft
Blue whale, jail and Microsoft
 
SpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSLSpringBoot with MyBatis, Flyway, QueryDSL
SpringBoot with MyBatis, Flyway, QueryDSL
 
Getting started with Google App Engine
Getting started with Google App EngineGetting started with Google App Engine
Getting started with Google App Engine
 
Day 2 Kubernetes - Tools for Operability (KubeCon)
Day 2 Kubernetes - Tools for Operability (KubeCon)Day 2 Kubernetes - Tools for Operability (KubeCon)
Day 2 Kubernetes - Tools for Operability (KubeCon)
 
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...
GLobal Azure Bootcamp 2016 Lyon Benjamin Talmard Azure Micro-services Contain...
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
 
MeteorJS Meetup
MeteorJS MeetupMeteorJS Meetup
MeteorJS Meetup
 
Budowanie szablonów Azure Resource Manager w praktyce od podstaw
Budowanie szablonów Azure Resource Manager w praktyce od podstawBudowanie szablonów Azure Resource Manager w praktyce od podstaw
Budowanie szablonów Azure Resource Manager w praktyce od podstaw
 
Google app-engine-with-python
Google app-engine-with-pythonGoogle app-engine-with-python
Google app-engine-with-python
 
Building a production ready meteor app
Building a production ready meteor appBuilding a production ready meteor app
Building a production ready meteor app
 
Build and ship apps with MeteorJS, Docker and Azure
Build and ship apps with MeteorJS, Docker and AzureBuild and ship apps with MeteorJS, Docker and Azure
Build and ship apps with MeteorJS, Docker and Azure
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
 

En vedette

Modul praktikum 17 - Android Sudaryatno
Modul praktikum 17 - Android SudaryatnoModul praktikum 17 - Android Sudaryatno
Modul praktikum 17 - Android SudaryatnoYatno Sudar
 
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e)
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e) E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e)
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e) Exterro
 
Modul praktikum 14 - Android Sudaryatno
Modul praktikum 14 - Android SudaryatnoModul praktikum 14 - Android Sudaryatno
Modul praktikum 14 - Android SudaryatnoYatno Sudar
 
Modul praktikum 8 - Android Sudaryatno
Modul praktikum 8 - Android SudaryatnoModul praktikum 8 - Android Sudaryatno
Modul praktikum 8 - Android SudaryatnoYatno Sudar
 
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)Amazon Web Services
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaAmazon Web Services
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksAmazon Web Services
 
Five keys to successful cloud migration
Five keys to successful cloud migrationFive keys to successful cloud migration
Five keys to successful cloud migrationIBM
 

En vedette (10)

Modul praktikum 17 - Android Sudaryatno
Modul praktikum 17 - Android SudaryatnoModul praktikum 17 - Android Sudaryatno
Modul praktikum 17 - Android Sudaryatno
 
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e)
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e) E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e)
E-Discovery Infographic: Reasonable Preservation Process under FRCP Rule 37(e)
 
Modul praktikum 14 - Android Sudaryatno
Modul praktikum 14 - Android SudaryatnoModul praktikum 14 - Android Sudaryatno
Modul praktikum 14 - Android Sudaryatno
 
HashiCorp's Vault - The Examples
HashiCorp's Vault - The ExamplesHashiCorp's Vault - The Examples
HashiCorp's Vault - The Examples
 
Modul praktikum 8 - Android Sudaryatno
Modul praktikum 8 - Android SudaryatnoModul praktikum 8 - Android Sudaryatno
Modul praktikum 8 - Android Sudaryatno
 
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)
AWS re:Invent 2016: Automated Governance of Your AWS Resources (DEV302)
 
A Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS LambdaA Walk in the Cloud with AWS Lambda
A Walk in the Cloud with AWS Lambda
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
 
Five keys to successful cloud migration
Five keys to successful cloud migrationFive keys to successful cloud migration
Five keys to successful cloud migration
 
Build Features, Not Apps
Build Features, Not AppsBuild Features, Not Apps
Build Features, Not Apps
 

Similaire à Cloud Function For Firebase - GITS

Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugToshiaki Maki
 
Firebase Cloud Functions V2
Firebase Cloud Functions V2Firebase Cloud Functions V2
Firebase Cloud Functions V2Aviv Laufer
 
Serverless with Firebase - Launchpad Build Burgos
Serverless with Firebase - Launchpad Build Burgos Serverless with Firebase - Launchpad Build Burgos
Serverless with Firebase - Launchpad Build Burgos Carlos Azaustre
 
Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overviewMaksym Davydov
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseMarina Coelho
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with FirebaseMike Fowler
 
Simplify Cloud Applications using Spring Cloud
Simplify Cloud Applications using Spring CloudSimplify Cloud Applications using Spring Cloud
Simplify Cloud Applications using Spring CloudRamnivas Laddad
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Codemotion
 
Google Cloud Build - Sfeir Lunch Janvier 2019
Google Cloud Build - Sfeir Lunch Janvier 2019Google Cloud Build - Sfeir Lunch Janvier 2019
Google Cloud Build - Sfeir Lunch Janvier 2019Gaëlle Acas
 
We All Live in a Yellow (Serverless) Submarine
We All Live in a Yellow (Serverless) SubmarineWe All Live in a Yellow (Serverless) Submarine
We All Live in a Yellow (Serverless) SubmarineFITC
 
Exploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in PythonExploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in PythonIvan Ma
 
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps_Fest
 
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Amazon Web Services
 
e-KTP Information Extraction with Google Cloud Function & Google Cloud Vision
e-KTP Information Extraction with Google Cloud Function & Google Cloud Visione-KTP Information Extraction with Google Cloud Function & Google Cloud Vision
e-KTP Information Extraction with Google Cloud Function & Google Cloud VisionImre Nagi
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf
 
AWSome day 2018 - API serverless with aws
AWSome day 2018  - API serverless with awsAWSome day 2018  - API serverless with aws
AWSome day 2018 - API serverless with awsCorley S.r.l.
 
Azure functions
Azure functionsAzure functions
Azure functions명신 김
 

Similaire à Cloud Function For Firebase - GITS (20)

Spring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsugSpring Cloud Function & Project riff #jsug
Spring Cloud Function & Project riff #jsug
 
Firebase Cloud Functions V2
Firebase Cloud Functions V2Firebase Cloud Functions V2
Firebase Cloud Functions V2
 
Serverless with Firebase - Launchpad Build Burgos
Serverless with Firebase - Launchpad Build Burgos Serverless with Firebase - Launchpad Build Burgos
Serverless with Firebase - Launchpad Build Burgos
 
Lecture 11 Firebase overview
Lecture 11 Firebase overviewLecture 11 Firebase overview
Lecture 11 Firebase overview
 
Firebase overview
Firebase overviewFirebase overview
Firebase overview
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
 
Building with Firebase
Building with FirebaseBuilding with Firebase
Building with Firebase
 
Simplify Cloud Applications using Spring Cloud
Simplify Cloud Applications using Spring CloudSimplify Cloud Applications using Spring Cloud
Simplify Cloud Applications using Spring Cloud
 
Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...Alex Casalboni - Configuration management and service discovery - Codemotion ...
Alex Casalboni - Configuration management and service discovery - Codemotion ...
 
Google Cloud Build - Sfeir Lunch Janvier 2019
Google Cloud Build - Sfeir Lunch Janvier 2019Google Cloud Build - Sfeir Lunch Janvier 2019
Google Cloud Build - Sfeir Lunch Janvier 2019
 
We All Live in a Yellow (Serverless) Submarine
We All Live in a Yellow (Serverless) SubmarineWe All Live in a Yellow (Serverless) Submarine
We All Live in a Yellow (Serverless) Submarine
 
Exploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in PythonExploring MySQL Operator for Kubernetes in Python
Exploring MySQL Operator for Kubernetes in Python
 
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
DevOps Fest 2019. Alex Casalboni. Configuration management and service discov...
 
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
Building Cloud-Backed Mobile Apps (MBL402) | AWS re:Invent 2013
 
e-KTP Information Extraction with Google Cloud Function & Google Cloud Vision
e-KTP Information Extraction with Google Cloud Function & Google Cloud Visione-KTP Information Extraction with Google Cloud Function & Google Cloud Vision
e-KTP Information Extraction with Google Cloud Function & Google Cloud Vision
 
Firebase
Firebase Firebase
Firebase
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
 
GradleFX
GradleFXGradleFX
GradleFX
 
AWSome day 2018 - API serverless with aws
AWSome day 2018  - API serverless with awsAWSome day 2018  - API serverless with aws
AWSome day 2018 - API serverless with aws
 
Azure functions
Azure functionsAzure functions
Azure functions
 

Plus de Yatno Sudar

Introduction Data Warehouse With BigQuery
Introduction Data Warehouse With BigQueryIntroduction Data Warehouse With BigQuery
Introduction Data Warehouse With BigQueryYatno Sudar
 
Introduction Flutter for Create Multiplatform Apps
Introduction Flutter for Create Multiplatform AppsIntroduction Flutter for Create Multiplatform Apps
Introduction Flutter for Create Multiplatform AppsYatno Sudar
 
Chatbot With Dialogflow
Chatbot With DialogflowChatbot With Dialogflow
Chatbot With DialogflowYatno Sudar
 
Dialog Flow - GITS Indonesia
Dialog Flow - GITS IndonesiaDialog Flow - GITS Indonesia
Dialog Flow - GITS IndonesiaYatno Sudar
 
Technical Feasibility For Product
Technical Feasibility For ProductTechnical Feasibility For Product
Technical Feasibility For ProductYatno Sudar
 
Modul praktikum 16 - Android Sudaryatno
Modul praktikum 16 - Android SudaryatnoModul praktikum 16 - Android Sudaryatno
Modul praktikum 16 - Android SudaryatnoYatno Sudar
 
Modul praktikum 15 - Android Sudaryatno
Modul praktikum 15 - Android SudaryatnoModul praktikum 15 - Android Sudaryatno
Modul praktikum 15 - Android SudaryatnoYatno Sudar
 
Modul praktikum 13 - Android Sudaryatno
Modul praktikum 13 - Android SudaryatnoModul praktikum 13 - Android Sudaryatno
Modul praktikum 13 - Android SudaryatnoYatno Sudar
 
Modul praktikum 12 - Android Sudaryatno
Modul praktikum 12 - Android SudaryatnoModul praktikum 12 - Android Sudaryatno
Modul praktikum 12 - Android SudaryatnoYatno Sudar
 
Modul praktikum 11 - Android Sudaryatno
Modul praktikum 11 - Android SudaryatnoModul praktikum 11 - Android Sudaryatno
Modul praktikum 11 - Android SudaryatnoYatno Sudar
 
Modul praktikum 10 - Android Sudaryatno
Modul praktikum 10 - Android SudaryatnoModul praktikum 10 - Android Sudaryatno
Modul praktikum 10 - Android SudaryatnoYatno Sudar
 
Modul praktikum 9 - Android Sudaryatno
Modul praktikum 9 - Android SudaryatnoModul praktikum 9 - Android Sudaryatno
Modul praktikum 9 - Android SudaryatnoYatno Sudar
 
Modul praktikum 7 - Android Sudaryatno
Modul praktikum 7 - Android SudaryatnoModul praktikum 7 - Android Sudaryatno
Modul praktikum 7 - Android SudaryatnoYatno Sudar
 
Modul praktikum 5 - Android Sudaryatno
Modul praktikum 5 - Android SudaryatnoModul praktikum 5 - Android Sudaryatno
Modul praktikum 5 - Android SudaryatnoYatno Sudar
 
Modul praktikum 4 - Android Sudaryatno
Modul praktikum 4 - Android SudaryatnoModul praktikum 4 - Android Sudaryatno
Modul praktikum 4 - Android SudaryatnoYatno Sudar
 
Modul praktikum 3 - Android Sudaryatno
Modul praktikum 3 - Android SudaryatnoModul praktikum 3 - Android Sudaryatno
Modul praktikum 3 - Android SudaryatnoYatno Sudar
 
Modul praktikum 2 - Android Sudaryatno
Modul praktikum 2 - Android SudaryatnoModul praktikum 2 - Android Sudaryatno
Modul praktikum 2 - Android SudaryatnoYatno Sudar
 

Plus de Yatno Sudar (18)

Slack Time
Slack TimeSlack Time
Slack Time
 
Introduction Data Warehouse With BigQuery
Introduction Data Warehouse With BigQueryIntroduction Data Warehouse With BigQuery
Introduction Data Warehouse With BigQuery
 
Introduction Flutter for Create Multiplatform Apps
Introduction Flutter for Create Multiplatform AppsIntroduction Flutter for Create Multiplatform Apps
Introduction Flutter for Create Multiplatform Apps
 
Chatbot With Dialogflow
Chatbot With DialogflowChatbot With Dialogflow
Chatbot With Dialogflow
 
Dialog Flow - GITS Indonesia
Dialog Flow - GITS IndonesiaDialog Flow - GITS Indonesia
Dialog Flow - GITS Indonesia
 
Technical Feasibility For Product
Technical Feasibility For ProductTechnical Feasibility For Product
Technical Feasibility For Product
 
Modul praktikum 16 - Android Sudaryatno
Modul praktikum 16 - Android SudaryatnoModul praktikum 16 - Android Sudaryatno
Modul praktikum 16 - Android Sudaryatno
 
Modul praktikum 15 - Android Sudaryatno
Modul praktikum 15 - Android SudaryatnoModul praktikum 15 - Android Sudaryatno
Modul praktikum 15 - Android Sudaryatno
 
Modul praktikum 13 - Android Sudaryatno
Modul praktikum 13 - Android SudaryatnoModul praktikum 13 - Android Sudaryatno
Modul praktikum 13 - Android Sudaryatno
 
Modul praktikum 12 - Android Sudaryatno
Modul praktikum 12 - Android SudaryatnoModul praktikum 12 - Android Sudaryatno
Modul praktikum 12 - Android Sudaryatno
 
Modul praktikum 11 - Android Sudaryatno
Modul praktikum 11 - Android SudaryatnoModul praktikum 11 - Android Sudaryatno
Modul praktikum 11 - Android Sudaryatno
 
Modul praktikum 10 - Android Sudaryatno
Modul praktikum 10 - Android SudaryatnoModul praktikum 10 - Android Sudaryatno
Modul praktikum 10 - Android Sudaryatno
 
Modul praktikum 9 - Android Sudaryatno
Modul praktikum 9 - Android SudaryatnoModul praktikum 9 - Android Sudaryatno
Modul praktikum 9 - Android Sudaryatno
 
Modul praktikum 7 - Android Sudaryatno
Modul praktikum 7 - Android SudaryatnoModul praktikum 7 - Android Sudaryatno
Modul praktikum 7 - Android Sudaryatno
 
Modul praktikum 5 - Android Sudaryatno
Modul praktikum 5 - Android SudaryatnoModul praktikum 5 - Android Sudaryatno
Modul praktikum 5 - Android Sudaryatno
 
Modul praktikum 4 - Android Sudaryatno
Modul praktikum 4 - Android SudaryatnoModul praktikum 4 - Android Sudaryatno
Modul praktikum 4 - Android Sudaryatno
 
Modul praktikum 3 - Android Sudaryatno
Modul praktikum 3 - Android SudaryatnoModul praktikum 3 - Android Sudaryatno
Modul praktikum 3 - Android Sudaryatno
 
Modul praktikum 2 - Android Sudaryatno
Modul praktikum 2 - Android SudaryatnoModul praktikum 2 - Android Sudaryatno
Modul praktikum 2 - Android Sudaryatno
 

Dernier

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Cloud Function For Firebase - GITS

  • 1. Cloud Function For Firebase GITS Indonesia
  • 3.
  • 4. Serverless, function as service (Faas) Adalah cloud computing code execution model dimana cloud provider dapat memanage secara meyeluruh, menjalankan dan memberhentikan container dari setiam function. Dan harga yang harus dibayarkan adalah ekesuti dari function tersebut bukan per VM, per hit API, per Jam
  • 6. Vendor Severless AWS Lamda Firebase Function Microsoft Azure IBM OpenWisk
  • 8. Intro Cloud Function adalah tempat hosting yang private dan scalable untuk Node.js environment. Firebase SDK sekarang sudah terintegrasi dengan Cloud Function yang dapat meresponse dan merequest fitur lain dari Firebase
  • 9. Key capabilities ● Integrate The Firebase Platform ● Zero maintenance ● Keep your logic private and secure
  • 10. Implement Path Set up Functions Write Functions Deploy & Monitor
  • 11. Function Start npm install -g firebase-tools
  • 12. myproject +- .firebaserc # Hidden file that helps you quickly switch between | # projects with `firebase use` +- firebase.json # Describes properties for your project +- functions/ # Directory containing all your functions code +- package.json # npm package file describing your Cloud Functions code +- index.js # main source file for your Cloud Functions code +- node_modules/ # directory where your dependencies (declared in # package.json) are installed
  • 13. Perform Realtime Database sanitization and maintenance 1. Event user melakukan write di database realtime 2. Function membaca action dan juga dapat membrikan logic dari action tersebut 3. Function menulis kembali di database realtime dengan path yang sama atau berbeda
  • 14. GITS CODE Perform Realtime Database sanitization and maintenance exports.makeUppercase = functions.database.ref('/messages/{pushId}/original').onWrite(event => { // Grab the current value of what was written to the Realtime Database. const original = event.data.val(); console.log('Uppercasing', event.params.pushId, original); const uppercase = original.toUpperCase(); // You must return a Promise when performing asynchronous tasks inside a Functions such as // writing to the Firebase Realtime Database. // Setting an "uppercase" sibling in the Realtime Database returns a Promise. return event.data.ref.parent.child('uppercase').set(uppercase);
  • 15. Execute intensive task in the cloud instead of in your app 1. Function mendapatkan trigger dari user yang upload image 2. Function download image dan membuat versi thumbnail 3. Function menyimpan path thumbnail di database 4. Function upload ulang ke firebase storage
  • 16. GITS CODE return mkdirp(tempLocalDir).then(() => { // Download file from bucket. const bucket = gcs.bucket(event.data.bucket); return bucket.file(filePath).download({ destination: tempLocalFile }).then(() => { console.log('The file has been downloaded to', tempLocalFile); // Generate a thumbnail using ImageMagick. return spawn('convert', [tempLocalFile, '-thumbnail', `${THUMB_MAX_WIDTH}x${THUMB_MAX_HEIGHT}>`, tempLocalThumbFile]).then(() => { console.log('Thumbnail created at', tempLocalThumbFile); // Uploading the Thumbnail. return bucket.upload(tempLocalThumbFile, { destination: thumbFilePath }).then(() => { console.log('Thumbnail uploaded to Storage at', thumbFilePath); }); }); }); });
  • 17. Integrate with third-party service and APIs 1. Function dapat triger dari webhook github 2. Function memanggil api postMessage
  • 18. GITS CODE exports.githubWebhook = functions.https.onRequest((req, res) => { const cipher = 'sha1'; const signature = req.headers['x-hub-signature']; // TODO: Configure the `github.secret` Google Cloud environment variables. const hmac = crypto.createHmac(cipher, functions.config().github.secret) // The JSON body is automatically parsed by Cloud Functions so we re-stringify it. .update(JSON.stringify(req.body, null, 0)) .digest('hex'); const expectedSignature = `${cipher}=${hmac}`; // Check that the body of the request has been signed with the GitHub Secret. if (signature === expectedSignature) { postToSlack(req.body.compare, req.body.commits.length, req.body.repository).then(() => { res.end(); }).catch(error => { console.error(error); res.status(500).send('Something went wrong while posting the message to Slack.'); }); } else { console.error('x-hub-signature', signature, 'did not match', expectedSignature); res.status(403).send('Your x-hub-signature's bad and you should feel bad!'); }});
  • 20. Google Cloud Functions is Google's serverless compute solution for creating event-driven applications. It is a joint product between the Google Cloud Platform team and the Firebase team.
  • 21. Thanks! Contact us: Sudaryatno GITS Indonesia Bandung, Mars Barat 1 no 9 yatnosudar@gits.co.id www.gits.id

Notes de l'éditeur

  1. Adalah cloud computing code execution model dimana cloud provider dapat memanage secara meyeluruh, menjalankan dan memberhentikan container dari setiam function. Dan harga yang harus dibayarkan adalah ekesuti dari function tersebut bukan per VM, per hit API, per Jam
  2. https://www.slideshare.net/AmazonWebServices/a-brief-look-at-serverless-architecture
  3. Contoh dari google function dapat membuat API, meresponse listener dari firebase dan juga dapat di integrasikan dengan produk google yang lainnnya
  4. npm install -g firebase-tools
  5. Execute intensive tasks in the cloud instead of in your app A function triggers when an image file is uploaded to Storage. The function downloads the image and creates a thumbnail version of it. The function writes that thumbnail location to the database, so a client app can find and use it. The function uploads the thumbnail back to Storage in a new location.
  6. Integrate with third-party services and APIs