All Projects → asyncapi → nodejs-template

asyncapi / nodejs-template

Licence: other
Node.js template for the AsyncAPI Generator

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to nodejs-template

nestjs-asyncapi
Async API module for Nestjs that provides documentation generation using your existing code (similar to Nestjs swagger module)
Stars: ✭ 22 (+15.79%)
Mutual labels:  asyncapi
wsapix
Next generation Websocket framework for nodejs
Stars: ✭ 17 (-10.53%)
Mutual labels:  asyncapi
python-paho-template
Python Paho template for the AsyncAPI generator
Stars: ✭ 17 (-10.53%)
Mutual labels:  asyncapi
event-gateway
AsyncAPI Event Gateway
Stars: ✭ 35 (+84.21%)
Mutual labels:  asyncapi
html-template
HTML template for AsyncAPI Generator
Stars: ✭ 38 (+100%)
Mutual labels:  asyncapi
java-spring-cloud-stream-template
Java Spring Cloud Stream template for the AsyncAPI Generator
Stars: ✭ 26 (+36.84%)
Mutual labels:  asyncapi
jasyncapi
/jay-sync-api/ is a Java code-first tool for AsyncAPI specification
Stars: ✭ 29 (+52.63%)
Mutual labels:  asyncapi
asynction
SocketIO python framework driven by the AsyncAPI specification. Built on top of Flask-SocketIO. Inspired by Connexion.
Stars: ✭ 40 (+110.53%)
Mutual labels:  asyncapi
openapi-filter
Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger/AsyncAPI definitions
Stars: ✭ 112 (+489.47%)
Mutual labels:  asyncapi
nestjs-asyncapi
NestJS AsyncAPI module - generate the documentation of your event-based services using decorators
Stars: ✭ 88 (+363.16%)
Mutual labels:  asyncapi
parser-go
It parses AsyncAPI documents.
Stars: ✭ 43 (+126.32%)
Mutual labels:  asyncapi
converter-go
Convert AsyncAPI documents from older to newer versions with Golang
Stars: ✭ 17 (-10.53%)
Mutual labels:  asyncapi
java-spring-template
Java Spring template for the AsyncAPI Generator
Stars: ✭ 41 (+115.79%)
Mutual labels:  asyncapi
go-watermill-template
Go template for the AsyncAPI Generator using Watermill module
Stars: ✭ 38 (+100%)
Mutual labels:  asyncapi
Spec
The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
Stars: ✭ 1,860 (+9689.47%)
Mutual labels:  asyncapi
modelina
Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents.
Stars: ✭ 55 (+189.47%)
Mutual labels:  asyncapi
home
This is the home page for the API specification toolbox.
Stars: ✭ 16 (-15.79%)
Mutual labels:  asyncapi
boats
Beautiful Open Api Template System
Stars: ✭ 28 (+47.37%)
Mutual labels:  asyncapi

AsyncAPI logo

npm npm

Overview

This template generates a Node.js application with any of the supported protocols endpoint, based on Hermesjs.

Other files are for the setup of developer environment, like .editorconfig or .eslint.

Technical requirements

Specification requirements

Property name Reason Fallback Default
operationId Operation ID must be set for every operation to generate proper functions as there is no fallback in place - -

Supported protocols

How to use the template

This template must be used with the AsyncAPI Generator. You can find all available options here.

In case you use X509 security and need to provide certificates, either place them in the root of the generated server with the following names: ca.pem, service.cert, service.key. You can provide a custom directory where cert files are located using certFilesDir parameter like -p certFilesDir=../not/in/my/app/dir.

Since you can have multiple different security schemes, to use the one of X509 type, you need to pass the name of the scheme like this: -p securityScheme=SCHEME_NAME.

You can find a complete tutorial on AsyncAPI Generator using this template here.

CLI

# Install the AsyncAPI Generator
$ npm install -g @asyncapi/generator

# Run generation
# To use the template
$ ag https://bit.ly/asyncapi @asyncapi/nodejs-template -o output -p server=production

# OR

# To test your local changes
$ ag https://bit.ly/asyncapi ./ -o output -p server=production

##
## Start the server 
##

# Go to the generated server
$ cd output

# Build generated application
$ npm i

# Start server
# To enable production settings start the server with "NODE_ENV=production npm start"
$ npm start

##
## Start the client 
##

#for testing your server you can use mqtt client. open a new terminal and install it using:
$ npm install mqtt -g

#publish an invalid message.
$ mqtt pub -t 'smartylighting/streetlights/1/0/event/123/lighting/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": "3", "sentAt": "2017-06-07T12:34:32.000Z"}'

#publish a valid message
$ mqtt pub -t 'smartylighting/streetlights/1/0/event/123/lighting/measured' -h 'test.mosquitto.org' -m '{"id": 1, "lumens": 3, "sentAt": "2017-06-07T12:34:32.000Z"}'

#You should see the sent message in the logs of the previously started server.
#Notice that the server automatically validates incoming messages and logs out validation errors

Template configuration

You can configure this template by passing different parameters in the Generator CLI: -p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE

Name Description Required Example
server The server you want to use in the code. Yes production
securityScheme Name of the security scheme. Only scheme with X509 and Kafka protocol is supported for now. No 'mySchemeName'
certFilesDir Directory where application certificates are located. This parameter is needed when you use X509 security scheme and your cert files are not located in the root of your application. No ../not/in/my/app/dir

Development

The most straightforward command to use this template is:

$ ag https://bit.ly/asyncapi @asyncapi/nodejs-template -o output -p server=production

Setup locally

# Run following commands in terminal:
$ git clone https://github.com/{username}/nodejs-template
$ cd nodejs-template
$ npm install
$ ag https://bit.ly/asyncapi ./ -o output -p server=production

For local development, you need different variations of this command. First of all, you need to know about three important CLI flags:

  • --debug enables the debug mode in Nunjucks engine what makes filters debugging simpler.
  • --watch-template enables a watcher of changes that you make in the template. It regenerates your template whenever it detects a change.
  • --install enforces reinstallation of the template.

There are two ways you can work on template development:

  • Use global Generator and template from your local sources:
    # assumption is that you run this command from the root of your template
    $ ag https://bit.ly/asyncapi ./ -o output -p server=production
  • Use Generator from sources and template also from local sources. This approach enables more debugging options with awesome console.log in the Generator sources or even the Parser located in node_modules of the Generator:
    # assumption is that you run this command from the root of your template
    # assumption is that generator sources are cloned on the same level as the template
    $ ../generator/cli.js https://bit.ly/asyncapi ./ -o output -p server=production

Contributors

Thanks goes to these wonderful people (emoji key):


Fran Méndez

💻 🤔

Lukasz Gornicki

🚇 💻

Khuda Dad Nomani

📖 💻

Samriddhi

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].