
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@salus-js/http
Advanced tools
A module for statically defining type-safe HTTP operations. These can be leveraged by other modules to build type-safe clients or servers that can execute the requests.
A module for statically defining type-safe HTTP operations. These can be leveraged by other modules to build type-safe clients or servers that can execute the requests.
Defining requests with @salus-js/http is simple. Let's start with a basic GET request that has no parameters and responds with just a string.
import { t } from '@salus-js/codec'
import { http, ResponseOf } from '@salus-js/http'
const getHelloWorld = http.get('/v1/hello', {
response: t.string
})
type HelloWorldResponse = ResponseOf<typeof getHelloWorld> // string
Most of the time, though, you'll have more exciting endpoints than this. Let's take a look at a complete description for an endpoint that creates a contact:
import { t } from '@salus-js/codec'
import { http, BodyOf, ResponseOf } from '@salus-js/http'
const contactParameters = t.partial({
firstName: t.string.document({
description: 'First name for the contact'
}),
lastName: t.string.document({
description: 'Last name for the contact'
})
})
const contactResource = t.object({
object: t.literal('contact').document({
description: 'Always `contact`.'
}),
id: t.string.document({
description: 'Unique ID for the contact'
}),
firstName: t.string.nullable().document({
description: 'First name for the contact'
}),
lastName: t.string.nullable().document({
description: 'Last name for the contact'
})
})
const createContact = http.post('/v1/contacts', {
description: 'Creates a new contact.',
body: contactParameters,
response: contactResource
})
type CreateContactBody = BodyOf<typeof createContact> // { firstName?: string; lastName?: string }
type CreateContactResponse = ResponseOf<typeof createContact> // { object: string; id: string; firstName: string | null; lastName: string | null }
Typically, you won't use @salus-js/http directly, but rather through one of the clients or servers. @salus-js/http is used internally by @salus-js/nestjs for server-side endpoints that are compatible with the NestJS framework, or with @salus-js/axios to create a type-safe HTTP client.
FAQs
A module for statically defining type-safe HTTP operations. These can be leveraged by other modules to build type-safe clients or servers that can execute the requests.
The npm package @salus-js/http receives a total of 132 weekly downloads. As such, @salus-js/http popularity was classified as not popular.
We found that @salus-js/http demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.