
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
tote-lib
tote-lib
is a helper library for Tote.
tote-lib
exports four items.
Func
Func
is the class you use to setup your function. It includes several helper methods.
// import dependencies
import { Func, joi } from 'tote-lib'
// create your function
class Hello extends Func {
// define your schema
schema = {
// query parameters
query: joi.object({
number: joi.number()
})
}
// define your function here
invoke() {
// get query params
const {
query: { number = 5 }
} = this.request
// return object
return {
hello: 'world',
result: number * 2
}
}
}
// bootstrap and export
export default Func.bootstrap(Hello)
Name | Type | Description |
---|---|---|
context | Object | Azure Function execution context |
request | Object | Request object. Contains body , headers , and query objects with any parameters |
status<number> | Function | Set the HTTP status code |
send<object> | Function | Set the JSON body |
request
Get input parameters.
// get parameters
const {
body: { foo },
query: { name }
} = this.request
// use them
status
this.status(404)
send
You can just return the object from your function. But you can also use send
.
this.send({
foo: 'bar'
})
Exception
Exception
extends Error
and lets you throw sensible errors from your functions.
Name | Type | Description | Default |
---|---|---|---|
message | string | Error message or key | unknown_error |
status | number | HTTP status code | 500 |
throw new Exception('Email required', 400)
invoke
invoke
is a helper for invoking functions when writing your tests.
Name | Type | Description |
---|---|---|
name | string | Function name, should correspond to a directory |
request | Object | Optional. Request object, may contain body , headers , and query objects |
invoke('hello', {
headers: {
authorization: 'Bearer ...'
},
query: {
name: 'Ali'
}
})
joi
Look at Joi docs.
FAQs
`tote-lib` is a helper library for [Tote](https://github.com/alizahid/tote).
The npm package tote-lib receives a total of 0 weekly downloads. As such, tote-lib popularity was classified as not popular.
We found that tote-lib 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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.