Skip to content

Nest.js Integration

If you currently have a nest.js project, you can easily migrate from nest.js to unioc.

WARNING

Currently, the nest.js adapter for unioc is still in the experimental stage and only supports basic Restful API functionality. We will continue to improve other features in the coming time.

Installation

bash
pnpm i unioc

Usage

Change your bootstrap code to the following:

ts
import 
process
from 'node:process'
import {
NestJS
} from 'unioc/adapter-nestjs'
import {
ExpressApp
} from 'unioc/web-express'
import {
AppModule
} from './app.module'
async function
bootstrap
() {
// Create an Express application const
app
= await new
ExpressApp
()
// Use NestJS adapter and import your main module
app
.
use
(
NestJS
, {
imports
: [
AppModule
],
} satisfies NestJS.
Options
)
// Run the application await
app
.
run
(
process
.
env
.
PORT
|| 3616)
}
bootstrap
()

Currently, nest.js has not adapted plugins like @nestjs/swagger that are directly adapted by modifying the bootstrap. A unified swagger plugin will be planned in the future.

Contributors

Changelog