Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
super-http-client-js
Advanced tools
Http Client Lib with segregated interfaces developed with clean architecture concepts by Superlógica Tecnologias S.A
Http Client lib for Node.js & TypeScript developed by Superlógica Tecnologias S.A
To install the lib just run the command:
npm install @superlogica/super-http-client-js
Ready!
Now you can use the available interfaces and the adapter.
The most basic possible use is to import default (adapter) and use it, as in the following example:
import SuperHttpClient from '@superlogica/super-http-client-js'
async function getAllCharacters() {
const superHttpClient = new SuperHttpClient({
baseURL: 'https://rickandmortyapi.com/api'
})
const characters = await superHttpClient.get({
url: '/character'
})
return characters
}
You can also make named imports to use interfaces, that is, abstractions instead of injecting concrete classes, as in the following example:
First of all, it is possible to create a type to define what the response will be, for example, of a get request.
// characters-dto.ts
export type Info = {
count: number
pages: number
next: string
prev?: string
}
export type Character = {
id: number
name: string
status: 'alive' | 'dead' | 'unknown'
species: string
type: string
gender: 'male' | 'female' | 'genderless'
origin: {
name: string
url: string
}
location: {
name: string
url: string
}
image: string
episode: string[]
url: string
created: Date
}
Let's create a simple use case that basically lists all characters for a given API. For this, we will use the existing abstraction in the @superlogica/super-http-client-js
lib, which is HttpGetClient
Note that when calling the get method, a parameter is passed to indicate the method's response type.
// get-all-characters-use-case.ts
import { HttpGetClient } from '@superlogica/super-http-client-js'
import { Info, Character } from './characters-dto'
export type Response = Info & Character
export class GetAllCharactersUseCase {
// abstract dependency
constructor(private readonly getCharacters: HttpGetClient) {}
async execute() {
return this.getCharacters.get<Response>({
url: '/character'
})
}
}
Finally, in index file, for example, you can create a lib instance to inject the dependency into the use case constructor
// index.ts
const superHttpClient = new SuperHttpClientAdapter({
baseURL: 'https://rickandmortyapi.com/api'
})
// inject dependency
const getAllCharactersUseCase = new GetAllCharactersUseCase(superHttpClient)
getAllCharactersUseCase.execute().then((response) => {
console.log(response)
})
FAQs
Http Client Lib with segregated interfaces developed with clean architecture concepts by Superlógica Tecnologias S.A
The npm package super-http-client-js receives a total of 0 weekly downloads. As such, super-http-client-js popularity was classified as not popular.
We found that super-http-client-js demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.