
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
A very small library for parsing and formatting various different mime types in node.js.
Note: Miming does not deal with content negotiation, you should use another library such as negotiator for that.
Miming supports the following built in mime types:
application/jsonapplication/ld+jsontext/htmlapplication/xhtml+xmlmultipart/form-dataapplication/x-www-form-urlencodedVia npm:
npm install miming
Create a Collection of MimeTypes that you'd like to handle in your application. Specify the types in order of precedence.
var Miming = require('miming');
var collection = new Miming.Collection([
'HTML',
'JSON',
'FormURLEncoded',
'MultipartFormData'
]);
var mime = collection.get('application/json');
mime.should.be.an.instanceOf(Miming.Types.JSON);
console.log(mime.format({foo: 'bar'})).should.equal('{"foo":"bar"}');
collection.add('JSONLD');
// or
collection.add('application/json');
// or
collection.add(new Miming.Types.JSONLD());
// or
collection.add(Miming.Types.JSONLD);
Here's a tiny application which parses requests in various formats, translates them to JSON, and echos them back to the client.
var http = require('http'),
Negotiator = require('negotiator'),
Miming = require('../lib'),
collection = new Miming.Collection();
collection.add('application/json');
collection.add('application/x-www-form-urlencoded');
collection.add('multipart/form-data');
http.createServer(function (req, res) {
if (!req.headers['content-type']) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end('<form method="POST"><textarea name="content"></textarea><br><button type="submit">Go</button></form>');
return;
}
collection.parse(req)
.spread(function (body, files) {
res.writeHead(200, {'Content-Type': 'application/json'});
return collection.format('application/json', {
body: body,
files: files
})
.then(res.end.bind(res));
})
.done();
}).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
MIT, see LICENSE.md.
FAQs
Processing and formatting for various mime types.
The npm package miming receives a total of 8 weekly downloads. As such, miming popularity was classified as not popular.
We found that miming demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.