Skip to content

TypeScript + Openapi + Typeorm + NestJS API Server

Notifications You must be signed in to change notification settings

VirgoHxy/nest-api

Repository files navigation

Nest Logo

A progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License NPM Downloads CircleCI Coverage Discord Backers on Open Collective Sponsors on Open Collective Support us

Description

Nest framework TypeScript starter repository.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Build the application

npm run build

Open dist folder in your file system to check output.

Build the api by openapi-axios

npm run build:sdk
// 测试api用例
import { Configuration, PingApi } from './sdk';

// 这个config是公共的 作用于所有api
const config = new Configuration({
  basePath: 'http://localhost:3000',
});

class Test {
  static instance = new Test();

  constructor(private pingApi: PingApi = new PingApi(config)) {
    this.init();
  }

  async init() {
    try {
      const result = await this.pingApi.pingControllerPing();
      console.log(result.data);
    } catch (error) {
      console.log(error.message);
    }
  }
}

Generate/Run/Revert the migrations

generate

npm run migrate:g

run

npm run migrate:s

revert

npm run migrate:r

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Nest-cli

# 查看命令帮助
$ nest -h
# 生成语法格式
$ nest g [<type>] [<name>] [<path>]
# generate model
$ nest g mo [<name>]
# generate controller
$ nest g co [<name>]
# generate service
$ nest g s [<name>]

Support

Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.

Stay in touch

License

Nest is MIT licensed.

About

TypeScript + Openapi + Typeorm + NestJS API Server

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published