# @cyyjs/nest

> nestjs lib

Latest version **1.0.0-rc2** (published 2021-07-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cyyjs/nest
pnpm add @cyyjs/nest
yarn add @cyyjs/nest
bun add @cyyjs/nest
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc2 |
| Published | 2021-07-21 |
| First published | 2021-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | cyyjs |
| Maintainers | cyyjs |
| Keywords | nestjs, nest |

## Links

- npm: https://www.npmjs.com/package/@cyyjs/nest
- Repository: https://github.com/cyyjs/nest-lib
- Homepage: https://github.com/cyyjs/nest-lib#readme
- Issues: https://github.com/cyyjs/nest-lib/issues
- npm.io page: https://npm.io/package/@cyyjs/nest

## Dependencies (1)

- [passport-strategy](https://npm.io/package/passport-strategy.md) ^1.0.0

## Recent versions

- 1.0.0-rc2 (latest) — 2021-07-21
- 1.0.0-rc1 — 2021-07-21
- 1.0.0 — 2021-07-21

## README

## nestjs 封装库

### 封装内容

- [x] 异常过滤器
- [x] 返回拦截器、超时拦截器
- [x] swagger文档
- [x] 全局验证管道
- [x] auth授权

## 安装

```bash
yarn add @cyyjs/nest
```

## 使用

```ts
// main.ts

import { AppModule } from './app.module';
import { CNestFactory } from '@cyyjs/nest/core'

async function bootstrap() {
  const app = await CNestFactory.create(AppModule, {
    applicationOptions: {}, // NestApplicationOptions
    validationPipeOptions: {}, // ValidationPipeOptions
    swaggerOptions: {
      path: '/swagger',
      title: 'API'
      description: 'API'
      version: '1.0.0'
    },
    filters: {
      exception: true
    },
    interceptors: {
      result: true,
      timeout: {
        time: 5000
      }
    }
  });
  await app.listen(3000);
  console.log(`app start at http://localhost:${3000}`)
}
bootstrap();
```

`CNestFactory.create`的默认配置：

```json
{
  "filters": {
    "exception": true
  },
  "interceptors": {
    "result": true,
    "timeout": {
      "time": 5000
    }
  }
}
```

## auth

使用 jwt授权

```ts
import { AuthModule, RolesGuard } from '@cyyjs/nest/auth'
@Module({
  imports: [
    AuthModule.register({
      url: '' // 获取用户信息的url
    })
  ],
  controllers: [AppController],
  providers: [
    {
      provide: APP_GUARD,
      useClass: RolesGuard
    },
    AppService
  ],
})
export class AppModule {}
```

---
_Source: https://npm.io/package/@cyyjs/nest · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
