lipp / login-with

Stateless login-with microservice for OAuth
https://login-with.com
MIT License
2.33k stars 144 forks source link

Ability to be required as an npm module #27

Closed jcguarinpenaranda closed 7 years ago

jcguarinpenaranda commented 7 years ago

Hello,

I am interested on using login-with with a server that already exists and uses express. I saw you had all your initialization code on server.js file. So, i copy-pasted that code to index.js and exported the app using express.Router().

Now running the file server.js lifts up the server, and the index.js file exports the app, that then can be required as an npm module by other people that would like to import login-with to their existing express server. To allow this, I also created the "main" key in the package.json, pointing it to "index.js". This will ensure people will be able tu run:

const LoginApp = require('login-with'); // or the package name you would like to use

Finally, as I use Heroku (and they provide the port as an env variable), I updated opts.js file to allow using process.env.PORT when available, using as a fallback the strategy you already implemented.

coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 99.091% when pulling c3feb7d4de545816b45e69e776c9e2921efe1c42 on owsas:master into 57a1cec66a7b3b270ac6fbc1fe7d692e55e64e4d on lipp:master.

lipp commented 7 years ago

💯 THX!