Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

micro

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micro - npm Package Compare versions

Comparing version 9.4.1 to 10.0.0

dist/package.json

34

package.json
{
"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

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