본문 바로가기

'o'

[nestjs] + azure + swagger + mariadb

 

 

#nomad

https://nomadcoders.co/nestjs-fundamentals/lobby

 

 

https://trilon.io/blog/deploy-nestjs-azure-functions

 

 

Deploy NestJS Serverless Apps to Azure Functions

Learn about the new NestJS Schematics and how to setup & deploy NestJS Serverless apps to Azure Functions in a few minutes!

trilon.io

 

 

$ npm i -g @nestjs/cli

$ nest new nest-azure-function

 

$ cd .\nest-azure-function\

$ nest add @nestjs/azure-func-http

 

$ func --version

 

$ npm run build
$ func host start

 

 

 

//swagger

https://docs.nestjs.com/openapi/introduction

$ npm install --save @nestjs/swagger swagger-ui-express

 

 

#main.azure.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { INestApplication } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
 
export async function createApp(): Promise<INestApplication> {
  const app = await NestFactory.create(AppModule);
  app.setGlobalPrefix('api');
 
  const options = new DocumentBuilder().build();
  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api/docs', app, document);
 
  await app.init();
  return app;
}
 
cs

 

 

#main.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
 
async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  const config = new DocumentBuilder()
      .setTitle('Payment')
      .setDescription('The payment API description')
      .setVersion('1.0')
      .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document);
 
  await app.listen(3000);
}
bootstrap();
 
cs

 

//Swagger 작성 

https://jhyeok.com/nestjs-swagger/

 

 

//azure + swagger

https://docs.microsoft.com/en-us/azure/connectors/connectors-native-http-swagger#add-an-http--swagger-trigger

 

//localhost + swagger test

// * main.ts > port & setup 확인 

$ npm run start

>> http://localhost:3000/api/

 

 

----------------------------------- add -----------------------------------

//sequelize

$ npm add @nestjs/sequelize mysql2 sequelize sequelize-typescript @types/sequelize

 

https://velog.io/@kwonh/Nest-Nest-%EC%8B%9C%EC%9E%91%ED%95%98%EA%B8%B0-2-DB%EC%97%B0%EA%B2%B0-mysql-sequelize

 

 

 

----------------------------------- add -----------------------------------

//typeorm

$ npm install --save @nestjs/typeorm typeorm mariadb

https://www.inflearn.com/course/%EB%94%B0%EB%9D%BC%ED%95%98%EB%8A%94-%EB%84%A4%EC%8A%A4%ED%8A%B8-%EC%A0%9C%EC%9D%B4%EC%97%90%EC%8A%A4/lecture/87235?tab=curriculum 

 

따라하며 배우는 NestJS - 인프런 | 학습 페이지

지식을 나누면 반드시 나에게 돌아옵니다. 인프런을 통해 나의 지식에 가치를 부여하세요....

www.inflearn.com

 

 

#folder

 

 

# configs/typeorm.config.ts

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import {TypeOrmModuleOptions} from "@nestjs/typeorm";
 
export const typeORMConfig : TypeOrmModuleOptions = {
    type: 'mariadb',
    host: 'localhost',
    port: 3306,
    username: 'root',
    password: 'root',
    database: 'root',
    entities: [__dirname + '/../**/*.entity.{js,ts}'],
    synchronize: false,
    autoLoadEntities: true
}
 
cs

 

--------- DTO --------- 

#ValidationPipe

$ npm i --save class-validator class-transformer

- https://docs.nestjs.kr/techniques/validation

 

- https://kyounghwan01.github.io/blog/etc/nest/validation-dto/#%E1%84%91%E1%85%B3%E1%84%85%E1%85%A9%E1%84%8C%E1%85%A6%E1%86%A8%E1%84%90%E1%85%B3-%E1%84%80%E1%85%AE%E1%84%8C%E1%85%A9

 

 

 

 

 

 

 

 

 

 

 

 

''o'' 카테고리의 다른 글

[크롬] 크롬 개발자도구 붙여놓기 오류  (0) 2024.02.06
[rust] windows10 ERROR  (0) 2021.11.15
[MailU]  (0) 2021.10.08
[Vue] tsc && vue-cli-service --build Error 오류  (0) 2021.10.08
[Vue] vuejs-daum-postcode 다음 주소 검색 modal  (0) 2021.09.27