mozilla / csp-logger

Log all the CSP violations!
57 stars 10 forks source link

Add /healthz endpoint #10

Closed kpcyrd closed 7 years ago

kpcyrd commented 7 years ago

This adds a simple configurable /healthz endpoint that returns 200 if the server started successfully.

This is especially useful in cloud setups.

naugtur commented 7 years ago

Nice. And, what is the reasoning behind the z at the end of endpoint name?

kpcyrd commented 7 years ago

@naugtur to be honest, I'm not 100% sure where the z in /healthz is coming from, it appears to be a convention and I assume the original source is this video:

https://vimeo.com/173610242

It's also referenced on various docs and applications implementing this, but I couldn't find an official-ish website :)

I assume it's to avoid conflicts with actual routes in existing applications. If you want this to be called /health or something else instead I can do that easily :)

naugtur commented 7 years ago

I don't think /health is any better, just wanted to make sure it's not just because you watched hacker movies from the '90s lately :)

This library can work standalone or as a module to someone else's server. I need to make sure it'll work for all usecases, but the only alternative to /healthz I want us to consider is making it opt-in with endpoint name as an argument.

Friday is my opensource day, I'll have more time for this then. Hope you don't mind the wait.

kpcyrd commented 7 years ago

This library can work standalone or as a module to someone else's server. I need to make sure it'll work for all usecases, but the only alternative to /healthz I want us to consider is making it opt-in with endpoint name as an argument.

Ideally, my endpoint would be disabled if the csp-logger is included into an existing express application and enabled on the standalone version.

I'm going to look into how to do this until tomorrow.

Friday is my opensource day, I'll have more time for this then. Hope you don't mind the wait.

Works for me :) I'm also on mozilla irc.

kpcyrd commented 7 years ago

The /healthz endpoint defaults to disabled now and can be enabled using the config.json :)

It's also possible to change the route and I'm passing the config object to the healthCheck function.

naugtur commented 7 years ago

I read your updated version and it's perfect. Merging.

BTW. I don't like how complicated all this is, with configs and schemas and databases. Will have to do something about it one day...