Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
couchdb-compile
Advanced tools
Readme
Build CouchDB documents from directory, JSON or module.
compile(source[, options], callback)
source
- Can be an object, a CouchDB Directory Tree (see below), a JSON file or a CommonJS moduleoptions.index
- When set to true
, folders are searched for index.js
, which, if present, is treated as CommonJS module. Default is false
.options.multipart
- When set to true
, attachments are handled as multipart. Default is false
.callback
- called when done with two arguments: error
and doc
.In case options.multipart
is set, callback
is called with a third argument:
attachments
. This is a multipart attachments array as required by nanos
db.multipart.insert
:
{
name: 'rabbit.png',
content_type: 'image/png',
data: <Buffer>
}
data
can be a Buffer
or a String
.
var compile = require('couchdb-compile');
compile('project/couchdb', function(error, doc) {
// doc is a compile object now
});
couchdb-compile [SOURCE] [OPTIONS]
When SOURCE
is omitted, the current directory will be used.
OPTIONS
can be --index
and --pretty
, see above.
Use --pretty
to get a pretty printed json output.
couchdb-compile project/couchdb
couchdb-compile project/couchdb --pretty
If there is a function inside source (passed as object or path to CommonJS
module), functions get stringified by calling toString
on them.
eg:
compile({
foo: function () {
return 42
}
}, (error, result) => {
// {
// foo: 'function () {\n return 42\n}'
// }
})
couchdb-compile
uses a filesystem mapping similar to Couchapp python
tool and
Erica:
The Couchapp Filesystem
Mapping.
It is quite self-explanatory. For example:
myapp
├── _id
├── language
└── views
└── numbers
├── map.js
└── reduce.js
becomes:
{
"_id": "_design/myapp",
"language": "javascript",
"views": {
"numbers": {
"map": "function...",
"reduce": "function..."
}
}
}
See test/fixtures
and test/expected
for usage examples.
If you do not include an _id
property, the filename will be used.
For property names file extensions will be stripped:
{
"validate_doc_update": "content of validate_doc_update.js",
}
Files inside the _attachments
directory are handled special:
They become attachment entries of the form
{
"a/file.txt": {
"data": "SGVsbG8gV29ybGQhCg==",
"content_type": "text/plain"
}
}
The content_type
is computed using
mime, with a fallback to
application/octet-stream
. data
is the base64 encoded value of the file.
Read more about Inline Attachments.
npm test
(c) 2014-2018 Johannes J. Schmidt Apache 2.0 License
FAQs
Build CouchDB documents from fs.
The npm package couchdb-compile receives a total of 2,809 weekly downloads. As such, couchdb-compile popularity was classified as popular.
We found that couchdb-compile 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.