SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadhamedmustafa094
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stageAbc194748
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network DevicesChandrakantDivate1
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxnuruddin69
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 

Dernier (20)

kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Air Compressor reciprocating single stage
Air Compressor reciprocating single stageAir Compressor reciprocating single stage
Air Compressor reciprocating single stage
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Computer Networks Basics of Network Devices
Computer Networks  Basics of Network DevicesComputer Networks  Basics of Network Devices
Computer Networks Basics of Network Devices
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Bridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptxBridge Jacking Design Sample Calculation.pptx
Bridge Jacking Design Sample Calculation.pptx
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 

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) ); };