
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
typed-axios-instance
Advanced tools
Typed Axios is a simple way to create an Axios instance that is fully typed with the routes from an application.
typed-axios-instance
Typed Axios Instance is a simple way to create an Axios instance that is fully typed with the routes from an API.
The benefit of using TypedAxiosInstance is you don't need to create or import a client for a third party API, you can just apply types (generated from OpenAPI or Nextlove) to an existing Axios instance.
import type { TypedAxios } from "typed-axios-instance"
import axios from "axios"
// Need help generating these routes? You can generate them from...
// nextlove: https://github.com/seamapi/nextlove
// openapi: TODO
type Routes = [
{
route: "/things/create"
method: "POST"
jsonBody: {
name?: string | undefined
}
jsonResponse: {
thing: {
thing_id: string
name: string
created_at: string | Date
}
}
}
]
const myAxiosInstance: TypedAxios<Routes> = axios.create({
baseURL: "http://example-api.com",
})
// myAxiosInstance now has intelligent autocomplete!
npm add --dev typed-axios-instance
# yarn add --dev typed-axios-instance
There are two ways of specifying routes for TypedAxios<Routes>
type Routes = RouteDef[]
type Routes = { [route:string]: RouteDef }
Using
RouteDef[]
allows you to do HTTP Method Discrimination and is the recommended method.
This is the type for RouteDef
:
export type RouteDef = {
route: string
method: HTTPMethod // you can supply multiple e.g. `"PATCH" | "POST"`
// INPUTS
queryParams?: Record<string, any>
jsonBody?: Record<string, any>
commonParams?: Record<string, any>
formData?: Record<string, any>
// RESPONSES
jsonResponse?: Record<string, any>
}
There are two ways of specifying route definitions, if you specify the route definitions as an array (default for OpenAPI schemas), you'll get more specific autocomplete results, e.g. the response or request type will be based on what method is being used.
FAQs
Typed Axios is a simple way to create an Axios instance that is fully typed with the routes from an application.
The npm package typed-axios-instance receives a total of 351 weekly downloads. As such, typed-axios-instance popularity was classified as not popular.
We found that typed-axios-instance 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.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.