
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
tsoa_sample
Advanced tools
by Alejandro M Pirola
This project is a monolithic service that provides a unified interface to all Numie services. fully implemented in Nodejs using Express. It uses TSOA to provide a clean and consistent API documentation, specification and client generation.
Current nodejs version: v16.13.0
Install yarn
npm install --global yarn
Installing all dependencies:
yarn or yarn install
Visual Code Packages:
This projects has 3 launch profiles in .vscode/launch.json. Press F5 to run project's profile with attached debugger. Crtl+F5 to run project's profile without debugger.
If you are using Visual Code, try to avoid using CLI commands.
Any change in controllers regarding new methods or new paths o paths updates, requires a rebuild of routes. Routes are generated using TSOA annotations. Routes are the way this methods are aexposed through Express and Swagger. If you want to build routes manually, you can use the following command:
yarn run tsoa routes
node build/src/server.js
yarn run tsoa spec
yarn run tsc --build --clean
yarn run build
yarn run start
In order to deploy execute the following command:
gcloud app deploy --no-promote --version gonzalez
Then open API Url in browser using:
gcloud app browse
Last url: https://numi-93f79.ue.r.appspot.com/
gcloud app logs tail
Settings are in app.yaml file.
Above command allows to build and deploy the whole project in a single command. Usefull for testing the whole project. But... There is a subset of the API's controllers that are only available to partners As a Service. And there is another subset of the API's controllers that are available for Mobile Apps. In order to keep both projects in sync, we have a sharding mechanism that allows us to split the API's controllers in two differents builds. Each build has defferents spec and routes.
Each sharding has a typescript build script located on project's root. - ./spec_n_routes_consumer_api.ts: contains the spec and routes for the consumer API. - ./spec_n_routes_partner_api.ts: contains the spec and routes for the partner API.
Register in the spec_n_routes_xxxxx_api.ts file the controllers that are available for each sharding.
There is a couple of command line tools that can be used to build the API's.
Long story:
This command will generate the specs and routes for the consumer API:
yarn ts-node spec_n_routes_consumer_api.ts
two files will be generated:
- ./consumer/swagger.json
- ./consumer/routes.ts
Then you have to transpile the entrire project to javascript. This is done using the following command:
yarn tsc --outDir ./consumer
Short story.... just run the following command:
This command will generate the specs and routes for the Partner API:
yarn ts-node spec_n_routes_consumer_api.ts
two files will be generated:
- ./partner/swagger.json
- ./partner/routes.ts
Then you have to transpile the entrire project to javascript. This is done using the following command:
yarn tsc --outDir ./partner
Try to use the launch profiles for unit tests:
Execute tests in folder /test/*.test.ts
yarn run mocha test.ts --require ts-node/register test/**/*.test.ts
Or using package.json script config:
yarn run test
For more information read: Mocha Docs at https://developer.aliyun.com/mirror/npm/package/mocha-typescript
This project requires Firebase Admin SDK to be installed. Is needed for data storage implementations.
https://tsoa-community.github.io/docs/getting-started.html#creating-our-express-server
This projects uses TSOA to generate automatically OpenAPI 3.0 specs. Then is possible to generate clients for this API in any language that is supported by OpenAPI-Generator. Once all specs are generated, a file is created in the /build/swagger.json, this file contains all the information needed to generate clients.
Install Open API Generator using:
npm install @openapitools/openapi-generator-cli -g
You can generate sdk in ../numie_sdk running this command line: yarn run buildgen
Also you can go more deep and execute the following command specifying the language and a different path. For example this line does exactly the same thing that the one above:
openapi-generator generate -i ./build/swagger.json -g dart -c config_openapi.yaml -o ../numie_sdk
FAQs
```by Alejandro M Pirola```
We found that tsoa_sample demonstrated a not healthy version release cadence and project activity because the last version was released 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.