Skip to content

Commit

Permalink
Add healthcheck in PHP back end of Storybook and handle new env var P…
Browse files Browse the repository at this point in the history
…S_APP_VERSION
  • Loading branch information
Quetzacoalt91 committed Nov 22, 2024
1 parent ac0fe21 commit fbe549b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions storybook/.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=6ca3f5a44d55f1407362700a7565930c
PS_APP_VERSION=dev
###< symfony/framework-bundle ###
1 change: 1 addition & 0 deletions storybook/config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
app.version: '%env(PS_APP_VERSION)%'

services:
_defaults:
Expand Down
20 changes: 20 additions & 0 deletions storybook/src/Controller/HealthCheckController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

class HealthCheckController extends AbstractController
{
#[Route('/healthcheck')]
public function index(): Response
{
return new JsonResponse([
'status' => 'ok',
'version' => $this->getParameter('app.version'),
]);
}
}

0 comments on commit fbe549b

Please sign in to comment.