Path-Check / safeplaces-ct-backend

Example backends for Safeplaces API specification

Home Page:https://covidsafepaths.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting up the DB: Error in migrate:up

SatadruBhattacharjee opened this issue · comments

While running the npm run migrate:up

getting this below error,

(node:68645) UnhandledPromiseRejectionWarning: Error: The migration directory is corrupt, the following files are missing: 20200420011122_organizations.js, 20200420011123_users.js, 20200428174152_trails.js, 20200501174613_publications.js

@SatadruBhattacharjee thanks for raising this. We're currently reworking our documentation and moving it to this repo - https://github.com/Path-Check/safeplaces-docs.

It looks like the error you've posted above is most likely related to database related environment variables not being set or not being accessible. Take a look at this bit of documentation https://github.com/Path-Check/safeplaces-docs/blob/master/safeplaces-backend-services/databases/schemas-and-migrations.md. Hopefully it'll unblock you.

Thanks @MarshallMcCoy for sharing the info. Eventually, I can able to setup the up and running frontend system along with the backend. The major hurdle was the Auth0 user creating and mapping part. I feel some pointer on that part was really helpful ( I can see some docs are now pointing to Auth0 part in https://github.com/Path-Check/safeplaces-docs ). While setting up the system, I faced issues on there below parts and has taken time to set them up.

  • AUTH0_REALM : How to set up this
  • Auth roles : how to set up the roles if required ?

Also, CORS issue was a big hurdle without setting up nginx. I have eventually used express cors middleware to solve this, but for this I need to touch the safeplaces-backend-lib files. Can I extend the middleware from the safeplaces-backend project ?

You can find info on the auth0 realms in https://auth0.com/docs/api-auth/tutorials/password-grant?_ga=2.189595234.833926368.1595256189-1363741231.1591637338#realm-support. The value of the AUTH0_REALM environment variable should be the name of the database connection you've setup for in Auth0.

For auth roles, you set these up in auth0. You'll need to support role values of contact_tracer and admin. Auth0 has documentation on setting up roles here https://auth0.com/docs/authorization/guides/manage-roles.

I'll be sure to update our docs to include information about the above. I appreciate you raising this.

As for CORS issues, we currently use nginx in our sample deployed environments. If for some reason you're not planning on doing so and want to use the express cors middleware library I would advise you to fork the safeplaces-backend-lib and extend it as needed on your fork.

@SatadruBhattacharjee If you run the application through the supplied docker container it has all the setup configs required to deploy nginx and handle CORS as well.
You can update the CORS snippet here by updating the following block to your domain of choice

set $cors 'true'; if ($http_origin ~ '^https?://(localhost|.*\.extremesolution\.com|.*\.safeplaces\.cloud)') { set $cors 'true'; }

I'm going to go ahead and close this issue due to inactivity. @SatadruBhattacharjee, please reopen a different issue or reach out on the PathCheck slack if you run into any other issues.