Skip to content

Commit

Permalink
Merge pull request #60 from 20tab/feature/964-expose-healthcheck-endp…
Browse files Browse the repository at this point in the history
…oint

TG-964 Expose healthcheck endpoint with rewrite path
  • Loading branch information
trottomv authored Jan 10, 2024
2 parents 804c03a + 0296d5a commit 37c27b8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions {{cookiecutter.project_dirname}}/cypress/e2e/Health/Health.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
context('Health check endpoint', () => {
describe('Service health endpoint', () => {
it('returns a 204 status', () => {
cy.request('/{{ cookiecutter.service_slug }}/health').then(response => {
expect(response.status).to.equal(204)
expect(response.body).to.be.empty
})
})
})
})
6 changes: 6 additions & 0 deletions {{cookiecutter.project_dirname}}/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const nextjsConfig = {
output: 'standalone',
reactStrictMode: true,
swcMinify: true,
rewrites: async () => [
{
source: '/{{ cookiecutter.service_slug }}/health',
destination: '/api/health'
},
]
}

// Sentry config. For all available options, see:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_dirname}}/pages/api/health.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from 'next'

export default function handler(_req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ status: 'ok' })
res.status(204).send('')
}

0 comments on commit 37c27b8

Please sign in to comment.