Coder Social home page Coder Social logo

nestia-example's Introduction

nestia-example

picktogram-server

"디자이너를 위한 SNS 서비스" 라는 주제로 개발 진행 중

서버 실행

npm run start:local
# .env
DB_TYPE=
LOCAL_DB_HOST=
LOCAL_DB_PORT=
LOCAL_DB_USERNAME=
LOCAL_DB_DATABASE=
LOCAL_DB_PASSWORD=

TEST_DB_HOST=
TEST_DB_PORT=
TEST_DB_USERNAME=
TEST_DB_DATABASE=
TEST_DB_PASSWORD=
  • 다른 환경 설정 값들은 생략

테스트

npm run test:watch

Swagger 생성

npm run build
   # npm run prebuild  : rimraf dist
   # npm run build     : nest build
   # npm run postbuild : npx nestia swagger && npx nestia sdk
  • 빌드 시 swagger 문서 및 SDK 생성이 되도록 하기

SDK 배포 방법

npm run build
   # npm run prebuild  : rimraf dist
   # npm run build     : nest build
   # npm run postbuild : npx nestia swagger && npx nestia sdk

npm run publish # cd packages/api/lib && npm publish

확인할 사항

  1. npx nestia sdk 실행 후 packages 폴더 생성 ( 해당 프로젝트는 이미 생성 이후 )
  2. packages/api/lib/package.json 생성해둬야... ( npm publish 용 설정 파일 )

프론트에서의 SDK 사용

TypeScript로 작성된 서버는 프론트 개발자가 코드를 보고 해석하는 데에 전혀 문제가 없다.

# front side
npm i picktogram-server-apis
import * as Apis from 'picktogram-server-apis/api/functional';

try {
  const connection = {
    host: SERVER_URL,
    headers: {
      Authorization: token,
      'Content-Type': 'application/json',
    },
  };

  // /api/v1/articles/reports 경로의 report()
  // 메서드의 이름은 백엔드 개발자가 컨트롤러에서 지정한 이름과 동일
  const response = await Apis.api.v1.articles.reports.report(connection, articleId, {
    reason: '불쾌한 언행으로 인한 신고',
  });
  return response.data;
} catch (err) {
  throw err;
}

Nestia SDK 연동 (~ing)

nestia-example's People

Contributors

kakasoo avatar windofwind avatar smilejakdu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.