
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.
@sumor/api-middleware
Advanced tools
API Middleware is a middleware for Node.JS. It can easily expose function to api, and validate parameters
A Sumor Cloud Tool.
More Documentation
API Middleware is a middleware for Node.JS.
It can easily expose function to api, and validate parameters
npm i @sumor/api-middleware --save
Require Node.JS version 16.x or above
As this package is written in ES module,
please change the following code in your package.json
file:
{
"type": "module"
}
plus.js
in your project folder api
export default async (context, req, res) => {
const { data } = context
const { a, b } = data
return a + b
}
[Optional] 2. Add a file named plus.json
in your project folder api
{
"name": "plus",
"parameters": {
"a": {
"name": "parameter a",
"type": "number",
"length": 3
},
"b": {
"name": "parameter b",
"type": "number"
}
}
}
index.js
fileimport express from 'express'
import apiMiddleware from '@sumor/api-middleware'
const app = express()
apiMiddleware(app, process.cwd() + '/api')
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000')
})
run index.js
node index.js
FAQs
API Middleware is a middleware for Node.JS. It can easily expose function to api, and validate parameters
The npm package @sumor/api-middleware receives a total of 40,718 weekly downloads. As such, @sumor/api-middleware popularity was classified as popular.
We found that @sumor/api-middleware demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
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.