実現させたい事
iosアプリでalgoliaを使用したいです。
実現のために、
youtube動画 Algolia Firestore QuickStart With Firebase Cloud Functionsをそのまま真似て作ったfirestoreのオブジェクトを、
algoliaで作成したindex(zoo search)にミラーリングしたいのですが、できないため困っています。
セットアップは、動画の5:50秒までを参考にしています。
確認できている事(やっている事)
< algolia設定済み >
・BrowseはNo records yetです。
・indicesのLogs内にPOST,DELETE,GETがあります。ここにCREATEは無いです。
onCreateはトリガーされていないという事だと思います。
(DELETEがあるのは何度かalgolia内のindexを削除して新規作成したり、xcodeでプロジェクトを作り直して新たにセットアップを何度も試みたからだと思います。)
< Firebase設定済み >
・Functionsのダッシュボードは 『最初のデプロイを待機しています』状態です。
ログはまだ無いです。
ダッシュボードのタブ内に、これらの履歴がないので動画のように正常にセットアップができおらず、この部分がどうしても分からず困っています。
やっていない事
Health Check: This lesson was last reviewed on May 31, 2018 and tested with these packages:
Angular v6
RxJS v6.2
firebase-functions v1
algoliasearch v3
リンク先のyoutube 動画では
ライブラリは上記の通りとリンク先にありますが、
私はAngularとRxJSはインストールしていません。
その他、とにかくリンク先のセットアップ手順のみに従って、そのまま真似ています。
試している事
ターミナルは以下の通り進めています。
//ターミナル Last login: Sun Dec 9 23:41:59 on ttys000 -bash: eval: line 21: syntax error: unexpected end of file hogeMacBook-Pro:~ hoge$ pwd /Users/hoge hogeMacBook-Pro:~ hoge$ ls Desktop Downloads Library Music Public Documents Dropbox Movies Pictures hogeMacBook-Pro:~ hoge$ mkdir apps hogeMacBook-Pro:~ hoge$ cd apps hogeMacBook-Pro:apps hoge$ mkdir lessons hogeMacBook-Pro:apps hoge$ cd lessons hogeMacBook-Pro:lessons hoge$ mkdir algolia hogeMacBook-Pro:lessons hoge$ cd algolia hogeMacBook-Pro:algolia hoge$ firebase init functions ######## #### ######## ######## ######## ### ###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ######## You're about to initialize a Firebase project in this directory: /Users/hoge/apps/lessons/algolia === Project Setup First, let's associate this project directory with a Firebase project. You can create multiple project aliases by running firebase use --add, but for now we'll just set up a default project. ? Select a default Firebase project for this directory: myproject (myproject) i Using project myproject (myproject) === Functions Setup A functions directory will be created in your project with a Node.js package pre-configured. Functions can be deployed with firebase deploy. ? What language would you like to use to write Cloud Functions? TypeScript ? Do you want to use TSLint to catch probable bugs and enforce style? Yes ✔ Wrote functions/package.json ✔ Wrote functions/tslint.json ✔ Wrote functions/tsconfig.json ✔ Wrote functions/src/index.ts ✔ Wrote functions/.gitignore ? Do you want to install dependencies with npm now? Yes > grpc@1.16.1 install /Users/hoge/apps/lessons/algolia/functions/node_modules/grpc > node-pre-gyp install --fallback-to-build --library=static_library node-pre-gyp WARN Using request for node-pre-gyp https download [grpc] Success: "/Users/hoge/apps/lessons/algolia/functions/node_modules/grpc/src/node/extension_binary/node-v59-darwin-x64-unknown/grpc_node.node" is installed via remote > protobufjs@6.8.8 postinstall /Users/hoge/apps/lessons/algolia/functions/node_modules/protobufjs > node scripts/postinstall > firebase-functions@2.1.0 postinstall /Users/hoge/apps/lessons/algolia/functions/node_modules/firebase-functions > node ./upgrade-warning ======== WARNING! ======== This upgrade of firebase-functions contains breaking changes if you are upgrading from a version below v1.0.0. To see a complete list of these breaking changes, please go to: https://firebase.google.com/docs/functions/beta-v1-diff npm notice created a lockfile as package-lock.json. You should commit this file. added 516 packages in 16.919s i Writing configuration info to firebase.json... i Writing project information to .firebaserc... i Writing gitignore file to .gitignore... ✔ Firebase initialization complete! hogeMacBook-Pro-Pro:algolia hoge$ cd functions hogeMacBook-Pro-Pro:functions hoge$ ls node_modules package.json tsconfig.json package-lock.json src tslint.json hogeMacBook-Pro:functions hoge$ npm i algoliasearch --save + algoliasearch@3.31.0 added 16 packages in 5.462s hogeMacBook-Pro-Pro:functions hoge$ firebase functions:config:set algolia.appid=“foobar” algolia.apikey=“hugahuga” ✔ Functions config updated. Please deploy your functions for the change to take effect by running firebase deploy --only functions hogeMacBook-Pro-Pro:functions hoge$ firebase deploy --only functions === Deploying to ‘myproject’… i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint > functions@ lint /Users/hoge/apps/lessons/algolia/functions > tslint --project tsconfig.json WARNING: /Users/hoge/apps/lessons/algolia/functions/src/index.ts[1, 1]: 'functions' is declared but its value is never read. Running command: npm --prefix "$RESOURCE_DIR" run build > functions@ build /Users/hoge/apps/lessons/algolia/functions > tsc ✔ functions: Finished running predeploy script. i functions: ensuring necessary APIs are enabled... ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading... ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/myproject/overview hogeMacBook-Pro-Pro:functions hoge$
firebase.jsonは以下の通り記述しています。
//firebase.json import * as functions from 'firebase-functions'; import * as admin from 'firebase-admin'; admin.initializeApp(); const env = functions.config(); import * as algoliasearch from 'algoliasearch'; // Initialize the Algolia Client const client = algoliasearch(env.algolia.appid, env.algolia.apikey); const index = client.initIndex('zoo_search'); exports.indexAnimal = functions.firestore .document('zoo/{animalId}') .onCreate((snap, context) => { const data = snap.data(); const objectID = snap.id; // Add the data to the algolia index return index.addObject({ objectID, ...data }); }); //デリート // exports.unindexAnimal = functions.firestore // .document('zoo/{animalId}') // .onDelete((snap, context) => { // const objectId = snap.id; // // Delete an ID from the index // return index.deleteObject(objectId); // });
本当に困っています。
ご教示願います。
回答1件
あなたの回答
tips
プレビュー