andrei-tatar / nora-service

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

nora-service

NORA (https://node-red-google-home.herokuapp.com) backend service deployed in Heroku.

Deployment instructions: (small guide on how to run nora-service on your own Heroku)

Needed:

HEROKU

FIREBASE

Google Api Console

Google Actions

CONFIG HEROKU ENV VARS

In Heroku go to Settings - Config Vars and add

env vars

JWT_COOKIE = nora:auth
JWT_SECRET = downloaded service account json from firebase - private_key
OAUTH_ID = api console - credentials - oauth 2.0 client ids - web client - Client ID
OAUTH_SECRET = api console - credentials - oauth 2.0 client ids - web client - Client secret
PROJECT_ID = firebase - settings -general - your apps - project id
SERVICE_ACCOUNT_ISSUER =  downloaded service account json from firebase - client_email
SERVICE_ACCOUNT_KEY =  downloaded service account json from firebase - private_key (format it as multiline)
FIREBASE_APIKEY = firebase - settings -general - your apps
FIREBASE_AUTHDOMAIN = firebase - settings -general - your apps

USER.REPOSITORY.TS

Modify src/services/user.repository.ts

To create the Database Tables modify this lines:

(async function () {
    const service = new PostgressService();
    await service.query(`
        CREATE TABLE IF NOT EXISTS appuser (
            uid VARCHAR(30) CONSTRAINT pk PRIMARY KEY,
            linked boolean DEFAULT false
        )`
    );

    await service.query('ALTER TABLE appuser ADD COLUMN IF NOT EXISTS noderedversion integer DEFAULT 1');
    await service.query('ALTER TABLE appuser ADD COLUMN IF NOT EXISTS refreshtoken integer DEFAULT 1');
})().catch(err => {
    console.error(err);
}).then(() => {
    console.log('done');
});

PUSH

THAT'S IT, you are ready to deploy to Heroku! Build the app and the schema with npm run heroku-postbuild before deploying. To deploy follow the instructions from the Heroku website or if you linked your account in Heroku with Github just push to github.

README DISCLAIMER

The instructions might be incomplete. For issues with the instructions please create an issue and we'll take another look,