SlideShare a Scribd company logo
1 of 19
Download to read offline
export const unregisterUser = functions
.region(‘asia-northeast1')
.https.onCall( … function )
firebase deploy --only functions:unregisterUser
firebase deploy --only functions:app.unregisterUser
export const app = {
registerUser: functionA,
unregisterUser: functionB
sub: {
dbtrigger: functionC //
}
};
firebase deploy --only functions:app.sub
firebase deploy --only functions
export const app = {
realtimeDatabaseTrigger,
firestoreTrigger,
batchTrigger,
endpoints
};
"deploy:dev": "firebase use default && faenv .env.default && cross-env NODE_ENV=development firebase deploy --only functions:app",
"functions": {
"source": "dist/functions",
"predeploy": [
"echo $NODE_ENV",
"rm -fr dist",
"npm run lint",
"npm run build",
"cpx "{package.json,yarn.lock,.npmrc}" dist/functions"
]
},
https://github.com/MOCHI-inc-JAPAN/firebase-auto-env
faenv: firebase functions:config:set .env npm
https://gist.github.com/tkow/e7db698f11d5dd61f3f2a6a5d7a48fec
type CloudFunctionsInterface<
CloudFunctionDefinitions extends {
[key: string]: (arg?: any) => any;
}
> = {
[key in keyof CloudFunctionDefinitions]: {
func: CloudFunctionDefinitions[key];
interface: {
args: Parameters<CloudFunctionDefinitions[key]>[0];
result: ReturnType<CloudFunctionDefinitions[key]>;
};
};
};
type User = { user: { name: string } };
type AppCloudFunctions = CloudFunctionsInterface<{
'sample-updateUserProfile': (args: User) => User;
}>;
https://gist.github.com/tkow/e7db698f11d5dd61f3f2a6a5d7a48fec
// list functions api
const callableFunctions = {
updateUserProfile: 'sample-updateUserProfile'
} as const;
httpsCallable<Key extends keyof AppCloudFunctions>(
name: Key
): HttpsCallable<
AppCloudFunctions[Key]['interface']['args'],
AppCloudFunctions[Key]['interface']['result']
>
commander.command('backupAlgoliaIndexSetting <indexes...>').action(async (args) => {
const results = await algoliaManager.getIndexSetting(args)
if(results && Array.isArray(results)) {
const promises = await Promise.all(results.map( async (setting,index) =>
new Promise((resolve,reject)=>{
const _path = path.join(process.cwd(),'algolia','indexes',`${args[index]}.json`)
fs.writeFile(
_path,
JSON.stringify(setting,null,2),
(err) => {
if(err) return reject(err.message)
console.log(`${args[index]}: are written to ${_path}`)
return resolve('success')
}
)
})
))
console.log(promises)
}
process.exit()
})
commander.command('updateAlgoliaIndexSetting <indexes...>').action(async (args) => {
const promises = await Promise.all(args.map( async (fileName,index) => {
return new Promise( (resolve,reject)=>{
const _path = path.join(process.cwd(),'algolia','indexes',`${fileName}.json`)
fs.readFile(_path,'utf8',async (err,_setting)=>{
if(err) return reject(err.message)
const setting:IndexSettings = JSON.parse(_setting)
const result = await algoliaManager.updateIndexSetting({
indexName: args[index] as string,
setting
})
console.log(setting)
if(result) {
resolve('success')
} else {
reject('index update failed')
}
})
})
}))
console.log(promises)
process.exit()
})
https://github.com/MOCHI-inc-JAPAN/algolia-firebase-tools/blob/develop/template/index.ts
export const example = functions
.runWith(runWithOptions)
.https.onRequest((request, response) => {
return nextjsServer.prepare().then(async () => {
if (isDevFunction) {
const expressServer = express()
const { default: basicAuth } = await import('basic-auth-connect')
const USERNAME = functions.config().example.basic_auth_user
const PASSWORD = functions.config().example.basic_auth_password
expressServer.use(basicAuth(USERNAME, PASSWORD))
expressServer.all('*', (req, res) => {
return nextjsHandle(req, res)
})
expressServer(request, response)
} else {
nextjsHandle(request, response)
}
})
})
// Deny read/write access to all users under any conditions
service cloud.firestore {
match /databases/{database}/documents {
function adminControl() {
return request.auth.token.admin == true;
}
function isLogin() {
return request.auth.uid != null;
}
match /sampleData/{logId} {
allow read: if adminControl();
allow create: if isLogin();
allow update: if adminControl();
allow delete: if adminControl();
}
}
}
function* saveUserProfile() {
yield takeLatest(SAVE_PROFILE, function*({ payload: user }: Action<User>) {
const currentUser = yield call(getCurrentUser);
if (currentUser && currentUser.uid) {
const profileDocument = getDocumentRef(`users/${currentUser.uid}`);
user && profileDocument.set(UserNormalizr.denormalize(user));
}
});
}
const adminOrIdentityUser = (
dataId: string,
context: functions.https.CallableContext
) => {
return (
dataId === context.auth.uid ||
(context.auth && context.auth.token && context.auth.token.admin)
);
};
Rntb20200805

More Related Content

What's hot

Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular jsMarcin Wosinek
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleGeoff Ballinger
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to productionFDConf
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​FDConf
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.CocoaHeads France
 
Autoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadAutoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadBram Vogelaar
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "FDConf
 
Real world scala
Real world scalaReal world scala
Real world scalalunfu zhong
 
Why Redux-Observable?
Why Redux-Observable?Why Redux-Observable?
Why Redux-Observable?Anna Su
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Codemotion
 
Anaysing your logs with docker and elk
Anaysing your logs with docker and elkAnaysing your logs with docker and elk
Anaysing your logs with docker and elkmelvin louwerse
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsBrainhub
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascriptPavel Volokitin
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suiteWit Jakuczun
 

What's hot (20)

fabfile.py
fabfile.pyfabfile.py
fabfile.py
 
Automation in angular js
Automation in angular jsAutomation in angular js
Automation in angular js
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's Finagle
 
Redux. From twitter hype to production
Redux. From twitter hype to productionRedux. From twitter hype to production
Redux. From twitter hype to production
 
Phpbase
PhpbasePhpbase
Phpbase
 
Finch + Finagle OAuth2
Finch + Finagle OAuth2Finch + Finagle OAuth2
Finch + Finagle OAuth2
 
From * to Symfony2
From * to Symfony2From * to Symfony2
From * to Symfony2
 
«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​«От экспериментов с инфраструктурой до внедрения в продакшен»​
«От экспериментов с инфраструктурой до внедрения в продакшен»​
 
Advanced redux
Advanced reduxAdvanced redux
Advanced redux
 
Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.Découvrir dtrace en ligne de commande.
Découvrir dtrace en ligne de commande.
 
Autoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomadAutoscaling with hashi_corp_nomad
Autoscaling with hashi_corp_nomad
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Real world scala
Real world scalaReal world scala
Real world scala
 
ES6 generators
ES6 generatorsES6 generators
ES6 generators
 
Why Redux-Observable?
Why Redux-Observable?Why Redux-Observable?
Why Redux-Observable?
 
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
Going fullstack React(ive) - Paulo Lopes - Codemotion Amsterdam 2017
 
Anaysing your logs with docker and elk
Anaysing your logs with docker and elkAnaysing your logs with docker and elk
Anaysing your logs with docker and elk
 
All you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, GeneratorsAll you need to know about Callbacks, Promises, Generators
All you need to know about Callbacks, Promises, Generators
 
Меняем javascript с помощью javascript
Меняем javascript с помощью javascriptМеняем javascript с помощью javascript
Меняем javascript с помощью javascript
 
Large scale machine learning projects with r suite
Large scale machine learning projects with r suiteLarge scale machine learning projects with r suite
Large scale machine learning projects with r suite
 

Similar to Rntb20200805

Apache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationBartosz Konieczny
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js frameworkBen Lin
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Gotdc-globalcode
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integraçãoVinícius Pretto da Silva
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013Laurent_VB
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerNic Raboy
 
Node js introduction
Node js introductionNode js introduction
Node js introductionAlex Su
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots DeepAnshu Sharma
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsKritika Phulli
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot Nidhi Chauhan
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsFrancois Zaninotto
 
Threads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOSThreads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOSTechWell
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesLindsay Holmwood
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on AndroidSven Haiges
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript Glenn Stovall
 

Similar to Rntb20200805 (20)

Apache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customizationApache Spark in your likeness - low and high level customization
Apache Spark in your likeness - low and high level customization
 
How and why i roll my own node.js framework
How and why i roll my own node.js frameworkHow and why i roll my own node.js framework
How and why i roll my own node.js framework
 
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com GoTDC2018SP | Trilha Go - Processando analise genetica em background com Go
TDC2018SP | Trilha Go - Processando analise genetica em background com Go
 
Nodejs do teste de unidade ao de integração
Nodejs  do teste de unidade ao de integraçãoNodejs  do teste de unidade ao de integração
Nodejs do teste de unidade ao de integração
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Quick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase ServerQuick and Easy Development with Node.js and Couchbase Server
Quick and Easy Development with Node.js and Couchbase Server
 
Node js introduction
Node js introductionNode js introduction
Node js introduction
 
ES6 Overview
ES6 OverviewES6 Overview
ES6 Overview
 
Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots Dpilot Source Code With ScreenShots
Dpilot Source Code With ScreenShots
 
Dpilot - Source Code with Snapshots
Dpilot - Source Code with SnapshotsDpilot - Source Code with Snapshots
Dpilot - Source Code with Snapshots
 
Source Code for Dpilot
Source Code for Dpilot Source Code for Dpilot
Source Code for Dpilot
 
Bonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node jsBonnes pratiques de développement avec Node js
Bonnes pratiques de développement avec Node js
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Threads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOSThreads, Queues, and More: Async Programming in iOS
Threads, Queues, and More: Async Programming in iOS
 
Burn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
 
Think Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJSThink Async: Asynchronous Patterns in NodeJS
Think Async: Asynchronous Patterns in NodeJS
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
Reliable Javascript
Reliable Javascript Reliable Javascript
Reliable Javascript
 
Node.js - Best practices
Node.js  - Best practicesNode.js  - Best practices
Node.js - Best practices
 

Recently uploaded

CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 

Recently uploaded (20)

CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 

Rntb20200805

  • 1.
  • 2.
  • 3.
  • 4. export const unregisterUser = functions .region(‘asia-northeast1') .https.onCall( … function ) firebase deploy --only functions:unregisterUser
  • 5. firebase deploy --only functions:app.unregisterUser export const app = { registerUser: functionA, unregisterUser: functionB sub: { dbtrigger: functionC // } }; firebase deploy --only functions:app.sub firebase deploy --only functions
  • 6. export const app = { realtimeDatabaseTrigger, firestoreTrigger, batchTrigger, endpoints };
  • 7. "deploy:dev": "firebase use default && faenv .env.default && cross-env NODE_ENV=development firebase deploy --only functions:app", "functions": { "source": "dist/functions", "predeploy": [ "echo $NODE_ENV", "rm -fr dist", "npm run lint", "npm run build", "cpx "{package.json,yarn.lock,.npmrc}" dist/functions" ] }, https://github.com/MOCHI-inc-JAPAN/firebase-auto-env faenv: firebase functions:config:set .env npm
  • 8.
  • 9.
  • 10. https://gist.github.com/tkow/e7db698f11d5dd61f3f2a6a5d7a48fec type CloudFunctionsInterface< CloudFunctionDefinitions extends { [key: string]: (arg?: any) => any; } > = { [key in keyof CloudFunctionDefinitions]: { func: CloudFunctionDefinitions[key]; interface: { args: Parameters<CloudFunctionDefinitions[key]>[0]; result: ReturnType<CloudFunctionDefinitions[key]>; }; }; }; type User = { user: { name: string } }; type AppCloudFunctions = CloudFunctionsInterface<{ 'sample-updateUserProfile': (args: User) => User; }>;
  • 11. https://gist.github.com/tkow/e7db698f11d5dd61f3f2a6a5d7a48fec // list functions api const callableFunctions = { updateUserProfile: 'sample-updateUserProfile' } as const; httpsCallable<Key extends keyof AppCloudFunctions>( name: Key ): HttpsCallable< AppCloudFunctions[Key]['interface']['args'], AppCloudFunctions[Key]['interface']['result'] >
  • 12. commander.command('backupAlgoliaIndexSetting <indexes...>').action(async (args) => { const results = await algoliaManager.getIndexSetting(args) if(results && Array.isArray(results)) { const promises = await Promise.all(results.map( async (setting,index) => new Promise((resolve,reject)=>{ const _path = path.join(process.cwd(),'algolia','indexes',`${args[index]}.json`) fs.writeFile( _path, JSON.stringify(setting,null,2), (err) => { if(err) return reject(err.message) console.log(`${args[index]}: are written to ${_path}`) return resolve('success') } ) }) )) console.log(promises) } process.exit() })
  • 13. commander.command('updateAlgoliaIndexSetting <indexes...>').action(async (args) => { const promises = await Promise.all(args.map( async (fileName,index) => { return new Promise( (resolve,reject)=>{ const _path = path.join(process.cwd(),'algolia','indexes',`${fileName}.json`) fs.readFile(_path,'utf8',async (err,_setting)=>{ if(err) return reject(err.message) const setting:IndexSettings = JSON.parse(_setting) const result = await algoliaManager.updateIndexSetting({ indexName: args[index] as string, setting }) console.log(setting) if(result) { resolve('success') } else { reject('index update failed') } }) }) })) console.log(promises) process.exit() })
  • 15. export const example = functions .runWith(runWithOptions) .https.onRequest((request, response) => { return nextjsServer.prepare().then(async () => { if (isDevFunction) { const expressServer = express() const { default: basicAuth } = await import('basic-auth-connect') const USERNAME = functions.config().example.basic_auth_user const PASSWORD = functions.config().example.basic_auth_password expressServer.use(basicAuth(USERNAME, PASSWORD)) expressServer.all('*', (req, res) => { return nextjsHandle(req, res) }) expressServer(request, response) } else { nextjsHandle(request, response) } }) })
  • 16. // Deny read/write access to all users under any conditions service cloud.firestore { match /databases/{database}/documents { function adminControl() { return request.auth.token.admin == true; } function isLogin() { return request.auth.uid != null; } match /sampleData/{logId} { allow read: if adminControl(); allow create: if isLogin(); allow update: if adminControl(); allow delete: if adminControl(); } } }
  • 17. function* saveUserProfile() { yield takeLatest(SAVE_PROFILE, function*({ payload: user }: Action<User>) { const currentUser = yield call(getCurrentUser); if (currentUser && currentUser.uid) { const profileDocument = getDocumentRef(`users/${currentUser.uid}`); user && profileDocument.set(UserNormalizr.denormalize(user)); } }); }
  • 18. const adminOrIdentityUser = ( dataId: string, context: functions.https.CallableContext ) => { return ( dataId === context.auth.uid || (context.auth && context.auth.token && context.auth.token.admin) ); };