Skip to content

Commit

Permalink
Support preview mode on the root API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jits committed Oct 27, 2020
1 parent a6cdab5 commit ee43c26
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { Controller, Get, HttpCode, Inject } from '@nestjs/common';
import { Controller, Get, Inject, UseGuards } from '@nestjs/common';
import StoryblokClient from 'storyblok-js-client';
import { PreviewMode } from './preview-mode/preview-mode.decorator';
import { PreviewModeGuard } from './preview-mode/preview-mode.guard';
import { STORYBLOK_CLIENT } from './storyblok/storyblok-factory';

@Controller()
export class AppController {
constructor(@Inject(STORYBLOK_CLIENT) private storyblok: StoryblokClient) {}

@Get('/')
@HttpCode(204)
root(): void {
@UseGuards(PreviewModeGuard)
root(@PreviewMode() previewMode: boolean): any {
// Root level API endpoint that we can use for things like uptime checks
if (previewMode) {
return { previewMode };
} else {
return {};
}
}

@Get('flush_cache')
Expand Down

0 comments on commit ee43c26

Please sign in to comment.