diff --git a/.gitignore b/.gitignore index 7e49769..0bece5c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ *.p12 # don't commit firestore certs (which usually follow this pattern) nos-notification-service-*.json +.direnv diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7ae4bf4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1704648272, + "narHash": "sha256-zCDhWGl3bVpBKpDZ0p3NuGksZVg69BAChsY5W4KARL4=", + "owner": "numtide", + "repo": "devshell", + "rev": "f54745fd4aae92443817ddc566ce06572b178b5a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1704538339, + "narHash": "sha256-1734d3mQuux9ySvwf6axRWZRBhtcZA9Q8eftD6EZg6U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "46ae0210ce163b3cba6c7da08840c1d63de9c701", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f2fbc24 --- /dev/null +++ b/flake.nix @@ -0,0 +1,53 @@ +{ + description = "Flake for developing on nos-notification-service"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + devshell.url = "github:numtide/devshell"; + }; + + outputs = { self, nixpkgs, flake-utils, devshell }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { + inherit system; + overlays = [ + devshell.overlays.default + ]; + }; + in + { + devShells.default = + pkgs.devshell.mkShell { + name = "nos-notification-service"; + packages = with pkgs; [ + go + gopls + golangci-lint + gotools + go-tools + gosimports + ]; + commands = [ + { + name = ''start''; + help = ''alias for `go run cmd/notification-service/main.go`''; + category = ''dev helpers''; + command = '' + go run cmd/notification-service/main.go + ''; + } + { + name = ''lint''; + help = ''check style and formatting''; + category = ''dev helpers''; + command = '' + go vet ./... + golangci-lint run ./... + ''; + } + + ]; + }; + }); +} \ No newline at end of file diff --git a/service/ports/http/http.go b/service/ports/http/http.go index 6d96e09..01c73c0 100644 --- a/service/ports/http/http.go +++ b/service/ports/http/http.go @@ -57,6 +57,9 @@ func (s *Server) createMux(ctx context.Context) *http.ServeMux { mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { s.serveWs(ctx, w, r) }) + mux.HandleFunc("/_health", func(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "ok\n") + }) return mux }