ourparentcenter / moleculer-template-project-ts-swagger

Project starter template for moleculer with swagger
MIT License
14 stars 3 forks source link

Moleculer template: project-ts-swagger

Features

Install

This project needs yarn due to an issue with npm resolving dependencies for prom client if using swagger stats. To install use the moleculer-cli tool.

$ moleculer init ourparentcenter/moleculer-template-project-ts-swagger#main my-project

Then be sure to update the .env file with the correct address to your transporter system if using one.

e.g.
TRANSPORTER=stan://stan:4222
to
TRANSPORTER=stan://localhost:4222

Prompts

$ moleculer init ourparentcenter/moleculer-template-project-ts moleculer-demo

Template repo: ourparentcenter/moleculer-template-project-ts-swagger
Downloading template...
? Give a description of your app:
? Add API Gateway (moleculer-web) service? Yes
? Add demo frontend project (Quasar)? Yes
? Use Swagger? Yes
? Use Swagger-Stats? Yes
? Use Swagger-Editor? Yes
? Would you like to communicate with other nodes? Yes
? Select a transporter NATS (recommended)
? Would you like to use cache? No
? Add DB sample service? Yes
? Would you like to enable metrics? Yes
? Select a reporter solution Prometheus
? Would you like to enable tracing? Yes
? Select a exporter solution Console
? Add Docker & Kubernetes sample files? Yes
? Use ESLint to lint your code? Yes
? Would you like to choose a file watcher? Yes
? Select a file watcher ts-node (recommended)

Create 'moleculertemplatetest' folder...
? Would you like to run 'npm install'? Yes **-- no if using swagger stats**

NPM scripts

swagger

Swagger has been updated to use the swagger initialize file in swagger-dist and openAPI 3.0.1 schema. This is a change from previous versions of swagger-dist where the html file was updated and held the js code for swagger initialize. Swagger editor has also been added for those who like swagger editor. You can use one or the other or both at the same time is supported.

frontend

The frontend is built with Quasar v2 and compiled into the public folder of api gateway. The frontend project directory is provided when selecting yes to adding frontend project. Quasar is an awesome vue framework that not only provide you with a frontend site, but can also compile to mobile app, SSR, PWA, BEX, Electron app, all from the same code base. See Quasar for more details

REPL in Docker

Docker images now have moleculer-repl added to them. To use, open docker cli of a container, like api container, and run the following command moleculer --ns {enter your namespace here}, e.g. moleculer --ns test-template2-docker. This will start a new broker serviece node and add it to your existing nodes so that you can use the repl commands in docker.

Current issues

If using swagger-stats, running npm install will fail due to swagger-stats dependency of prom-client, which is "prom-client": ">= 10 <= 13", and we are using 14.0.1. Until this is changed in swagger-stats either use yarn or remove prom-client from package.json, npm install, then add it back and do npm install.

If you found this project useful, buy me a beer! 😁 paypal

License

moleculer-template-project-ts-swagger is available under the MIT license.

Contact

Copyright (c) 2022 Our Parent Center

@moleculerjs @MoleculerJS