Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@yoonit/utils
Advanced tools
A Javascript Lib that provides:
npm i -s @yoonit/utils
We used a functional technique called currying at the main constructor function, this means that we pass a subset of arguments and each function returns a function that uses the next subset of arguments.
The first parameters is a string and its the the endpoint name (such as 'getUsers'), it returns the function that uses the next parameter, the arguments object. This function will build the arguments body for your query/mutation and will return another function. This third function uses the third parameter you need to pass, the expected response fields. This will build the response filds and will return you query/mutation ready to use. You can use the builders without a arguments object, but you need to pass the endpoint name and the response fields, otherwise it will return false and a warning.
Parameters:
import { graphql } from '@yoonit/utils'
const query = graphql.query('getUsers')({ value: 'value', valueTwo: 123 })('status', 'message', 'messageTwo')
Output
query {
getUsers (
value: "value",
valueTwo: 123,
){
status,
message,
messageTwo
}
}
import { graphql } from '@yoonit/utils'
const mutation = graphql.mutation('createUser')(name: 'Mutation', surname: 'Builder')('status', 'message')
Output
mutation {
createUser (
name: "Mutation",
surname: "Builder"
){
status,
message
}
}
Our builders also suports nested response fields and arrays on arguments object, see beelow how to use it:
import { graphql } from '@yoonit/utils'
const mutation = graphql.mutation('createUser')({ value: ['value', '123', 'John Doe']})('status', 'message', { 'messageTwo': ['messageTitle', 'messageBody', { 'messageAlt': 'test' }, { 'messageAtt': ['att1', 'att2'] }]})
Output
mutation {
createUser (
value: [
'value',
'123',
'John Doe'
],
){
status,
message,
messageTwo {
messageTitle,
messageBody,
messageAlt {
test
},
messageAtt {
att1,
att2
}
}
}
}
You can use it with js fetch or any other HTTP client you like. See below how to use it with Fetch
import { graphql } from '@yoonit/utils'
const body = graphql.mutation('createUser')({value: ['value', '123', 'John Doe'] })('status', 'message', { 'messageTwo': ['messageTitle', 'messageBody', { 'messageAlt': 'test' }, { 'messageAtt': ['att1', 'att2'] }]})
fetch('http://yourapi:5000', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body // Use the builder response here, as your body :)
})
})
Clone the repo, change what you want and send PR.
Contributions are always welcome!
Code with ❤ by the Cyberlabs AI Front-End Team
FAQs
Couple of functions in JS to speed up development and give some help
The npm package @yoonit/utils receives a total of 12 weekly downloads. As such, @yoonit/utils popularity was classified as not popular.
We found that @yoonit/utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.