From da7af92dcbbae9444ce9daf3fd278212d9cea4c7 Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Wed, 9 Aug 2023 03:17:29 +0530 Subject: initial commit with sample post url --- src/app.controller.spec.ts | 22 ++++++++++++++++++++++ src/app.controller.ts | 20 ++++++++++++++++++++ src/app.module.ts | 10 ++++++++++ src/app.service.ts | 12 ++++++++++++ src/main.ts | 8 ++++++++ src/tester.ts | 0 6 files changed, 72 insertions(+) create mode 100644 src/app.controller.spec.ts create mode 100644 src/app.controller.ts create mode 100644 src/app.module.ts create mode 100644 src/app.service.ts create mode 100644 src/main.ts create mode 100644 src/tester.ts (limited to 'src') diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts new file mode 100644 index 0000000..d22f389 --- /dev/null +++ b/src/app.controller.spec.ts @@ -0,0 +1,22 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; + +describe('AppController', () => { + let appController: AppController; + + beforeEach(async () => { + const app: TestingModule = await Test.createTestingModule({ + controllers: [AppController], + providers: [AppService], + }).compile(); + + appController = app.get(AppController); + }); + + describe('root', () => { + it('should return "Hello World!"', () => { + expect(appController.getHello()).toBe('Hello World!'); + }); + }); +}); diff --git a/src/app.controller.ts b/src/app.controller.ts new file mode 100644 index 0000000..3e9bcca --- /dev/null +++ b/src/app.controller.ts @@ -0,0 +1,20 @@ +import { Body, Controller, Get, Post } from '@nestjs/common'; +import { AppService } from './app.service'; + +@Controller() +export class AppController { + constructor(private readonly appService: AppService) {} + + @Get() + getHello(): Object { + return this.appService.getHello(); + } + + @Post() + saveJournalData(@Body() journalData: any) { + console.log("JOURNAL DATA", journalData); + return { + success: "ok" + } + } +} diff --git a/src/app.module.ts b/src/app.module.ts new file mode 100644 index 0000000..8662803 --- /dev/null +++ b/src/app.module.ts @@ -0,0 +1,10 @@ +import { Module } from '@nestjs/common'; +import { AppController } from './app.controller'; +import { AppService } from './app.service'; + +@Module({ + imports: [], + controllers: [AppController], + providers: [AppService], +}) +export class AppModule {} diff --git a/src/app.service.ts b/src/app.service.ts new file mode 100644 index 0000000..5d566ee --- /dev/null +++ b/src/app.service.ts @@ -0,0 +1,12 @@ +import { Injectable } from '@nestjs/common'; +import { warn } from 'console'; + +@Injectable() +export class AppService { + getHello(): Object { + return { + id: 10, + text: "Hello This is a TEXT" + }; + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..13cad38 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,8 @@ +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; + +async function bootstrap() { + const app = await NestFactory.create(AppModule); + await app.listen(3000); +} +bootstrap(); diff --git a/src/tester.ts b/src/tester.ts new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3