forked from m4nuC/async-busboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request m4nuC#53 from alqu/master
Update internal busboy from v0.3.1 to v1.4.0
- Loading branch information
Showing
9 changed files
with
2,869 additions
and
1,025 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.DS_Store | ||
node_modules | ||
.nyc_output | ||
coverage | ||
npm-debug.log | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Ignore artifacts: | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
sudo: false | ||
node_js: | ||
- "10" | ||
- '10' | ||
language: node_js | ||
script: "npm run cover" | ||
after_script: "npm i codecov.io && cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js" | ||
script: 'npm run cover' | ||
after_script: 'npm i codecov.io && cat ./coverage/coverage.json | ./node_modules/codecov.io/bin/codecov.io.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,67 @@ | ||
//This file is if you want to run some test localy, run: `node index.js` | ||
//From there you can use something like [Postman](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en) to send `POST` request to `localhost:8080`. | ||
//Note: When using Postman make sure to not send a `Content-Type` header, if it's field by default, juste delete it. | ||
// This file is if you want to run some test locally, run: `node index.js` | ||
// From there you can use something like [Postman](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en) to send `POST` request to `localhost:8080`. | ||
// Note: When using Postman make sure to not send a `Content-Type` header, if it's field by default, juste delete it. | ||
|
||
const asyncBusboy = require('../') | ||
const asyncBusboy = require('../'); | ||
const http = require('http'); | ||
const PORT = 8080; | ||
|
||
function handleRequest(request, response){ | ||
asyncBusboy(request).then(function(formData) { | ||
// [You can put your tests here] | ||
console.log('Files :', formData.files); | ||
console.log('Fields :', formData.fields) | ||
const server = http | ||
.createServer((req, res) => { | ||
if (req.method === 'POST') { | ||
console.log('POST request'); | ||
asyncBusboy(req).then( | ||
function (formData) { | ||
// [You can put your tests here] | ||
console.log('Files :', formData.files); | ||
console.log('Fields :', formData.fields); | ||
|
||
// We need to emit a reponse so that the request doesn't hang | ||
response.end('It Works!! '); | ||
},function(error) { | ||
console.log(error) | ||
response.end('Something broke!! '); | ||
// We need to emit a response so that the request doesn't hang | ||
res.end('It Works!! '); | ||
}, | ||
function (error) { | ||
console.log(error); | ||
res.end('Something broke!! '); | ||
} | ||
); | ||
} else if (req.method === 'GET') { | ||
res.writeHead(200, { Connection: 'close' }); | ||
res.end(` | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Async Busboy upload test</title> | ||
<link rel="stylesheet" href="//unpkg.com/@picocss/pico@latest/css/pico.classless.min.css"> | ||
</head> | ||
<body> | ||
<main> | ||
<h1>Async Busboy upload test</h1> | ||
<form method="POST" enctype="multipart/form-data"> | ||
<label> | ||
Choose file for upload | ||
<input type="file" name="filefield"> | ||
</label> | ||
<label> | ||
A text field | ||
<input type="text" name="textfield" placeholder="a text field"> | ||
</label> | ||
<button type="submit">Submit</button> | ||
</form> | ||
</main> | ||
</body> | ||
</html> | ||
`); | ||
} | ||
}) | ||
.listen(PORT, () => { | ||
console.log('Server listening on: http://localhost:%s', PORT); | ||
}); | ||
} | ||
|
||
var server = http.createServer(handleRequest); | ||
server.listen(PORT, function(){ | ||
console.log("Server listening on: http://localhost:%s", PORT); | ||
}); | ||
// Example output: | ||
// | ||
// Server listening on: http://localhost:8080 | ||
// < ... form submitted ... > | ||
// POST request | ||
// Files : [ ... | ||
// Fields : { textfield: '...' } |
Oops, something went wrong.