-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-Prettier fixes in tsx -Removed unused AppController and AppService -Moved Client App Logic to Main.ts -Created Contact List Module
- Loading branch information
1 parent
b886e83
commit 5e23030
Showing
19 changed files
with
112 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
import { ClientAppModule } from './client-app/client-app.module'; | ||
import { ContactListModule } from './contact-list/contact-list.module'; | ||
|
||
@Module({ | ||
imports: [ClientAppModule], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
imports: [ContactListModule], | ||
}) | ||
export class AppModule {} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { ContactListController } from './contact-list.controller'; | ||
|
||
describe('ContactListController', () => { | ||
let controller: ContactListController; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
controllers: [ContactListController], | ||
}).compile(); | ||
|
||
controller = module.get<ContactListController>(ContactListController); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(controller).toBeDefined(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Controller, Get } from '@nestjs/common'; | ||
import { ContactListService } from './contact-list.service'; | ||
|
||
@Controller('contact-list') | ||
export class ContactListController { | ||
constructor(private readonly contactListService: ContactListService) {} | ||
|
||
@Get() | ||
getContacts(): Array<any> { | ||
return this.contactListService.getContacts(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ContactListController } from './contact-list.controller'; | ||
import { ContactListService } from './contact-list.service'; | ||
|
||
@Module({ | ||
controllers: [ContactListController], | ||
providers: [ContactListService], | ||
}) | ||
export class ContactListModule {} |
10 changes: 5 additions & 5 deletions
10
...ver/client-app/client-app.service.spec.ts → ...contact-list/contact-list.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
|
||
@Injectable() | ||
export class ContactListService { | ||
getContacts(): Array<any> { | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import { ConfigService } from '@nestjs/config'; | ||
import { NestFactory } from '@nestjs/core'; | ||
import createServer from 'next/dist/server/next'; | ||
import { AppModule } from './app.module'; | ||
import { HttpExceptionFilter } from './next.filter'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
|
||
const configService = app.get<ConfigService>(ConfigService); | ||
const nextServer = createServer({ | ||
dev: configService.get<string>('NODE_ENV') !== 'production', | ||
dir: './src/client', | ||
}); | ||
await nextServer.prepare(); | ||
|
||
app.useGlobalFilters(new HttpExceptionFilter(nextServer)); | ||
await app.listen(3000); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ArgumentsHost, ExceptionFilter, HttpException } from '@nestjs/common'; | ||
import { NextServer } from 'next/dist/server/next'; | ||
|
||
export class HttpExceptionFilter implements ExceptionFilter { | ||
constructor(private nextServer: NextServer) {} | ||
|
||
public catch(exception: HttpException, host: ArgumentsHost) { | ||
const ctx = host.switchToHttp(); | ||
const response = ctx.getResponse(); | ||
const request = ctx.getRequest(); | ||
const status = exception.getStatus(); | ||
|
||
if (status === 404) { | ||
this.nextServer.getRequestHandler()(request, response); | ||
} else { | ||
response.status(status).json({ | ||
statusCode: status, | ||
timestamp: new Date().toISOString(), | ||
path: request.url, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters