danneu/koa-skeleton

Improve doc/setup

jscari opened this issue · 6 comments

Hi,

Thanks for the boilerplate.

Two things are missing in the README, it is kind of obvious when you know it but the app returns an error 500 without them :

  1. Add to the .env file (the template do not render without those two variables)
RECAPTCHA_SITEKEY=''
RECAPTCHA_SITESECRET=''
  1. Init the db
npm run reset-db

Thanks, I definitely need to add these to the README.

I should also improve the project so that the Recaptcha is gracefully turned off if those env vars are missing.

Made some progress on the README: 94e5638

Another thing I'd like to fix is that the current npm tasks fail if you have no .env:

"start-dev": "env $(cat .env | xargs) nodemon --ext js,html ./src/index.js",
"reset-db": "env $(cat .env | xargs) node ./sql/reset_db.js"

I've never used it, but I think I should use something like https://www.npmjs.com/package/config to setup environment vars, especially in development.

Actually, I am on Windows and npn start-dev doesn't work.

The fix was easy, just add in index.js
require('dotenv').config();

https://www.npmjs.com/package/dotenv

Just pushed some code improvements that handle missing RECAPTCHA_SITEKEY.

Thanks, I'll look at the dotenv package right now. My xargs/.env stuff is a hack that I'm eager to replace.

That was simple: 550f5a8

Switched to that dotenv module.

npm run reset-db and npm run start-dev should now work on Windows or if you're missing a .env file altogether.

Should be all resolved now