Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@tsoa/runtime
Advanced tools
@tsoa/runtime is a runtime library for the TSOA framework, which is used to build TypeScript-based REST APIs with OpenAPI documentation. It provides decorators and utilities to define API routes, request validation, and response handling.
Route Definition
Defines a route for the 'users' endpoint and a GET method to retrieve users.
import { Controller, Get, Route } from '@tsoa/runtime';
@Route('users')
export class UserController extends Controller {
@Get()
public async getUsers(): Promise<User[]> {
return [{ id: 1, name: 'John Doe' }];
}
}
Request Validation
Defines a POST method to create a user with request body validation.
import { Controller, Post, Route, Body } from '@tsoa/runtime';
interface CreateUserRequest {
name: string;
}
@Route('users')
export class UserController extends Controller {
@Post()
public async createUser(@Body() request: CreateUserRequest): Promise<User> {
return { id: 1, name: request.name };
}
}
Response Handling
Defines a GET method to retrieve a user by ID with custom response handling for 404 status.
import { Controller, Get, Route, Response } from '@tsoa/runtime';
@Route('users')
export class UserController extends Controller {
@Get('{userId}')
@Response(404, 'User not found')
public async getUser(userId: number): Promise<User> {
if (userId !== 1) {
this.setStatus(404);
return null;
}
return { id: 1, name: 'John Doe' };
}
}
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Unlike @tsoa/runtime, Express does not provide built-in support for TypeScript decorators or OpenAPI documentation.
NestJS is a progressive Node.js framework for building efficient, reliable, and scalable server-side applications. It uses TypeScript and supports decorators similar to @tsoa/runtime, but it also includes a broader set of features like dependency injection and a modular architecture.
Hapi is a rich framework for building applications and services in Node.js. It provides powerful configuration options and a plugin-based architecture. Unlike @tsoa/runtime, Hapi does not natively support TypeScript decorators or OpenAPI documentation.
This package contains the runtime helpers for tsoa.
For a comprehensive Readme, please refer to the main readme.
FAQs
Build swagger-compliant REST APIs using TypeScript and Node
The npm package @tsoa/runtime receives a total of 94,371 weekly downloads. As such, @tsoa/runtime popularity was classified as popular.
We found that @tsoa/runtime demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.