NestJS + SSR

오픈소스·2023년 1월 8일
0

NestJS Boilerplate

목록 보기
12/16
post-thumbnail

https://docs.nestjs.com/#alternatives

$ git clone https://github.com/nestjs/typescript-starter.git project
$ cd project
$ npm install
$ npm run start:dev
$ git remote set-url origin https://github.com/youngkiu/nestjs-kakaologin.git
$ git branch -M main
$ git push -u origin main
$ npm install --save hbs

main.ts

  app.useStaticAssets(join(__dirname, '..', 'public'));
  app.setBaseViewsDir(join(__dirname, '..', 'views'));
  app.setViewEngine('hbs');

app.controllers.ts

  @Render('index') //index.hbs랑 연결
  root() {
    return {
      data: {
        title: 'Chattings',
        copyright: 'ryu jun yeol',
      },
    };
  }

index.hbs

<html>
  <head>
    <meta charset='utf-8' />
    <link href='css/styles.css' rel='stylesheet' />
    <title>{{data.title}}</title>
  </head>
  <body>
    <h1>Hello World!</h1>

    {{data.copyright}}
    <script src='js/scripts.js'></script>
  </body>
</html>

Ref)

0개의 댓글