Comparing version 9.4.1 to 10.0.0
{ | ||
"name": "micro", | ||
"version": "9.4.1", | ||
"version": "10.0.0", | ||
"description": "Asynchronous HTTP microservices", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"types": "./micro.d.ts", | ||
"main": "./dist/src/lib/index.js", | ||
"types": "./types", | ||
"files": [ | ||
"bin", | ||
"lib", | ||
"micro.d.ts" | ||
"src", | ||
"dist", | ||
"types" | ||
], | ||
"bin": { | ||
"micro": "./bin/micro.js" | ||
"micro": "./dist/src/bin/micro.js" | ||
}, | ||
"engines": { | ||
"node": ">= 8.0.0" | ||
"node": ">= 16.0.0" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"prepublishOnly": "yarn run build", | ||
"eslint-check": "eslint --max-warnings=0 .", | ||
"prettier-check": "prettier --check .", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"repository": "vercel/micro", | ||
@@ -31,3 +38,12 @@ "keywords": [ | ||
"raw-body": "2.4.1" | ||
} | ||
}, | ||
"devDependencies": { | ||
"@types/content-type": "1.1.5", | ||
"@types/node": "18.0.3", | ||
"@vercel/style-guide": "3.0.0", | ||
"eslint": "8.19.0", | ||
"prettier": "2.7.1", | ||
"typescript": "4.7.4" | ||
}, | ||
"prettier": "@vercel/style-guide/prettier" | ||
} |
@@ -217,17 +217,19 @@ # Micro — Asynchronous HTTP microservices | ||
```js | ||
const micro = require('micro') | ||
const sleep = require('then-sleep') | ||
const http = require('http'); | ||
const serve = require('micro'); | ||
const sleep = require('then-sleep'); | ||
const server = micro(async (req, res) => { | ||
await sleep(500) | ||
return 'Hello world' | ||
}) | ||
const server = new http.Server( | ||
serve(async (req, res) => { | ||
await sleep(500); | ||
return 'Hello world'; | ||
}), | ||
); | ||
server.listen(3000) | ||
server.listen(3000); | ||
``` | ||
##### micro(fn) | ||
##### serve(fn) | ||
- This function is exposed as the `default` export. | ||
- Use `require('micro')`. | ||
- Use `require('micro').serve`. | ||
- Returns a function with the `(req, res) => void` signature. That uses the provided `function` as the request handler. | ||
@@ -324,7 +326,7 @@ - The supplied function is run with `await`. So it can be `async` | ||
Micro makes tests compact and a pleasure to read and write. | ||
We recommend [ava](https://github.com/sindresorhus/ava), a highly parallel Micro test framework with built-in support for async tests: | ||
We recommend [Node TAP](https://node-tap.org/) or [AVA](https://github.com/avajs/ava), a highly parallel test framework with built-in support for async tests: | ||
```js | ||
const http = require('http'); | ||
const micro = require('micro'); | ||
const { send, serve } = require('micro'); | ||
const test = require('ava'); | ||
@@ -336,7 +338,7 @@ const listen = require('test-listen'); | ||
const service = new http.Server( | ||
micro(async (req, res) => { | ||
micro.send(res, 200, { | ||
serve(async (req, res) => { | ||
send(res, 200, { | ||
test: 'woot', | ||
}); | ||
}) | ||
}), | ||
); | ||
@@ -362,3 +364,3 @@ | ||
You can run the [AVA](https://github.com/sindresorhus/ava) tests using: `npm test` | ||
You can run the tests using: `npm test`. | ||
@@ -365,0 +367,0 @@ ## Credits |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
42072
23
787
372
3
6