Skip to content

Commit

Permalink
add healthcheck endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
StarpTech committed Apr 24, 2021
1 parent 02f70e3 commit 53e9065
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ POST - `/schema/validate` Validate schema between provided and latest schemas.
</p>
</details>

### Monitoring

GET - `/health` healthcheck endpoint.

### Persisted Queries

GET - `/persisted_query?key=foo` Looks up persisted query from KV Storage.
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ import { getSchemaDiff } from './routes/get-schema-diff'
import { getSchemaValidation } from './routes/get-schema-validation'
import { registerSchema } from './routes/register-schema'
import { deletePersistedQuery } from './routes/delete-persisted-query'
import { healthcheck } from './routes/healthcheck'

const API = new Router()

API.add('GET', '/health', healthcheck)

// Federation
API.add('POST', '/schema/push', compose(basicAuth, registerSchema))
API.add('GET', '/schema/latest', compose(basicAuth, getComposedSchema))
Expand Down
11 changes: 11 additions & 0 deletions src/routes/healthcheck.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Handler } from 'worktop'

/**
* Healthcheck endpoint. Useful for monitoring.
*
* @param req
* @param res
*/
export const healthcheck: Handler = async function (req, res) {
res.send(200)
}

0 comments on commit 53e9065

Please sign in to comment.