Tutorial
Closed this issue · 17 comments
Can someone provide a guide on how to run this? I added a new device in node-red-contrib-nora and I think the config for the service, but I can't test it.
If you scroll down on this page (https://github.com/andrei-tatar/node-red-contrib-nora) there's a more detailed description.
Hey Andrei, sorry I was in a hurry and I didn't make myself clear.
I am looking for a tutorial or a proper README on how to setup firebase and the "Nora service" to be used for local testing or to use my own firebase acc instead of yours.
I already made some changes in the nora red node (https://github.com/nicandris/node-red-contrib-nora/commit/bdc9b9b85b14a6ea275dcf9f72bf671206713ea5) so I need some kind of info on how to start the nora-service in order to do some testing and create a PR 😬 (sorry if it's obvious on how to run this, i'm not a node dev)
I supposedly did the changes to add the StartStop trait also at (https://github.com/nicandris/nora-service) but again I'm too much of a noob to test it! Any help appreciated.
How to configure Firebase?
- To get started, go to the Firebase website and log in with your Google account.
https://firebase.google.com/ - When you click the “Get started” button, a new page will appear. It will offer you “Add a project”. In addition, here you can see the “Project Example” to see how the data will be displayed.
- After you select “Add project”, a window will appear where you need to enter the name of the project and specify the country.
- In the next step, a page opens where you can add Firebase to your application.
Working with FirebaseDatabase:
let database = DatabaseProvider()
database.request(.getUser(id: "1")) { result in
switch result {
case .success(let response):
let snapshot = response.snapshot
case .failure(let error):
print(error.localizedDescription)
}
}
Database Response Decoding
Provide a JSON initializer for your custom types and easily convert the database response
let database = DatabaseProvider()
database.request(.getUser(id: "1")) { result in
switch result {
case .success(let response):
let user = try? response.mapTo(User.init)
case .failure(let error):
print(error.localizedDescription)
}
}
Working with FirebaseStorage
let storage = StorageProvider()
let avatarData = Data()
var meta = FIRStorageMetadata?
storage.request(.upload(avatarData, meta)) { result in
switch result {
case .success(_):
print("Upload Success!")
case .failure(let error):
print(error.localizedDescription)
}
}
Yes, it would be a nice if we could run an instance ourselves and test things locally. I know you can set up a local.config file but it takes a whole bunch of vars that need to be set, eg:
port , oauthClientId , oauthClientSecret ,jwtCookieName ,jwtSecret , projectId,googleProjectApiKey,postgressConnectionString,serviceAccountIssuer, serviceAccountPrivateKey,userAdminUid
and it is unclear to me what these values should be or where they can be obtained..
I managed to get it working on heroku, so i'll close this bug and when i have time probably write a README
It's a shame you closed this. Because, allthough you have got it working, it remains undocumented and unclear.
dont worry, i'll help writing the README after i finish adding the vacuum
Great, thanks!
@nicandris awesome. I did get stuck on the google API's part though.
it says
- Create a Project
- Enable HomeGraph API
- Under 'OAuth 2.0 Client IDs' click your webclient credentials
but this is where it runs off the track. :) there's nothing to click on there. It simply says 'No OAuth clients to display'. Any idea where to go from there ?
Did I maybe need to doe more for the HomeGraph API? Configure the oAuth consent screen maybe?
hmmmm... i'll create a fresh project tonight and check what step i missed
Also, there no API key to enter here:
PROJECT_API_KEY = api console - credentials - api keys - key
edit: Solved, I just had to create one, using '+ create credentials -> API key
👍
THAT'S IT, you are ready to deploy to Heroku! Build the app and the schema with npm run heroku-postbuild before deploying..
Also, this step leaves some stuff out I think, besides the (maybe obvious) 'npm install'..
I get a bunch of Cannot find module '../nora-common/models'.
errors...
edit: oh. those are apparently in a different repo. I guess a clone of this repo didnt clone those automatically... ah well.