nestjs / nestjs.com

The official website https://nestjs.com 🏆
https://nestjs.com
MIT License
137 stars 23 forks source link

Codesandbox example does not use the AppService #3

Closed BrunnerLivio closed 5 years ago

BrunnerLivio commented 5 years ago

The Codesandbox.io example on the start page is kinda questionable. The app.controller.ts does inject the AppService, but does not call anything from it, making it unneeded.

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  render(@Res() res: Response) {
    res.sendFile(`index.html`, { root: __dirname + '/..' });
  }
}

I understand that you probably want to render the index.html so it looks more appealing. But maybe we should consider an example which actually uses a service, so the user better understands the benefits of NestJS? Maybe the app service returns a static array of benefits of NestJS which then get rendered by the index.html?

kamilmysliwiec commented 5 years ago

I understand that you probably want to render the index.html so it looks more appealing

Exactly.

Maybe the app service returns a static array of benefits of NestJS which then get rendered by the index.html?

In this case, we would have to add some template engine whereas I tried to keep this sample as simple as possible Any ideas what could we do instead? I agree that it definitely doesn't show nest benefits.

BrunnerLivio commented 5 years ago

I tried to keep this sample as simple as possible

That does totally make sense. Unfortunately to me it seems like there is no other good way other than using a template rendering engine.. Maybe adding this to the example would not be too bad of an idea, because as a newcomer you can directly see that NestJS is using express as underlying HTTP client. Seeing that you can easily modify the express instance was also one of the points which made me jump onto NestJS back then :)

kamilmysliwiec commented 5 years ago

I updated the example. Would you mind to take a look? :)

BrunnerLivio commented 5 years ago

Looking real good, clean, simple and usable.

One teeny tiny thing; seems like an uneeded import slipped in main.ts: import { join } from 'path'; :)

kamilmysliwiec commented 5 years ago

Fixed!