Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
nestjs-asyncapi
Advanced tools
Readme
Generate AsyncApi documentation (for event-based services, like websockets) in a similar to nestjs/swagger fashion.
full installation (with chromium)
$ npm i --save nestjs-asyncapi
nestjs-async api package doesn't require chromium (which is required by asyncapi lib), so u can skip chromium installation by setting PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true environment variable.
$ PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm i --save nestjs-asyncapi
Include AsyncApi initialization into your bootstrap function.
async function bootstrap() {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
const asyncApiOptions = new AsyncApiDocumentBuilder()
.setTitle('Feline')
.setDescription('Feline server description here')
.setVersion('1.0')
.setDefaultContentType('application/json')
.addSecurity('user-password', {type: 'userPassword'})
.addServer('feline-ws', {
url: 'ws://localhost:3000',
protocol: 'socket.io',
})
.build();
const asyncapiDocument = await AsyncApiModule.createDocument(app, asyncApiOptions);
await AsyncApiModule.setup(docRelPath, app, asyncapiDocument);
// other bootstrap procedures here
return app.listen(3000);
}
AsyncApi module explores Controllers
& WebSocketGateway
by default.
In most cases you won't need to add extra annotation,
but if you need to define asyncApi operations in a class that's not a controller or gateway use the AsyncApi
class
decorator.
Mark pub/sub methods via AsyncApiPub
or AsyncApiSub
decorators
class CreateFelineDto {
@ApiProperty()
demo: string;
}
@Controller()
class DemoController {
@AsyncApiPub({
channel: 'create/feline',
message: {
payload: CreateFelineDto
},
})
async createFeline() {
// logic here
}
@AsyncApiSub({
channel: 'create/feline',
message: {
payload: CreateFelineDto
},
})
async createFeline() {
// logic here
}
}
For more detailed examples please check out https://github.com/flamewow/nestjs-asyncapi/tree/main/sample sample app.
FAQs
NestJS AsyncAPI module - generate documentation of your event-based services using decorators
The npm package nestjs-asyncapi receives a total of 8,045 weekly downloads. As such, nestjs-asyncapi popularity was classified as popular.
We found that nestjs-asyncapi demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.