New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sumor/api-middleware

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumor/api-middleware - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "@sumor/api-middleware",
"description": "API Middleware is a middleware for Node.JS. It can easily expose function to api, and validate parameters",
"version": "1.0.7",
"version": "1.0.8",
"license": "MIT",

@@ -6,0 +6,0 @@ "repository": "sumor-cloud/api-middleware",

@@ -77,4 +77,5 @@ # api-middleware

const app = express()
apiMiddleware(app, process.cwd() + '/api')
await apiMiddleware(app, process.cwd() + '/api')
app.listen(3000, () => {

@@ -91,2 +92,35 @@ console.log('Server is running on http://localhost:3000')

5. Test the api
```bash
curl -X POST http://localhost:3000/plus -H "Content-Type: application/json" -d '{"a": 1, "b": 2}'
```
or use browser to open `http://localhost:3000/plus?a=1&b=2`
### Options for apiMiddleware
```javascript
import express from 'express'
import apiMiddleware from '@sumor/api-middleware'
const app = express()
await apiMiddleware(app, process.cwd() + '/api', {
prefix: '/api',
prepare: async context => {
// do something before api
},
finalize: async (context, result) => {
// do something after api
},
exception: async (context, error) => {
// handle error
}
})
app.listen(3000, () => {
console.log('Server is running on http://localhost:3000')
})
```
### More Config File Types

@@ -93,0 +127,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc