Comparing version 6.0.2 to 6.1.0
@@ -26,3 +26,3 @@ const server = require('http').Server | ||
// return a non-null value -> send with 200 | ||
if (null !== val) { | ||
if (null !== val && undefined !== val) { | ||
send(res, 200, val) | ||
@@ -61,7 +61,13 @@ } | ||
if (Buffer.isBuffer(obj)) { | ||
res.setHeader('Content-Type', 'application/octet-stream') | ||
if (!res.getHeader('Content-Type')) { | ||
res.setHeader('Content-Type', 'application/octet-stream') | ||
} | ||
res.setHeader('Content-Length', obj.length) | ||
res.end(obj) | ||
} else if (isStream(obj)) { | ||
res.setHeader('Content-Type', 'application/octet-stream') | ||
if (!res.getHeader('Content-Type')) { | ||
res.setHeader('Content-Type', 'application/octet-stream') | ||
} | ||
obj.pipe(res) | ||
@@ -114,2 +120,2 @@ } else { | ||
function __async(g){return new Promise(function(s,j){function c(a,x){try{var r=g[x?"throw":"next"](a)}catch(e){return j(e)}return r.done?s(r.value):Promise.resolve(r.value).then(c,d)}function d(e){return c(e,1)}c()})} | ||
function __async(g){return new Promise(function(s,j){function c(a,x){try{var r=g[x?"throw":"next"](a)}catch(e){j(e);return}r.done?s(r.value):Promise.resolve(r.value).then(c,d)}function d(e){c(e,1)}c()})} |
The MIT License (MIT) | ||
Copyright (c) 2016 ZEIT | ||
Copyright (c) 2016 Zeit, Inc. | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "micro", | ||
"version": "6.0.2", | ||
"version": "6.1.0", | ||
"description": "Async HTTP microservices", | ||
@@ -52,3 +52,6 @@ "main": "./dist/index.js", | ||
], | ||
"author": "rauchg", | ||
"author": { | ||
"name": "Zeit, Inc.", | ||
"email": "team@zeit.co" | ||
}, | ||
"license": "MIT", | ||
@@ -60,3 +63,2 @@ "bugs": { | ||
"devDependencies": { | ||
"async-to-gen": "1.0.5", | ||
"ava": "^0.16.0", | ||
@@ -70,3 +72,3 @@ "request": "^2.74.0", | ||
"dependencies": { | ||
"async-to-gen": "1.0.5", | ||
"async-to-gen": "1.1.4", | ||
"isstream": "0.1.2", | ||
@@ -73,0 +75,0 @@ "media-typer": "0.3.0", |
@@ -6,4 +6,4 @@ ![](https://cldup.com/JDmmHX3uhF.svg) | ||
[![Build Status](https://travis-ci.org/zeit/micro.svg?branch=master)](https://travis-ci.org/zeit/micro) | ||
[![NPM version](https://badge.fury.io/js/micro.svg)](https://npmjs.com/micro) | ||
[![Slack](https://zeit-slackin.now.sh/badge.svg)](https://zeit.chat) | ||
[![Slack Channel](https://zeit-slackin.now.sh/badge.svg)](https://zeit.chat/) | ||
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
@@ -111,3 +111,3 @@ ## Features | ||
const { json, send } = require('micro'); | ||
export default async function (req, res) { | ||
module.exports = async function (req, res) { | ||
const data = await json(req); | ||
@@ -134,4 +134,4 @@ console.log(data.price); | ||
```js | ||
const { send } = require('micro'); | ||
export default async function (req, res) { | ||
const { send } = require('micro') | ||
module.exports = async function (req, res) { | ||
send(res, 400, { error: 'Please use a valid email' }); | ||
@@ -149,3 +149,3 @@ } | ||
```js | ||
export default function (req, res) { | ||
module.exports = default function (req, res) { | ||
return {message: 'Hello!'}; | ||
@@ -159,4 +159,4 @@ } | ||
```js | ||
const sleep = require('then-sleep'); | ||
export default async function(req, res) => { | ||
const sleep = require('then-sleep') | ||
module.exports = async function(req, res) => { | ||
return new Promise(async (resolve) => { | ||
@@ -200,4 +200,4 @@ await sleep(100); | ||
```js | ||
const rateLimit = require('my-rate-limit'); | ||
export default async function (req, res) { | ||
const rateLimit = require('my-rate-limit') | ||
module.exports = async function (req, res) { | ||
await rateLimit(req); | ||
@@ -257,3 +257,3 @@ // … your code | ||
```js | ||
export default handleErrors(async (req, res) => { | ||
module.exports = handleErrors(async (req, res) => { | ||
throw new Error('What happened here?'); | ||
@@ -339,5 +339,2 @@ }); | ||
- Thanks Tom Yandell and Richard Hodgson for donating the `micro` npm name. | ||
- Copyright © 2016 Zeit, Inc and project authors. | ||
- Licensed under MIT. | ||
- ▲ | ||
Thanks Tom Yandell and Richard Hodgson for donating the `micro` npm name. |
Sorry, the diff of this file is not supported yet
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
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
17426
6
100
333
+ Addedasync-to-gen@1.1.4(transitive)
+ Addedmagic-string@0.16.0(transitive)
- Removedasync-to-gen@1.0.5(transitive)
- Removedmagic-string@0.15.2(transitive)
Updatedasync-to-gen@1.1.4