From b7f6b079c35d583006cce6a68a1858b7df2475c8 Mon Sep 17 00:00:00 2001 From: Sven Czarnian Date: Thu, 3 Nov 2022 23:33:17 +0100 Subject: [PATCH] add a system controller with the current timestamp --- src/system/system.controller.spec.ts | 18 ++++++++++++++++++ src/system/system.controller.ts | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/system/system.controller.spec.ts create mode 100644 src/system/system.controller.ts diff --git a/src/system/system.controller.spec.ts b/src/system/system.controller.spec.ts new file mode 100644 index 0000000..ddd02e9 --- /dev/null +++ b/src/system/system.controller.spec.ts @@ -0,0 +1,18 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { SystemController } from './system.controller'; + +describe('SystemController', () => { + let controller: SystemController; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + controllers: [SystemController], + }).compile(); + + controller = module.get(SystemController); + }); + + it('should be defined', () => { + expect(controller).toBeDefined(); + }); +}); diff --git a/src/system/system.controller.ts b/src/system/system.controller.ts new file mode 100644 index 0000000..577544c --- /dev/null +++ b/src/system/system.controller.ts @@ -0,0 +1,16 @@ +import { Controller, Get, UseGuards } from '@nestjs/common'; +import { ApiResponse } from '@nestjs/swagger'; +import { JwtGuard } from 'src/auth/guards/jwt.guard'; + +@Controller('system') +export class SystemController { + @UseGuards(JwtGuard) + @Get('/timestamp') + @ApiResponse({ + description: 'The current ZULU timestamp of the system', + type: String, + }) + async timestamp(): Promise { + return new Date().getTime(); + } +}