Browse Source

add a system controller with the current timestamp

Sven Czarnian 2 years ago
parent
commit
b7f6b079c3
2 changed files with 34 additions and 0 deletions
  1. 18 0
      src/system/system.controller.spec.ts
  2. 16 0
      src/system/system.controller.ts

+ 18 - 0
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>(SystemController);
+  });
+
+  it('should be defined', () => {
+    expect(controller).toBeDefined();
+  });
+});

+ 16 - 0
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<number> {
+    return new Date().getTime();
+  }
+}