diff options
author | Indrajith K L | 2023-08-09 03:17:29 +0530 |
---|---|---|
committer | Indrajith K L | 2023-08-09 03:17:29 +0530 |
commit | da7af92dcbbae9444ce9daf3fd278212d9cea4c7 (patch) | |
tree | 0c25dbd2c84e16d0f44844e94f70711e7770cb86 /src | |
download | Journlr Backend-master.tar.gz Journlr Backend-master.tar.bz2 Journlr Backend-master.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/app.controller.spec.ts | 22 | ||||
-rw-r--r-- | src/app.controller.ts | 20 | ||||
-rw-r--r-- | src/app.module.ts | 10 | ||||
-rw-r--r-- | src/app.service.ts | 12 | ||||
-rw-r--r-- | src/main.ts | 8 | ||||
-rw-r--r-- | src/tester.ts | 0 |
6 files changed, 72 insertions, 0 deletions
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>(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 --- /dev/null +++ b/src/tester.ts |