andrei-tatar / nora-service

NORA backend service
https://node-red-google-home.herokuapp.com
34 stars 30 forks source link

Tutorial #16

Closed nicandris closed 4 years ago

nicandris commented 4 years ago

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.

andrei-tatar commented 4 years ago

If you scroll down on this page (https://github.com/andrei-tatar/node-red-contrib-nora) there's a more detailed description.

nicandris commented 4 years ago

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.

Atnagulova commented 4 years ago

How to configure Firebase?

  1. To get started, go to the Firebase website and log in with your Google account. https://firebase.google.com/
  2. 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.
  3. After you select “Add project”, a window will appear where you need to enter the name of the project and specify the country.
  4. In the next step, a page opens where you can add Firebase to your application.
Atnagulova commented 4 years ago

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

Atnagulova commented 4 years ago

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

Atnagulova commented 4 years ago

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

realjax commented 4 years ago

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..

nicandris commented 4 years ago

I managed to get it working on heroku, so i'll close this bug and when i have time probably write a README

realjax commented 4 years ago

It's a shame you closed this. Because, allthough you have got it working, it remains undocumented and unclear.

nicandris commented 4 years ago

dont worry, i'll help writing the README after i finish adding the vacuum

nicandris commented 4 years ago

@realjax as promised. https://github.com/andrei-tatar/nora-service/pull/19/files?short_path=04c6e90#diff-04c6e90faac2675aa89e2176d2eec7d8

realjax commented 4 years ago

Great, thanks!

realjax commented 4 years ago

@nicandris awesome. I did get stuck on the google API's part though. it says

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?

nicandris commented 4 years ago

hmmmm... i'll create a fresh project tonight and check what step i missed

realjax commented 4 years ago

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

👍

realjax commented 4 years ago

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.

realjax commented 4 years ago

Well, stuck again. :)

I got it all deployed at heroku bu cant login to the app, it says Screenshot 2020-04-28 at 12 11 09

I added it to firebase of course as per the instructions,

Screenshot 2020-04-28 at 13 23 10

but it still doesnt work. Any idea's ?

edit: moved this to https://github.com/andrei-tatar/nora-service/issues/21