initial commit
This commit is contained in:
commit
ee8aedd857
1599 changed files with 652440 additions and 0 deletions
17
backend/node_modules/multer/LICENSE
generated
vendored
Normal file
17
backend/node_modules/multer/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
Copyright (c) 2014 Hage Yaapa <[http://www.hacksparrow.com](http://www.hacksparrow.com)>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
348
backend/node_modules/multer/README.md
generated
vendored
Normal file
348
backend/node_modules/multer/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,348 @@
|
|||
# Multer [![NPM Version][npm-version-image]][npm-url] [![NPM Downloads][npm-downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Test Coverage][test-image]][test-url] [![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||
|
||||
Multer is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written
|
||||
on top of [busboy](https://github.com/mscdex/busboy) for maximum efficiency.
|
||||
|
||||
**NOTE**: Multer will not process any form which is not multipart (`multipart/form-data`).
|
||||
|
||||
## Translations
|
||||
|
||||
This README is also available in other languages:
|
||||
|
||||
| | |
|
||||
| ------------------------------------------------------------------------------ | --------------- |
|
||||
| [العربية](https://github.com/expressjs/multer/blob/main/doc/README-ar.md) | Arabic |
|
||||
| [简体中文](https://github.com/expressjs/multer/blob/main/doc/README-zh-cn.md) | Chinese |
|
||||
| [Français](https://github.com/expressjs/multer/blob/main/doc/README-fr.md) | French |
|
||||
| [한국어](https://github.com/expressjs/multer/blob/main/doc/README-ko.md) | Korean |
|
||||
| [Português](https://github.com/expressjs/multer/blob/main/doc/README-pt-br.md) | Portuguese (BR) |
|
||||
| [Русский язык](https://github.com/expressjs/multer/blob/main/doc/README-ru.md) | Russian |
|
||||
| [Español](https://github.com/expressjs/multer/blob/main/doc/README-es.md) | Spanish |
|
||||
| [O'zbek tili](https://github.com/expressjs/multer/blob/main/doc/README-uz.md) | Uzbek |
|
||||
| [Việt Nam](https://github.com/expressjs/multer/blob/main/doc/README-vi.md) | Vietnamese |
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install multer
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Multer adds a `body` object and a `file` or `files` object to the `request` object. The `body` object contains the values of the text fields of the form, the `file` or `files` object contains the files uploaded via the form.
|
||||
|
||||
Basic usage example:
|
||||
|
||||
Don't forget the `enctype="multipart/form-data"` in your form.
|
||||
|
||||
```html
|
||||
<form action="/profile" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="avatar" />
|
||||
</form>
|
||||
```
|
||||
|
||||
```javascript
|
||||
const express = require('express')
|
||||
const multer = require('multer')
|
||||
const upload = multer({ dest: 'uploads/' })
|
||||
|
||||
const app = express()
|
||||
|
||||
app.post('/profile', upload.single('avatar'), function (req, res, next) {
|
||||
// req.file is the `avatar` file
|
||||
// req.body will hold the text fields, if there were any
|
||||
})
|
||||
|
||||
app.post('/photos/upload', upload.array('photos', 12), function (req, res, next) {
|
||||
// req.files is array of `photos` files
|
||||
// req.body will contain the text fields, if there were any
|
||||
})
|
||||
|
||||
const uploadMiddleware = upload.fields([{ name: 'avatar', maxCount: 1 }, { name: 'gallery', maxCount: 8 }])
|
||||
app.post('/cool-profile', uploadMiddleware, function (req, res, next) {
|
||||
// req.files is an object (String -> Array) where fieldname is the key, and the value is array of files
|
||||
//
|
||||
// e.g.
|
||||
// req.files['avatar'][0] -> File
|
||||
// req.files['gallery'] -> Array
|
||||
//
|
||||
// req.body will contain the text fields, if there were any
|
||||
})
|
||||
```
|
||||
|
||||
In case you need to handle a text-only multipart form, you should use the `.none()` method:
|
||||
|
||||
```javascript
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const multer = require('multer')
|
||||
const upload = multer()
|
||||
|
||||
app.post('/profile', upload.none(), function (req, res, next) {
|
||||
// req.body contains the text fields
|
||||
})
|
||||
```
|
||||
|
||||
Here's an example on how multer is used in a HTML form. Take special note of the `enctype="multipart/form-data"` and `name="uploaded_file"` fields:
|
||||
|
||||
```html
|
||||
<form action="/stats" enctype="multipart/form-data" method="post">
|
||||
<div class="form-group">
|
||||
<input type="file" class="form-control-file" name="uploaded_file">
|
||||
<input type="text" class="form-control" placeholder="Number of speakers" name="nspeakers">
|
||||
<input type="submit" value="Get me the stats!" class="btn btn-default">
|
||||
</div>
|
||||
</form>
|
||||
```
|
||||
|
||||
Then in your javascript file you would add these lines to access both the file and the body. It is important that you use the `name` field value from the form in your upload function. This tells multer which field on the request it should look for the files in. If these fields aren't the same in the HTML form and on your server, your upload will fail:
|
||||
|
||||
```javascript
|
||||
const multer = require('multer')
|
||||
const upload = multer({ dest: './public/data/uploads/' })
|
||||
app.post('/stats', upload.single('uploaded_file'), function (req, res) {
|
||||
// req.file is the name of your file in the form above, here 'uploaded_file'
|
||||
// req.body will hold the text fields, if there were any
|
||||
console.log(req.file, req.body)
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### File information
|
||||
|
||||
Each file contains the following information:
|
||||
|
||||
Key | Description | Note
|
||||
--- | --- | ---
|
||||
`fieldname` | Field name specified in the form |
|
||||
`originalname` | Name of the file on the user's computer |
|
||||
`encoding` | Encoding type of the file |
|
||||
`mimetype` | Mime type of the file |
|
||||
`size` | Size of the file in bytes |
|
||||
`destination` | The folder to which the file has been saved | `DiskStorage`
|
||||
`filename` | The name of the file within the `destination` | `DiskStorage`
|
||||
`path` | The full path to the uploaded file | `DiskStorage`
|
||||
`buffer` | A `Buffer` of the entire file | `MemoryStorage`
|
||||
|
||||
### `multer(opts)`
|
||||
|
||||
Multer accepts an options object, the most basic of which is the `dest`
|
||||
property, which tells Multer where to upload the files. In case you omit the
|
||||
options object, the files will be kept in memory and never written to disk.
|
||||
|
||||
By default, Multer will rename the files so as to avoid naming conflicts. The
|
||||
renaming function can be customized according to your needs.
|
||||
|
||||
The following are the options that can be passed to Multer.
|
||||
|
||||
Key | Description
|
||||
--- | ---
|
||||
`dest` or `storage` | Where to store the files
|
||||
`fileFilter` | Function to control which files are accepted
|
||||
`limits` | Limits of the uploaded data
|
||||
`preservePath` | Keep the full path of files instead of just the base name
|
||||
|
||||
In an average web app, only `dest` might be required, and configured as shown in
|
||||
the following example.
|
||||
|
||||
```javascript
|
||||
const upload = multer({ dest: 'uploads/' })
|
||||
```
|
||||
|
||||
If you want more control over your uploads, you'll want to use the `storage`
|
||||
option instead of `dest`. Multer ships with storage engines `DiskStorage`
|
||||
and `MemoryStorage`; More engines are available from third parties.
|
||||
|
||||
#### `.single(fieldname)`
|
||||
|
||||
Accept a single file with the name `fieldname`. The single file will be stored
|
||||
in `req.file`.
|
||||
|
||||
#### `.array(fieldname[, maxCount])`
|
||||
|
||||
Accept an array of files, all with the name `fieldname`. Optionally error out if
|
||||
more than `maxCount` files are uploaded. The array of files will be stored in
|
||||
`req.files`.
|
||||
|
||||
#### `.fields(fields)`
|
||||
|
||||
Accept a mix of files, specified by `fields`. An object with arrays of files
|
||||
will be stored in `req.files`.
|
||||
|
||||
`fields` should be an array of objects with `name` and optionally a `maxCount`.
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
[
|
||||
{ name: 'avatar', maxCount: 1 },
|
||||
{ name: 'gallery', maxCount: 8 }
|
||||
]
|
||||
```
|
||||
|
||||
#### `.none()`
|
||||
|
||||
Accept only text fields. If any file upload is made, error with code
|
||||
"LIMIT\_UNEXPECTED\_FILE" will be issued.
|
||||
|
||||
#### `.any()`
|
||||
|
||||
Accepts all files that comes over the wire. An array of files will be stored in
|
||||
`req.files`.
|
||||
|
||||
**WARNING:** Make sure that you always handle the files that a user uploads.
|
||||
Never add multer as a global middleware since a malicious user could upload
|
||||
files to a route that you didn't anticipate. Only use this function on routes
|
||||
where you are handling the uploaded files.
|
||||
|
||||
### `storage`
|
||||
|
||||
#### `DiskStorage`
|
||||
|
||||
The disk storage engine gives you full control on storing files to disk.
|
||||
|
||||
```javascript
|
||||
const storage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
cb(null, '/tmp/my-uploads')
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9)
|
||||
cb(null, file.fieldname + '-' + uniqueSuffix)
|
||||
}
|
||||
})
|
||||
|
||||
const upload = multer({ storage: storage })
|
||||
```
|
||||
|
||||
There are two options available, `destination` and `filename`. They are both
|
||||
functions that determine where the file should be stored.
|
||||
|
||||
`destination` is used to determine within which folder the uploaded files should
|
||||
be stored. This can also be given as a `string` (e.g. `'/tmp/uploads'`). If no
|
||||
`destination` is given, the operating system's default directory for temporary
|
||||
files is used.
|
||||
|
||||
**Note:** You are responsible for creating the directory when providing
|
||||
`destination` as a function. When passing a string, multer will make sure that
|
||||
the directory is created for you.
|
||||
|
||||
`filename` is used to determine what the file should be named inside the folder.
|
||||
If no `filename` is given, each file will be given a random name that doesn't
|
||||
include any file extension.
|
||||
|
||||
**Note:** Multer will not append any file extension for you, your function
|
||||
should return a filename complete with a file extension.
|
||||
|
||||
Each function gets passed both the request (`req`) and some information about
|
||||
the file (`file`) to aid with the decision.
|
||||
|
||||
Note that `req.body` might not have been fully populated yet. It depends on the
|
||||
order that the client transmits fields and files to the server.
|
||||
|
||||
For understanding the calling convention used in the callback (needing to pass
|
||||
null as the first param), refer to
|
||||
[Node.js error handling](https://web.archive.org/web/20220417042018/https://www.joyent.com/node-js/production/design/errors)
|
||||
|
||||
#### `MemoryStorage`
|
||||
|
||||
The memory storage engine stores the files in memory as `Buffer` objects. It
|
||||
doesn't have any options.
|
||||
|
||||
```javascript
|
||||
const storage = multer.memoryStorage()
|
||||
const upload = multer({ storage: storage })
|
||||
```
|
||||
|
||||
When using memory storage, the file info will contain a field called
|
||||
`buffer` that contains the entire file.
|
||||
|
||||
**WARNING**: Uploading very large files, or relatively small files in large
|
||||
numbers very quickly, can cause your application to run out of memory when
|
||||
memory storage is used.
|
||||
|
||||
### `limits`
|
||||
|
||||
An object specifying the size limits of the following optional properties. Multer passes this object into busboy directly, and the details of the properties can be found on [busboy's page](https://github.com/mscdex/busboy#busboy-methods).
|
||||
|
||||
The following integer values are available:
|
||||
|
||||
Key | Description | Default
|
||||
--- | --- | ---
|
||||
`fieldNameSize` | Max field name size | 100 bytes
|
||||
`fieldSize` | Max field value size (in bytes) | 1MB
|
||||
`fields` | Max number of non-file fields | Infinity
|
||||
`fileSize` | For multipart forms, the max file size (in bytes) | Infinity
|
||||
`files` | For multipart forms, the max number of file fields | Infinity
|
||||
`parts` | For multipart forms, the max number of parts (fields + files) | Infinity
|
||||
`headerPairs` | For multipart forms, the max number of header key=>value pairs to parse | 2000
|
||||
|
||||
Specifying the limits can help protect your site against denial of service (DoS) attacks.
|
||||
|
||||
### `fileFilter`
|
||||
|
||||
Set this to a function to control which files should be uploaded and which
|
||||
should be skipped. The function should look like this:
|
||||
|
||||
```javascript
|
||||
function fileFilter (req, file, cb) {
|
||||
|
||||
// The function should call `cb` with a boolean
|
||||
// to indicate if the file should be accepted
|
||||
|
||||
// To reject this file pass `false`, like so:
|
||||
cb(null, false)
|
||||
|
||||
// To accept the file pass `true`, like so:
|
||||
cb(null, true)
|
||||
|
||||
// You can always pass an error if something goes wrong:
|
||||
cb(new Error('I don\'t have a clue!'))
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
## Error handling
|
||||
|
||||
When encountering an error, Multer will delegate the error to Express. You can
|
||||
display a nice error page using [the standard express way](http://expressjs.com/guide/error-handling.html).
|
||||
|
||||
If you want to catch errors specifically from Multer, you can call the
|
||||
middleware function by yourself. Also, if you want to catch only [the Multer errors](https://github.com/expressjs/multer/blob/main/lib/multer-error.js), you can use the `MulterError` class that is attached to the `multer` object itself (e.g. `err instanceof multer.MulterError`).
|
||||
|
||||
```javascript
|
||||
const multer = require('multer')
|
||||
const upload = multer().single('avatar')
|
||||
|
||||
app.post('/profile', function (req, res) {
|
||||
upload(req, res, function (err) {
|
||||
if (err instanceof multer.MulterError) {
|
||||
// A Multer error occurred when uploading.
|
||||
} else if (err) {
|
||||
// An unknown error occurred when uploading.
|
||||
}
|
||||
|
||||
// Everything went fine.
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Custom storage engine
|
||||
|
||||
For information on how to build your own storage engine, see [Multer Storage Engine](https://github.com/expressjs/multer/blob/main/StorageEngine.md).
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://github.com/expressjs/multer/actions/workflows/ci.yml/badge.svg
|
||||
[ci-url]: https://github.com/expressjs/multer/actions/workflows/ci.yml
|
||||
[test-url]: https://coveralls.io/r/expressjs/multer?branch=main
|
||||
[test-image]: https://badgen.net/coveralls/c/github/expressjs/multer/main
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/multer
|
||||
[npm-url]: https://npmjs.org/package/multer
|
||||
[npm-version-image]: https://badgen.net/npm/v/multer
|
||||
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/multer/badge
|
||||
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/multer
|
||||
104
backend/node_modules/multer/index.js
generated
vendored
Normal file
104
backend/node_modules/multer/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
var makeMiddleware = require('./lib/make-middleware')
|
||||
|
||||
var diskStorage = require('./storage/disk')
|
||||
var memoryStorage = require('./storage/memory')
|
||||
var MulterError = require('./lib/multer-error')
|
||||
|
||||
function allowAll (req, file, cb) {
|
||||
cb(null, true)
|
||||
}
|
||||
|
||||
function Multer (options) {
|
||||
if (options.storage) {
|
||||
this.storage = options.storage
|
||||
} else if (options.dest) {
|
||||
this.storage = diskStorage({ destination: options.dest })
|
||||
} else {
|
||||
this.storage = memoryStorage()
|
||||
}
|
||||
|
||||
this.limits = options.limits
|
||||
this.preservePath = options.preservePath
|
||||
this.fileFilter = options.fileFilter || allowAll
|
||||
}
|
||||
|
||||
Multer.prototype._makeMiddleware = function (fields, fileStrategy) {
|
||||
function setup () {
|
||||
var fileFilter = this.fileFilter
|
||||
var filesLeft = Object.create(null)
|
||||
|
||||
fields.forEach(function (field) {
|
||||
if (typeof field.maxCount === 'number') {
|
||||
filesLeft[field.name] = field.maxCount
|
||||
} else {
|
||||
filesLeft[field.name] = Infinity
|
||||
}
|
||||
})
|
||||
|
||||
function wrappedFileFilter (req, file, cb) {
|
||||
if ((filesLeft[file.fieldname] || 0) <= 0) {
|
||||
return cb(new MulterError('LIMIT_UNEXPECTED_FILE', file.fieldname))
|
||||
}
|
||||
|
||||
filesLeft[file.fieldname] -= 1
|
||||
fileFilter(req, file, cb)
|
||||
}
|
||||
|
||||
return {
|
||||
limits: this.limits,
|
||||
preservePath: this.preservePath,
|
||||
storage: this.storage,
|
||||
fileFilter: wrappedFileFilter,
|
||||
fileStrategy: fileStrategy
|
||||
}
|
||||
}
|
||||
|
||||
return makeMiddleware(setup.bind(this))
|
||||
}
|
||||
|
||||
Multer.prototype.single = function (name) {
|
||||
return this._makeMiddleware([{ name: name, maxCount: 1 }], 'VALUE')
|
||||
}
|
||||
|
||||
Multer.prototype.array = function (name, maxCount) {
|
||||
return this._makeMiddleware([{ name: name, maxCount: maxCount }], 'ARRAY')
|
||||
}
|
||||
|
||||
Multer.prototype.fields = function (fields) {
|
||||
return this._makeMiddleware(fields, 'OBJECT')
|
||||
}
|
||||
|
||||
Multer.prototype.none = function () {
|
||||
return this._makeMiddleware([], 'NONE')
|
||||
}
|
||||
|
||||
Multer.prototype.any = function () {
|
||||
function setup () {
|
||||
return {
|
||||
limits: this.limits,
|
||||
preservePath: this.preservePath,
|
||||
storage: this.storage,
|
||||
fileFilter: this.fileFilter,
|
||||
fileStrategy: 'ARRAY'
|
||||
}
|
||||
}
|
||||
|
||||
return makeMiddleware(setup.bind(this))
|
||||
}
|
||||
|
||||
function multer (options) {
|
||||
if (options === undefined) {
|
||||
return new Multer({})
|
||||
}
|
||||
|
||||
if (typeof options === 'object' && options !== null) {
|
||||
return new Multer(options)
|
||||
}
|
||||
|
||||
throw new TypeError('Expected object for argument options')
|
||||
}
|
||||
|
||||
module.exports = multer
|
||||
module.exports.diskStorage = diskStorage
|
||||
module.exports.memoryStorage = memoryStorage
|
||||
module.exports.MulterError = MulterError
|
||||
28
backend/node_modules/multer/lib/counter.js
generated
vendored
Normal file
28
backend/node_modules/multer/lib/counter.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
var EventEmitter = require('events').EventEmitter
|
||||
|
||||
function Counter () {
|
||||
EventEmitter.call(this)
|
||||
this.value = 0
|
||||
}
|
||||
|
||||
Counter.prototype = Object.create(EventEmitter.prototype)
|
||||
|
||||
Counter.prototype.increment = function increment () {
|
||||
this.value++
|
||||
}
|
||||
|
||||
Counter.prototype.decrement = function decrement () {
|
||||
if (--this.value === 0) this.emit('zero')
|
||||
}
|
||||
|
||||
Counter.prototype.isZero = function isZero () {
|
||||
return (this.value === 0)
|
||||
}
|
||||
|
||||
Counter.prototype.onceZero = function onceZero (fn) {
|
||||
if (this.isZero()) return fn()
|
||||
|
||||
this.once('zero', fn)
|
||||
}
|
||||
|
||||
module.exports = Counter
|
||||
67
backend/node_modules/multer/lib/file-appender.js
generated
vendored
Normal file
67
backend/node_modules/multer/lib/file-appender.js
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
var objectAssign = require('object-assign')
|
||||
|
||||
function arrayRemove (arr, item) {
|
||||
var idx = arr.indexOf(item)
|
||||
if (~idx) arr.splice(idx, 1)
|
||||
}
|
||||
|
||||
function FileAppender (strategy, req) {
|
||||
this.strategy = strategy
|
||||
this.req = req
|
||||
|
||||
switch (strategy) {
|
||||
case 'NONE': break
|
||||
case 'VALUE': break
|
||||
case 'ARRAY': req.files = []; break
|
||||
case 'OBJECT': req.files = Object.create(null); break
|
||||
default: throw new Error('Unknown file strategy: ' + strategy)
|
||||
}
|
||||
}
|
||||
|
||||
FileAppender.prototype.insertPlaceholder = function (file) {
|
||||
var placeholder = {
|
||||
fieldname: file.fieldname
|
||||
}
|
||||
|
||||
switch (this.strategy) {
|
||||
case 'NONE': break
|
||||
case 'VALUE': break
|
||||
case 'ARRAY': this.req.files.push(placeholder); break
|
||||
case 'OBJECT':
|
||||
if (this.req.files[file.fieldname]) {
|
||||
this.req.files[file.fieldname].push(placeholder)
|
||||
} else {
|
||||
this.req.files[file.fieldname] = [placeholder]
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
return placeholder
|
||||
}
|
||||
|
||||
FileAppender.prototype.removePlaceholder = function (placeholder) {
|
||||
switch (this.strategy) {
|
||||
case 'NONE': break
|
||||
case 'VALUE': break
|
||||
case 'ARRAY': arrayRemove(this.req.files, placeholder); break
|
||||
case 'OBJECT':
|
||||
if (this.req.files[placeholder.fieldname].length === 1) {
|
||||
delete this.req.files[placeholder.fieldname]
|
||||
} else {
|
||||
arrayRemove(this.req.files[placeholder.fieldname], placeholder)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
FileAppender.prototype.replacePlaceholder = function (placeholder, file) {
|
||||
if (this.strategy === 'VALUE') {
|
||||
this.req.file = file
|
||||
return
|
||||
}
|
||||
|
||||
delete placeholder.fieldname
|
||||
objectAssign(placeholder, file)
|
||||
}
|
||||
|
||||
module.exports = FileAppender
|
||||
194
backend/node_modules/multer/lib/make-middleware.js
generated
vendored
Normal file
194
backend/node_modules/multer/lib/make-middleware.js
generated
vendored
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
var is = require('type-is')
|
||||
var Busboy = require('busboy')
|
||||
var extend = require('xtend')
|
||||
var appendField = require('append-field')
|
||||
|
||||
var Counter = require('./counter')
|
||||
var MulterError = require('./multer-error')
|
||||
var FileAppender = require('./file-appender')
|
||||
var removeUploadedFiles = require('./remove-uploaded-files')
|
||||
|
||||
function drainStream (stream) {
|
||||
stream.on('readable', () => {
|
||||
while (stream.read() !== null) {}
|
||||
})
|
||||
}
|
||||
|
||||
function makeMiddleware (setup) {
|
||||
return function multerMiddleware (req, res, next) {
|
||||
if (!is(req, ['multipart'])) return next()
|
||||
|
||||
var options = setup()
|
||||
|
||||
var limits = options.limits
|
||||
var storage = options.storage
|
||||
var fileFilter = options.fileFilter
|
||||
var fileStrategy = options.fileStrategy
|
||||
var preservePath = options.preservePath
|
||||
|
||||
req.body = Object.create(null)
|
||||
|
||||
req.on('error', function (err) {
|
||||
abortWithError(err)
|
||||
})
|
||||
|
||||
var busboy
|
||||
|
||||
try {
|
||||
busboy = Busboy({ headers: req.headers, limits: limits, preservePath: preservePath })
|
||||
} catch (err) {
|
||||
return next(err)
|
||||
}
|
||||
|
||||
var appender = new FileAppender(fileStrategy, req)
|
||||
var isDone = false
|
||||
var readFinished = false
|
||||
var errorOccured = false
|
||||
var pendingWrites = new Counter()
|
||||
var uploadedFiles = []
|
||||
|
||||
function done (err) {
|
||||
if (isDone) return
|
||||
isDone = true
|
||||
req.unpipe(busboy)
|
||||
drainStream(req)
|
||||
req.resume()
|
||||
setImmediate(() => {
|
||||
busboy.removeAllListeners()
|
||||
})
|
||||
next(err)
|
||||
}
|
||||
|
||||
function indicateDone () {
|
||||
if (readFinished && pendingWrites.isZero() && !errorOccured) done()
|
||||
}
|
||||
|
||||
function abortWithError (uploadError) {
|
||||
if (errorOccured) return
|
||||
errorOccured = true
|
||||
|
||||
pendingWrites.onceZero(function () {
|
||||
function remove (file, cb) {
|
||||
storage._removeFile(req, file, cb)
|
||||
}
|
||||
|
||||
removeUploadedFiles(uploadedFiles, remove, function (err, storageErrors) {
|
||||
if (err) return done(err)
|
||||
|
||||
uploadError.storageErrors = storageErrors
|
||||
done(uploadError)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function abortWithCode (code, optionalField) {
|
||||
abortWithError(new MulterError(code, optionalField))
|
||||
}
|
||||
|
||||
// handle text field data
|
||||
busboy.on('field', function (fieldname, value, { nameTruncated, valueTruncated }) {
|
||||
if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME')
|
||||
if (nameTruncated) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
if (valueTruncated) return abortWithCode('LIMIT_FIELD_VALUE', fieldname)
|
||||
|
||||
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
|
||||
if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {
|
||||
if (fieldname.length > limits.fieldNameSize) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
}
|
||||
|
||||
appendField(req.body, fieldname, value)
|
||||
})
|
||||
|
||||
// handle files
|
||||
busboy.on('file', function (fieldname, fileStream, { filename, encoding, mimeType }) {
|
||||
var pendingWritesIncremented = false
|
||||
|
||||
fileStream.on('error', function (err) {
|
||||
if (pendingWritesIncremented) {
|
||||
pendingWrites.decrement()
|
||||
}
|
||||
abortWithError(err)
|
||||
})
|
||||
|
||||
if (fieldname == null) return abortWithCode('MISSING_FIELD_NAME')
|
||||
|
||||
// don't attach to the files object, if there is no file
|
||||
if (!filename) return fileStream.resume()
|
||||
|
||||
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
|
||||
if (limits && Object.prototype.hasOwnProperty.call(limits, 'fieldNameSize')) {
|
||||
if (fieldname.length > limits.fieldNameSize) return abortWithCode('LIMIT_FIELD_KEY')
|
||||
}
|
||||
|
||||
var file = {
|
||||
fieldname: fieldname,
|
||||
originalname: filename,
|
||||
encoding: encoding,
|
||||
mimetype: mimeType
|
||||
}
|
||||
|
||||
var placeholder = appender.insertPlaceholder(file)
|
||||
|
||||
fileFilter(req, file, function (err, includeFile) {
|
||||
if (err) {
|
||||
appender.removePlaceholder(placeholder)
|
||||
return abortWithError(err)
|
||||
}
|
||||
|
||||
if (!includeFile) {
|
||||
appender.removePlaceholder(placeholder)
|
||||
return fileStream.resume()
|
||||
}
|
||||
|
||||
var aborting = false
|
||||
pendingWritesIncremented = true
|
||||
pendingWrites.increment()
|
||||
|
||||
Object.defineProperty(file, 'stream', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: fileStream
|
||||
})
|
||||
|
||||
fileStream.on('limit', function () {
|
||||
aborting = true
|
||||
abortWithCode('LIMIT_FILE_SIZE', fieldname)
|
||||
})
|
||||
|
||||
storage._handleFile(req, file, function (err, info) {
|
||||
if (aborting) {
|
||||
appender.removePlaceholder(placeholder)
|
||||
uploadedFiles.push(extend(file, info))
|
||||
return pendingWrites.decrement()
|
||||
}
|
||||
|
||||
if (err) {
|
||||
appender.removePlaceholder(placeholder)
|
||||
pendingWrites.decrement()
|
||||
return abortWithError(err)
|
||||
}
|
||||
|
||||
var fileInfo = extend(file, info)
|
||||
|
||||
appender.replacePlaceholder(placeholder, fileInfo)
|
||||
uploadedFiles.push(fileInfo)
|
||||
pendingWrites.decrement()
|
||||
indicateDone()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
busboy.on('error', function (err) { abortWithError(err) })
|
||||
busboy.on('partsLimit', function () { abortWithCode('LIMIT_PART_COUNT') })
|
||||
busboy.on('filesLimit', function () { abortWithCode('LIMIT_FILE_COUNT') })
|
||||
busboy.on('fieldsLimit', function () { abortWithCode('LIMIT_FIELD_COUNT') })
|
||||
busboy.on('close', function () {
|
||||
readFinished = true
|
||||
indicateDone()
|
||||
})
|
||||
|
||||
req.pipe(busboy)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = makeMiddleware
|
||||
24
backend/node_modules/multer/lib/multer-error.js
generated
vendored
Normal file
24
backend/node_modules/multer/lib/multer-error.js
generated
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
var util = require('util')
|
||||
|
||||
var errorMessages = {
|
||||
LIMIT_PART_COUNT: 'Too many parts',
|
||||
LIMIT_FILE_SIZE: 'File too large',
|
||||
LIMIT_FILE_COUNT: 'Too many files',
|
||||
LIMIT_FIELD_KEY: 'Field name too long',
|
||||
LIMIT_FIELD_VALUE: 'Field value too long',
|
||||
LIMIT_FIELD_COUNT: 'Too many fields',
|
||||
LIMIT_UNEXPECTED_FILE: 'Unexpected field',
|
||||
MISSING_FIELD_NAME: 'Field name missing'
|
||||
}
|
||||
|
||||
function MulterError (code, field) {
|
||||
Error.captureStackTrace(this, this.constructor)
|
||||
this.name = this.constructor.name
|
||||
this.message = errorMessages[code]
|
||||
this.code = code
|
||||
if (field) this.field = field
|
||||
}
|
||||
|
||||
util.inherits(MulterError, Error)
|
||||
|
||||
module.exports = MulterError
|
||||
28
backend/node_modules/multer/lib/remove-uploaded-files.js
generated
vendored
Normal file
28
backend/node_modules/multer/lib/remove-uploaded-files.js
generated
vendored
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
function removeUploadedFiles (uploadedFiles, remove, cb) {
|
||||
var length = uploadedFiles.length
|
||||
var errors = []
|
||||
|
||||
if (length === 0) return cb(null, errors)
|
||||
|
||||
function handleFile (idx) {
|
||||
var file = uploadedFiles[idx]
|
||||
|
||||
remove(file, function (err) {
|
||||
if (err) {
|
||||
err.file = file
|
||||
err.field = file.fieldname
|
||||
errors.push(err)
|
||||
}
|
||||
|
||||
if (idx < length - 1) {
|
||||
handleFile(idx + 1)
|
||||
} else {
|
||||
cb(null, errors)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
handleFile(0)
|
||||
}
|
||||
|
||||
module.exports = removeUploadedFiles
|
||||
22
backend/node_modules/multer/node_modules/media-typer/HISTORY.md
generated
vendored
Normal file
22
backend/node_modules/multer/node_modules/media-typer/HISTORY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
0.3.0 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* Throw error when parameter format invalid on parse
|
||||
|
||||
0.2.0 / 2014-06-18
|
||||
==================
|
||||
|
||||
* Add `typer.format()` to format media types
|
||||
|
||||
0.1.0 / 2014-06-17
|
||||
==================
|
||||
|
||||
* Accept `req` as argument to `parse`
|
||||
* Accept `res` as argument to `parse`
|
||||
* Parse media type with extra LWS between type and first parameter
|
||||
|
||||
0.0.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* Initial implementation
|
||||
22
backend/node_modules/multer/node_modules/media-typer/LICENSE
generated
vendored
Normal file
22
backend/node_modules/multer/node_modules/media-typer/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
81
backend/node_modules/multer/node_modules/media-typer/README.md
generated
vendored
Normal file
81
backend/node_modules/multer/node_modules/media-typer/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
# media-typer
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Simple RFC 6838 media type parser
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install media-typer
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var typer = require('media-typer')
|
||||
```
|
||||
|
||||
### typer.parse(string)
|
||||
|
||||
```js
|
||||
var obj = typer.parse('image/svg+xml; charset=utf-8')
|
||||
```
|
||||
|
||||
Parse a media type string. This will return an object with the following
|
||||
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
||||
|
||||
- `type`: The type of the media type (always lower case). Example: `'image'`
|
||||
|
||||
- `subtype`: The subtype of the media type (always lower case). Example: `'svg'`
|
||||
|
||||
- `suffix`: The suffix of the media type (always lower case). Example: `'xml'`
|
||||
|
||||
- `parameters`: An object of the parameters in the media type (name of parameter always lower case). Example: `{charset: 'utf-8'}`
|
||||
|
||||
### typer.parse(req)
|
||||
|
||||
```js
|
||||
var obj = typer.parse(req)
|
||||
```
|
||||
|
||||
Parse the `content-type` header from the given `req`. Short-cut for
|
||||
`typer.parse(req.headers['content-type'])`.
|
||||
|
||||
### typer.parse(res)
|
||||
|
||||
```js
|
||||
var obj = typer.parse(res)
|
||||
```
|
||||
|
||||
Parse the `content-type` header set on the given `res`. Short-cut for
|
||||
`typer.parse(res.getHeader('content-type'))`.
|
||||
|
||||
### typer.format(obj)
|
||||
|
||||
```js
|
||||
var obj = typer.format({type: 'image', subtype: 'svg', suffix: 'xml'})
|
||||
```
|
||||
|
||||
Format an object into a media type string. This will return a string of the
|
||||
mime type for the given object. For the properties of the object, see the
|
||||
documentation for `typer.parse(string)`.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/media-typer
|
||||
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/media-typer
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/media-typer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/media-typer
|
||||
270
backend/node_modules/multer/node_modules/media-typer/index.js
generated
vendored
Normal file
270
backend/node_modules/multer/node_modules/media-typer/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,270 @@
|
|||
/*!
|
||||
* media-typer
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7
|
||||
*
|
||||
* parameter = token "=" ( token | quoted-string )
|
||||
* token = 1*<any CHAR except CTLs or separators>
|
||||
* separators = "(" | ")" | "<" | ">" | "@"
|
||||
* | "," | ";" | ":" | "\" | <">
|
||||
* | "/" | "[" | "]" | "?" | "="
|
||||
* | "{" | "}" | SP | HT
|
||||
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
||||
* qdtext = <any TEXT except <">>
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
* TEXT = <any OCTET except CTLs, but including LWS>
|
||||
* LWS = [CRLF] 1*( SP | HT )
|
||||
* CRLF = CR LF
|
||||
* CR = <US-ASCII CR, carriage return (13)>
|
||||
* LF = <US-ASCII LF, linefeed (10)>
|
||||
* SP = <US-ASCII SP, space (32)>
|
||||
* SHT = <US-ASCII HT, horizontal-tab (9)>
|
||||
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||
* OCTET = <any 8-bit sequence of data>
|
||||
*/
|
||||
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g;
|
||||
var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/
|
||||
var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
|
||||
|
||||
/**
|
||||
* RegExp to match quoted-pair in RFC 2616
|
||||
*
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
*/
|
||||
var qescRegExp = /\\([\u0000-\u007f])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match chars that must be quoted-pair in RFC 2616
|
||||
*/
|
||||
var quoteRegExp = /([\\"])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match type in RFC 6838
|
||||
*
|
||||
* type-name = restricted-name
|
||||
* subtype-name = restricted-name
|
||||
* restricted-name = restricted-name-first *126restricted-name-chars
|
||||
* restricted-name-first = ALPHA / DIGIT
|
||||
* restricted-name-chars = ALPHA / DIGIT / "!" / "#" /
|
||||
* "$" / "&" / "-" / "^" / "_"
|
||||
* restricted-name-chars =/ "." ; Characters before first dot always
|
||||
* ; specify a facet name
|
||||
* restricted-name-chars =/ "+" ; Characters after last plus always
|
||||
* ; specify a structured syntax suffix
|
||||
* ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
|
||||
* DIGIT = %x30-39 ; 0-9
|
||||
*/
|
||||
var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/
|
||||
var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/
|
||||
var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
exports.format = format
|
||||
exports.parse = parse
|
||||
|
||||
/**
|
||||
* Format object to media type.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @return {string}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function format(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
throw new TypeError('argument obj is required')
|
||||
}
|
||||
|
||||
var parameters = obj.parameters
|
||||
var subtype = obj.subtype
|
||||
var suffix = obj.suffix
|
||||
var type = obj.type
|
||||
|
||||
if (!type || !typeNameRegExp.test(type)) {
|
||||
throw new TypeError('invalid type')
|
||||
}
|
||||
|
||||
if (!subtype || !subtypeNameRegExp.test(subtype)) {
|
||||
throw new TypeError('invalid subtype')
|
||||
}
|
||||
|
||||
// format as type/subtype
|
||||
var string = type + '/' + subtype
|
||||
|
||||
// append +suffix
|
||||
if (suffix) {
|
||||
if (!typeNameRegExp.test(suffix)) {
|
||||
throw new TypeError('invalid suffix')
|
||||
}
|
||||
|
||||
string += '+' + suffix
|
||||
}
|
||||
|
||||
// append parameters
|
||||
if (parameters && typeof parameters === 'object') {
|
||||
var param
|
||||
var params = Object.keys(parameters).sort()
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
param = params[i]
|
||||
|
||||
if (!tokenRegExp.test(param)) {
|
||||
throw new TypeError('invalid parameter name')
|
||||
}
|
||||
|
||||
string += '; ' + param + '=' + qstring(parameters[param])
|
||||
}
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse media type to object.
|
||||
*
|
||||
* @param {string|object} string
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function parse(string) {
|
||||
if (!string) {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
// support req/res-like objects as argument
|
||||
if (typeof string === 'object') {
|
||||
string = getcontenttype(string)
|
||||
}
|
||||
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required to be a string')
|
||||
}
|
||||
|
||||
var index = string.indexOf(';')
|
||||
var type = index !== -1
|
||||
? string.substr(0, index)
|
||||
: string
|
||||
|
||||
var key
|
||||
var match
|
||||
var obj = splitType(type)
|
||||
var params = {}
|
||||
var value
|
||||
|
||||
paramRegExp.lastIndex = index
|
||||
|
||||
while (match = paramRegExp.exec(string)) {
|
||||
if (match.index !== index) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
index += match[0].length
|
||||
key = match[1].toLowerCase()
|
||||
value = match[2]
|
||||
|
||||
if (value[0] === '"') {
|
||||
// remove quotes and escapes
|
||||
value = value
|
||||
.substr(1, value.length - 2)
|
||||
.replace(qescRegExp, '$1')
|
||||
}
|
||||
|
||||
params[key] = value
|
||||
}
|
||||
|
||||
if (index !== -1 && index !== string.length) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
obj.parameters = params
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content-type from req/res objects.
|
||||
*
|
||||
* @param {object}
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getcontenttype(obj) {
|
||||
if (typeof obj.getHeader === 'function') {
|
||||
// res-like
|
||||
return obj.getHeader('content-type')
|
||||
}
|
||||
|
||||
if (typeof obj.headers === 'object') {
|
||||
// req-like
|
||||
return obj.headers && obj.headers['content-type']
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote a string if necessary.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function qstring(val) {
|
||||
var str = String(val)
|
||||
|
||||
// no need to quote tokens
|
||||
if (tokenRegExp.test(str)) {
|
||||
return str
|
||||
}
|
||||
|
||||
if (str.length > 0 && !textRegExp.test(str)) {
|
||||
throw new TypeError('invalid parameter value')
|
||||
}
|
||||
|
||||
return '"' + str.replace(quoteRegExp, '\\$1') + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply "type/subtype+siffx" into parts.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function splitType(string) {
|
||||
var match = typeRegExp.exec(string.toLowerCase())
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid media type')
|
||||
}
|
||||
|
||||
var type = match[1]
|
||||
var subtype = match[2]
|
||||
var suffix
|
||||
|
||||
// suffix after last +
|
||||
var index = subtype.lastIndexOf('+')
|
||||
if (index !== -1) {
|
||||
suffix = subtype.substr(index + 1)
|
||||
subtype = subtype.substr(0, index)
|
||||
}
|
||||
|
||||
var obj = {
|
||||
type: type,
|
||||
subtype: subtype,
|
||||
suffix: suffix
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
||||
26
backend/node_modules/multer/node_modules/media-typer/package.json
generated
vendored
Normal file
26
backend/node_modules/multer/node_modules/media-typer/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "media-typer",
|
||||
"description": "Simple RFC 6838 media type parser and formatter",
|
||||
"version": "0.3.0",
|
||||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/media-typer",
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4",
|
||||
"should": "~4.0.4"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
|
||||
}
|
||||
}
|
||||
507
backend/node_modules/multer/node_modules/mime-db/HISTORY.md
generated
vendored
Normal file
507
backend/node_modules/multer/node_modules/mime-db/HISTORY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,507 @@
|
|||
1.52.0 / 2022-02-21
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for more `image/*` types
|
||||
* Add extension `.asc` to `application/pgp-keys`
|
||||
* Add extensions to various XML types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.51.0 / 2021-11-08
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Mark `image/vnd.microsoft.icon` as compressible
|
||||
* Mark `image/vnd.ms-dds` as compressible
|
||||
|
||||
1.50.0 / 2021-09-15
|
||||
===================
|
||||
|
||||
* Add deprecated iWorks mime types and extensions
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.49.0 / 2021-07-26
|
||||
===================
|
||||
|
||||
* Add extension `.trig` to `application/trig`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.48.0 / 2021-05-30
|
||||
===================
|
||||
|
||||
* Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
|
||||
* Add new upstream MIME types
|
||||
* Mark `text/yaml` as compressible
|
||||
|
||||
1.47.0 / 2021-04-01
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Remove ambigious extensions from IANA for `application/*+xml` types
|
||||
* Update primary extension to `.es` for `application/ecmascript`
|
||||
|
||||
1.46.0 / 2021-02-13
|
||||
===================
|
||||
|
||||
* Add extension `.amr` to `audio/amr`
|
||||
* Add extension `.m4s` to `video/iso.segment`
|
||||
* Add extension `.opus` to `audio/ogg`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.45.0 / 2020-09-22
|
||||
===================
|
||||
|
||||
* Add `application/ubjson` with extension `.ubj`
|
||||
* Add `image/avif` with extension `.avif`
|
||||
* Add `image/ktx2` with extension `.ktx2`
|
||||
* Add extension `.dbf` to `application/vnd.dbf`
|
||||
* Add extension `.rar` to `application/vnd.rar`
|
||||
* Add extension `.td` to `application/urc-targetdesc+xml`
|
||||
* Add new upstream MIME types
|
||||
* Fix extension of `application/vnd.apple.keynote` to be `.key`
|
||||
|
||||
1.44.0 / 2020-04-22
|
||||
===================
|
||||
|
||||
* Add charsets from IANA
|
||||
* Add extension `.cjs` to `application/node`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.43.0 / 2020-01-05
|
||||
===================
|
||||
|
||||
* Add `application/x-keepass2` with extension `.kdbx`
|
||||
* Add extension `.mxmf` to `audio/mobile-xmf`
|
||||
* Add extensions from IANA for `application/*+xml` types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.42.0 / 2019-09-25
|
||||
===================
|
||||
|
||||
* Add `image/vnd.ms-dds` with extension `.dds`
|
||||
* Add new upstream MIME types
|
||||
* Remove compressible from `multipart/mixed`
|
||||
|
||||
1.41.0 / 2019-08-30
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add `application/toml` with extension `.toml`
|
||||
* Mark `font/ttf` as compressible
|
||||
|
||||
1.40.0 / 2019-04-20
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for `model/*` types
|
||||
* Add `text/mdx` with extension `.mdx`
|
||||
|
||||
1.39.0 / 2019-04-04
|
||||
===================
|
||||
|
||||
* Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.38.0 / 2019-02-04
|
||||
===================
|
||||
|
||||
* Add extension `.nq` to `application/n-quads`
|
||||
* Add extension `.nt` to `application/n-triples`
|
||||
* Add new upstream MIME types
|
||||
* Mark `text/less` as compressible
|
||||
|
||||
1.37.0 / 2018-10-19
|
||||
===================
|
||||
|
||||
* Add extensions to HEIC image types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.36.0 / 2018-08-20
|
||||
===================
|
||||
|
||||
* Add Apple file extensions from IANA
|
||||
* Add extensions from IANA for `image/*` types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.35.0 / 2018-07-15
|
||||
===================
|
||||
|
||||
* Add extension `.owl` to `application/rdf+xml`
|
||||
* Add new upstream MIME types
|
||||
- Removes extension `.woff` from `application/font-woff`
|
||||
|
||||
1.34.0 / 2018-06-03
|
||||
===================
|
||||
|
||||
* Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
* Add extension `.es` to `application/ecmascript`
|
||||
* Add new upstream MIME types
|
||||
* Add `UTF-8` as default charset for `text/turtle`
|
||||
* Mark all XML-derived types as compressible
|
||||
|
||||
1.33.0 / 2018-02-15
|
||||
===================
|
||||
|
||||
* Add extensions from IANA for `message/*` types
|
||||
* Add new upstream MIME types
|
||||
* Fix some incorrect OOXML types
|
||||
* Remove `application/font-woff2`
|
||||
|
||||
1.32.0 / 2017-11-29
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Update `text/hjson` to registered `application/hjson`
|
||||
* Add `text/shex` with extension `.shex`
|
||||
|
||||
1.31.0 / 2017-10-25
|
||||
===================
|
||||
|
||||
* Add `application/raml+yaml` with extension `.raml`
|
||||
* Add `application/wasm` with extension `.wasm`
|
||||
* Add new `font` type from IANA
|
||||
* Add new upstream font extensions
|
||||
* Add new upstream MIME types
|
||||
* Add extensions for JPEG-2000 images
|
||||
|
||||
1.30.0 / 2017-08-27
|
||||
===================
|
||||
|
||||
* Add `application/vnd.ms-outlook`
|
||||
* Add `application/x-arj`
|
||||
* Add extension `.mjs` to `application/javascript`
|
||||
* Add glTF types and extensions
|
||||
* Add new upstream MIME types
|
||||
* Add `text/x-org`
|
||||
* Add VirtualBox MIME types
|
||||
* Fix `source` records for `video/*` types that are IANA
|
||||
* Update `font/opentype` to registered `font/otf`
|
||||
|
||||
1.29.0 / 2017-07-10
|
||||
===================
|
||||
|
||||
* Add `application/fido.trusted-apps+json`
|
||||
* Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
* Add new upstream MIME types
|
||||
* Add `UTF-8` as default charset for `text/css`
|
||||
|
||||
1.28.0 / 2017-05-14
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.gz` to `application/gzip`
|
||||
* Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
|
||||
1.27.0 / 2017-03-16
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add `image/apng` with extension `.apng`
|
||||
|
||||
1.26.0 / 2017-01-14
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.geojson` to `application/geo+json`
|
||||
|
||||
1.25.0 / 2016-11-11
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.24.0 / 2016-09-18
|
||||
===================
|
||||
|
||||
* Add `audio/mp3`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.23.0 / 2016-05-01
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
* Add extension `.3gpp` to `audio/3gpp`
|
||||
|
||||
1.22.0 / 2016-02-15
|
||||
===================
|
||||
|
||||
* Add `text/slim`
|
||||
* Add extension `.rng` to `application/xml`
|
||||
* Add new upstream MIME types
|
||||
* Fix extension of `application/dash+xml` to be `.mpd`
|
||||
* Update primary extension to `.m4a` for `audio/mp4`
|
||||
|
||||
1.21.0 / 2016-01-06
|
||||
===================
|
||||
|
||||
* Add Google document types
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.20.0 / 2015-11-10
|
||||
===================
|
||||
|
||||
* Add `text/x-suse-ymp`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.19.0 / 2015-09-17
|
||||
===================
|
||||
|
||||
* Add `application/vnd.apple.pkpass`
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.18.0 / 2015-09-03
|
||||
===================
|
||||
|
||||
* Add new upstream MIME types
|
||||
|
||||
1.17.0 / 2015-08-13
|
||||
===================
|
||||
|
||||
* Add `application/x-msdos-program`
|
||||
* Add `audio/g711-0`
|
||||
* Add `image/vnd.mozilla.apng`
|
||||
* Add extension `.exe` to `application/x-msdos-program`
|
||||
|
||||
1.16.0 / 2015-07-29
|
||||
===================
|
||||
|
||||
* Add `application/vnd.uri-map`
|
||||
|
||||
1.15.0 / 2015-07-13
|
||||
===================
|
||||
|
||||
* Add `application/x-httpd-php`
|
||||
|
||||
1.14.0 / 2015-06-25
|
||||
===================
|
||||
|
||||
* Add `application/scim+json`
|
||||
* Add `application/vnd.3gpp.ussd+xml`
|
||||
* Add `application/vnd.biopax.rdf+xml`
|
||||
* Add `text/x-processing`
|
||||
|
||||
1.13.0 / 2015-06-07
|
||||
===================
|
||||
|
||||
* Add nginx as a source
|
||||
* Add `application/x-cocoa`
|
||||
* Add `application/x-java-archive-diff`
|
||||
* Add `application/x-makeself`
|
||||
* Add `application/x-perl`
|
||||
* Add `application/x-pilot`
|
||||
* Add `application/x-redhat-package-manager`
|
||||
* Add `application/x-sea`
|
||||
* Add `audio/x-m4a`
|
||||
* Add `audio/x-realaudio`
|
||||
* Add `image/x-jng`
|
||||
* Add `text/mathml`
|
||||
|
||||
1.12.0 / 2015-06-05
|
||||
===================
|
||||
|
||||
* Add `application/bdoc`
|
||||
* Add `application/vnd.hyperdrive+json`
|
||||
* Add `application/x-bdoc`
|
||||
* Add extension `.rtf` to `text/rtf`
|
||||
|
||||
1.11.0 / 2015-05-31
|
||||
===================
|
||||
|
||||
* Add `audio/wav`
|
||||
* Add `audio/wave`
|
||||
* Add extension `.litcoffee` to `text/coffeescript`
|
||||
* Add extension `.sfd-hdstx` to `application/vnd.hydrostatix.sof-data`
|
||||
* Add extension `.n-gage` to `application/vnd.nokia.n-gage.symbian.install`
|
||||
|
||||
1.10.0 / 2015-05-19
|
||||
===================
|
||||
|
||||
* Add `application/vnd.balsamiq.bmpr`
|
||||
* Add `application/vnd.microsoft.portable-executable`
|
||||
* Add `application/x-ns-proxy-autoconfig`
|
||||
|
||||
1.9.1 / 2015-04-19
|
||||
==================
|
||||
|
||||
* Remove `.json` extension from `application/manifest+json`
|
||||
- This is causing bugs downstream
|
||||
|
||||
1.9.0 / 2015-04-19
|
||||
==================
|
||||
|
||||
* Add `application/manifest+json`
|
||||
* Add `application/vnd.micro+json`
|
||||
* Add `image/vnd.zbrush.pcx`
|
||||
* Add `image/x-ms-bmp`
|
||||
|
||||
1.8.0 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Add `application/vnd.citationstyles.style+xml`
|
||||
* Add `application/vnd.fastcopy-disk-image`
|
||||
* Add `application/vnd.gov.sk.xmldatacontainer+xml`
|
||||
* Add extension `.jsonld` to `application/ld+json`
|
||||
|
||||
1.7.0 / 2015-02-08
|
||||
==================
|
||||
|
||||
* Add `application/vnd.gerber`
|
||||
* Add `application/vnd.msa-disk-image`
|
||||
|
||||
1.6.1 / 2015-02-05
|
||||
==================
|
||||
|
||||
* Community extensions ownership transferred from `node-mime`
|
||||
|
||||
1.6.0 / 2015-01-29
|
||||
==================
|
||||
|
||||
* Add `application/jose`
|
||||
* Add `application/jose+json`
|
||||
* Add `application/json-seq`
|
||||
* Add `application/jwk+json`
|
||||
* Add `application/jwk-set+json`
|
||||
* Add `application/jwt`
|
||||
* Add `application/rdap+json`
|
||||
* Add `application/vnd.gov.sk.e-form+xml`
|
||||
* Add `application/vnd.ims.imsccv1p3`
|
||||
|
||||
1.5.0 / 2014-12-30
|
||||
==================
|
||||
|
||||
* Add `application/vnd.oracle.resource+json`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/mbox+xml`
|
||||
- `application/oscp-response`
|
||||
- `application/vwg-multiplexed`
|
||||
- `audio/g721`
|
||||
|
||||
1.4.0 / 2014-12-21
|
||||
==================
|
||||
|
||||
* Add `application/vnd.ims.imsccv1p2`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/vnd-acucobol`
|
||||
- `application/vnd-curl`
|
||||
- `application/vnd-dart`
|
||||
- `application/vnd-dxr`
|
||||
- `application/vnd-fdf`
|
||||
- `application/vnd-mif`
|
||||
- `application/vnd-sema`
|
||||
- `application/vnd-wap-wmlc`
|
||||
- `application/vnd.adobe.flash-movie`
|
||||
- `application/vnd.dece-zip`
|
||||
- `application/vnd.dvb_service`
|
||||
- `application/vnd.micrografx-igx`
|
||||
- `application/vnd.sealed-doc`
|
||||
- `application/vnd.sealed-eml`
|
||||
- `application/vnd.sealed-mht`
|
||||
- `application/vnd.sealed-ppt`
|
||||
- `application/vnd.sealed-tiff`
|
||||
- `application/vnd.sealed-xls`
|
||||
- `application/vnd.sealedmedia.softseal-html`
|
||||
- `application/vnd.sealedmedia.softseal-pdf`
|
||||
- `application/vnd.wap-slc`
|
||||
- `application/vnd.wap-wbxml`
|
||||
- `audio/vnd.sealedmedia.softseal-mpeg`
|
||||
- `image/vnd-djvu`
|
||||
- `image/vnd-svf`
|
||||
- `image/vnd-wap-wbmp`
|
||||
- `image/vnd.sealed-png`
|
||||
- `image/vnd.sealedmedia.softseal-gif`
|
||||
- `image/vnd.sealedmedia.softseal-jpg`
|
||||
- `model/vnd-dwf`
|
||||
- `model/vnd.parasolid.transmit-binary`
|
||||
- `model/vnd.parasolid.transmit-text`
|
||||
- `text/vnd-a`
|
||||
- `text/vnd-curl`
|
||||
- `text/vnd.wap-wml`
|
||||
* Remove example template MIME types
|
||||
- `application/example`
|
||||
- `audio/example`
|
||||
- `image/example`
|
||||
- `message/example`
|
||||
- `model/example`
|
||||
- `multipart/example`
|
||||
- `text/example`
|
||||
- `video/example`
|
||||
|
||||
1.3.1 / 2014-12-16
|
||||
==================
|
||||
|
||||
* Fix missing extensions
|
||||
- `application/json5`
|
||||
- `text/hjson`
|
||||
|
||||
1.3.0 / 2014-12-07
|
||||
==================
|
||||
|
||||
* Add `application/a2l`
|
||||
* Add `application/aml`
|
||||
* Add `application/atfx`
|
||||
* Add `application/atxml`
|
||||
* Add `application/cdfx+xml`
|
||||
* Add `application/dii`
|
||||
* Add `application/json5`
|
||||
* Add `application/lxf`
|
||||
* Add `application/mf4`
|
||||
* Add `application/vnd.apache.thrift.compact`
|
||||
* Add `application/vnd.apache.thrift.json`
|
||||
* Add `application/vnd.coffeescript`
|
||||
* Add `application/vnd.enphase.envoy`
|
||||
* Add `application/vnd.ims.imsccv1p1`
|
||||
* Add `text/csv-schema`
|
||||
* Add `text/hjson`
|
||||
* Add `text/markdown`
|
||||
* Add `text/yaml`
|
||||
|
||||
1.2.0 / 2014-11-09
|
||||
==================
|
||||
|
||||
* Add `application/cea`
|
||||
* Add `application/dit`
|
||||
* Add `application/vnd.gov.sk.e-form+zip`
|
||||
* Add `application/vnd.tmd.mediaflex.api+xml`
|
||||
* Type `application/epub+zip` is now IANA-registered
|
||||
|
||||
1.1.2 / 2014-10-23
|
||||
==================
|
||||
|
||||
* Rebuild database for `application/x-www-form-urlencoded` change
|
||||
|
||||
1.1.1 / 2014-10-20
|
||||
==================
|
||||
|
||||
* Mark `application/x-www-form-urlencoded` as compressible.
|
||||
|
||||
1.1.0 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Add `application/font-woff2`
|
||||
|
||||
1.0.3 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Fix engine requirement in package
|
||||
|
||||
1.0.2 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Add `application/coap-group+json`
|
||||
* Add `application/dcd`
|
||||
* Add `application/vnd.apache.thrift.binary`
|
||||
* Add `image/vnd.tencent.tap`
|
||||
* Mark all JSON-derived types as compressible
|
||||
* Update `text/vtt` data
|
||||
|
||||
1.0.1 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Fix extension ordering
|
||||
|
||||
1.0.0 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Add `application/atf`
|
||||
* Add `application/merge-patch+json`
|
||||
* Add `multipart/x-mixed-replace`
|
||||
* Add `source: 'apache'` metadata
|
||||
* Add `source: 'iana'` metadata
|
||||
* Remove badly-assumed charset data
|
||||
23
backend/node_modules/multer/node_modules/mime-db/LICENSE
generated
vendored
Normal file
23
backend/node_modules/multer/node_modules/mime-db/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015-2022 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
100
backend/node_modules/multer/node_modules/mime-db/README.md
generated
vendored
Normal file
100
backend/node_modules/multer/node_modules/mime-db/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
# mime-db
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
This is a large database of mime types and information about them.
|
||||
It consists of a single, public JSON file and does not include any logic,
|
||||
allowing it to remain as un-opinionated as possible with an API.
|
||||
It aggregates data from the following sources:
|
||||
|
||||
- http://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
- http://hg.nginx.org/nginx/raw-file/default/conf/mime.types
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install mime-db
|
||||
```
|
||||
|
||||
### Database Download
|
||||
|
||||
If you're crazy enough to use this in the browser, you can just grab the
|
||||
JSON file using [jsDelivr](https://www.jsdelivr.com/). It is recommended to
|
||||
replace `master` with [a release tag](https://github.com/jshttp/mime-db/tags)
|
||||
as the JSON format may change in the future.
|
||||
|
||||
```
|
||||
https://cdn.jsdelivr.net/gh/jshttp/mime-db@master/db.json
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var db = require('mime-db')
|
||||
|
||||
// grab data on .js files
|
||||
var data = db['application/javascript']
|
||||
```
|
||||
|
||||
## Data Structure
|
||||
|
||||
The JSON file is a map lookup for lowercased mime types.
|
||||
Each mime type has the following properties:
|
||||
|
||||
- `.source` - where the mime type is defined.
|
||||
If not set, it's probably a custom media type.
|
||||
- `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
|
||||
- `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
|
||||
- `nginx` - [nginx media types](http://hg.nginx.org/nginx/raw-file/default/conf/mime.types)
|
||||
- `.extensions[]` - known extensions associated with this mime type.
|
||||
- `.compressible` - whether a file of this type can be gzipped.
|
||||
- `.charset` - the default charset associated with this type, if any.
|
||||
|
||||
If unknown, every property could be `undefined`.
|
||||
|
||||
## Contributing
|
||||
|
||||
To edit the database, only make PRs against `src/custom-types.json` or
|
||||
`src/custom-suffix.json`.
|
||||
|
||||
The `src/custom-types.json` file is a JSON object with the MIME type as the
|
||||
keys and the values being an object with the following keys:
|
||||
|
||||
- `compressible` - leave out if you don't know, otherwise `true`/`false` to
|
||||
indicate whether the data represented by the type is typically compressible.
|
||||
- `extensions` - include an array of file extensions that are associated with
|
||||
the type.
|
||||
- `notes` - human-readable notes about the type, typically what the type is.
|
||||
- `sources` - include an array of URLs of where the MIME type and the associated
|
||||
extensions are sourced from. This needs to be a [primary source](https://en.wikipedia.org/wiki/Primary_source);
|
||||
links to type aggregating sites and Wikipedia are _not acceptable_.
|
||||
|
||||
To update the build, run `npm run build`.
|
||||
|
||||
### Adding Custom Media Types
|
||||
|
||||
The best way to get new media types included in this library is to register
|
||||
them with the IANA. The community registration procedure is outlined in
|
||||
[RFC 6838 section 5](http://tools.ietf.org/html/rfc6838#section-5). Types
|
||||
registered with the IANA are automatically pulled into this library.
|
||||
|
||||
If that is not possible / feasible, they can be added directly here as a
|
||||
"custom" type. To do this, it is required to have a primary source that
|
||||
definitively lists the media type. If an extension is going to be listed as
|
||||
associateed with this media type, the source must definitively link the
|
||||
media type and extension as well.
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-db/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/mime-db/actions?query=workflow%3Aci
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-db/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
|
||||
[node-image]: https://badgen.net/npm/node/mime-db
|
||||
[node-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/mime-db
|
||||
[npm-url]: https://npmjs.org/package/mime-db
|
||||
[npm-version-image]: https://badgen.net/npm/v/mime-db
|
||||
8519
backend/node_modules/multer/node_modules/mime-db/db.json
generated
vendored
Normal file
8519
backend/node_modules/multer/node_modules/mime-db/db.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load diff
12
backend/node_modules/multer/node_modules/mime-db/index.js
generated
vendored
Normal file
12
backend/node_modules/multer/node_modules/mime-db/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/*!
|
||||
* mime-db
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = require('./db.json')
|
||||
60
backend/node_modules/multer/node_modules/mime-db/package.json
generated
vendored
Normal file
60
backend/node_modules/multer/node_modules/mime-db/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "mime-db",
|
||||
"description": "Media Type Database",
|
||||
"version": "1.52.0",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)",
|
||||
"Robert Kieffer <robert@broofa.com> (http://github.com/broofa)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"db",
|
||||
"type",
|
||||
"types",
|
||||
"database",
|
||||
"charset",
|
||||
"charsets"
|
||||
],
|
||||
"repository": "jshttp/mime-db",
|
||||
"devDependencies": {
|
||||
"bluebird": "3.7.2",
|
||||
"co": "4.6.0",
|
||||
"cogent": "1.0.1",
|
||||
"csv-parse": "4.16.3",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "15.0.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "5.1.1",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"gnode": "0.1.2",
|
||||
"media-typer": "1.1.0",
|
||||
"mocha": "9.2.1",
|
||||
"nyc": "15.1.0",
|
||||
"raw-body": "2.5.0",
|
||||
"stream-to-array": "2.3.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"db.json",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build",
|
||||
"fetch": "node scripts/fetch-apache && gnode scripts/fetch-iana && node scripts/fetch-nginx",
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"update": "npm run fetch && npm run build",
|
||||
"version": "node scripts/version-history.js && git add HISTORY.md"
|
||||
}
|
||||
}
|
||||
397
backend/node_modules/multer/node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
397
backend/node_modules/multer/node_modules/mime-types/HISTORY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,397 @@
|
|||
2.1.35 / 2022-03-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.52.0
|
||||
- Add extensions from IANA for more `image/*` types
|
||||
- Add extension `.asc` to `application/pgp-keys`
|
||||
- Add extensions to various XML types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.34 / 2021-11-08
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.51.0
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.33 / 2021-10-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.50.0
|
||||
- Add deprecated iWorks mime types and extensions
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.32 / 2021-07-27
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.49.0
|
||||
- Add extension `.trig` to `application/trig`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.31 / 2021-06-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.48.0
|
||||
- Add extension `.mvt` to `application/vnd.mapbox-vector-tile`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.30 / 2021-04-02
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.47.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Remove ambigious extensions from IANA for `application/*+xml` types
|
||||
- Update primary extension to `.es` for `application/ecmascript`
|
||||
|
||||
2.1.29 / 2021-02-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.46.0
|
||||
- Add extension `.amr` to `audio/amr`
|
||||
- Add extension `.m4s` to `video/iso.segment`
|
||||
- Add extension `.opus` to `audio/ogg`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.28 / 2021-01-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.45.0
|
||||
- Add `application/ubjson` with extension `.ubj`
|
||||
- Add `image/avif` with extension `.avif`
|
||||
- Add `image/ktx2` with extension `.ktx2`
|
||||
- Add extension `.dbf` to `application/vnd.dbf`
|
||||
- Add extension `.rar` to `application/vnd.rar`
|
||||
- Add extension `.td` to `application/urc-targetdesc+xml`
|
||||
- Add new upstream MIME types
|
||||
- Fix extension of `application/vnd.apple.keynote` to be `.key`
|
||||
|
||||
2.1.27 / 2020-04-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.44.0
|
||||
- Add charsets from IANA
|
||||
- Add extension `.cjs` to `application/node`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.26 / 2020-01-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.43.0
|
||||
- Add `application/x-keepass2` with extension `.kdbx`
|
||||
- Add extension `.mxmf` to `audio/mobile-xmf`
|
||||
- Add extensions from IANA for `application/*+xml` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.25 / 2019-11-12
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.42.0
|
||||
- Add new upstream MIME types
|
||||
- Add `application/toml` with extension `.toml`
|
||||
- Add `image/vnd.ms-dds` with extension `.dds`
|
||||
|
||||
2.1.24 / 2019-04-20
|
||||
===================
|
||||
|
||||
* deps: mime-db@1.40.0
|
||||
- Add extensions from IANA for `model/*` types
|
||||
- Add `text/mdx` with extension `.mdx`
|
||||
|
||||
2.1.23 / 2019-04-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.39.0
|
||||
- Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.22 / 2019-02-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.38.0
|
||||
- Add extension `.nq` to `application/n-quads`
|
||||
- Add extension `.nt` to `application/n-triples`
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.21 / 2018-10-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.37.0
|
||||
- Add extensions to HEIC image types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.20 / 2018-08-26
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.36.0
|
||||
- Add Apple file extensions from IANA
|
||||
- Add extensions from IANA for `image/*` types
|
||||
- Add new upstream MIME types
|
||||
|
||||
2.1.19 / 2018-07-17
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.35.0
|
||||
- Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
- Add extension `.es` to `application/ecmascript`
|
||||
- Add extension `.owl` to `application/rdf+xml`
|
||||
- Add new upstream MIME types
|
||||
- Add UTF-8 as default charset for `text/turtle`
|
||||
|
||||
2.1.18 / 2018-02-16
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.33.0
|
||||
- Add `application/raml+yaml` with extension `.raml`
|
||||
- Add `application/wasm` with extension `.wasm`
|
||||
- Add `text/shex` with extension `.shex`
|
||||
- Add extensions for JPEG-2000 images
|
||||
- Add extensions from IANA for `message/*` types
|
||||
- Add new upstream MIME types
|
||||
- Update font MIME types
|
||||
- Update `text/hjson` to registered `application/hjson`
|
||||
|
||||
2.1.17 / 2017-09-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.30.0
|
||||
- Add `application/vnd.ms-outlook`
|
||||
- Add `application/x-arj`
|
||||
- Add extension `.mjs` to `application/javascript`
|
||||
- Add glTF types and extensions
|
||||
- Add new upstream MIME types
|
||||
- Add `text/x-org`
|
||||
- Add VirtualBox MIME types
|
||||
- Fix `source` records for `video/*` types that are IANA
|
||||
- Update `font/opentype` to registered `font/otf`
|
||||
|
||||
2.1.16 / 2017-07-24
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.29.0
|
||||
- Add `application/fido.trusted-apps+json`
|
||||
- Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
- Add extension `.gz` to `application/gzip`
|
||||
- Add new upstream MIME types
|
||||
- Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
|
||||
2.1.15 / 2017-03-23
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.27.0
|
||||
- Add new mime types
|
||||
- Add `image/apng`
|
||||
|
||||
2.1.14 / 2017-01-14
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.26.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.13 / 2016-11-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.25.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.12 / 2016-09-18
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.24.0
|
||||
- Add new mime types
|
||||
- Add `audio/mp3`
|
||||
|
||||
2.1.11 / 2016-05-01
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.23.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.10 / 2016-02-15
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.22.0
|
||||
- Add new mime types
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
|
||||
2.1.9 / 2016-01-06
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.21.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.8 / 2015-11-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.20.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.7 / 2015-09-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.19.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.6 / 2015-09-03
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.18.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.5 / 2015-08-20
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.17.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.4 / 2015-07-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.16.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.3 / 2015-07-13
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.15.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.2 / 2015-06-25
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.14.0
|
||||
- Add new mime types
|
||||
|
||||
2.1.1 / 2015-06-08
|
||||
==================
|
||||
|
||||
* perf: fix deopt during mapping
|
||||
|
||||
2.1.0 / 2015-06-07
|
||||
==================
|
||||
|
||||
* Fix incorrectly treating extension-less file name as extension
|
||||
- i.e. `'path/to/json'` will no longer return `application/json`
|
||||
* Fix `.charset(type)` to accept parameters
|
||||
* Fix `.charset(type)` to match case-insensitive
|
||||
* Improve generation of extension to MIME mapping
|
||||
* Refactor internals for readability and no argument reassignment
|
||||
* Prefer `application/*` MIME types from the same source
|
||||
* Prefer any type over `application/octet-stream`
|
||||
* deps: mime-db@~1.13.0
|
||||
- Add nginx as a source
|
||||
- Add new mime types
|
||||
|
||||
2.0.14 / 2015-06-06
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.12.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.13 / 2015-05-31
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.11.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.12 / 2015-05-19
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.10.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.11 / 2015-05-05
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.9.1
|
||||
- Add new mime types
|
||||
|
||||
2.0.10 / 2015-03-13
|
||||
===================
|
||||
|
||||
* deps: mime-db@~1.8.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.9 / 2015-02-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.7.0
|
||||
- Add new mime types
|
||||
- Community extensions ownership transferred from `node-mime`
|
||||
|
||||
2.0.8 / 2015-01-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.6.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.7 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.5.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
|
||||
2.0.6 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.4.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
|
||||
2.0.5 / 2014-12-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.1
|
||||
- Fix missing extensions
|
||||
|
||||
2.0.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.2.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.2 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.1.0
|
||||
- Add new mime types
|
||||
- Update charsets
|
||||
|
||||
2.0.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
|
||||
2.0.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* Use `mime-db`
|
||||
* Remove `.define()`
|
||||
|
||||
1.0.2 / 2014-08-04
|
||||
==================
|
||||
|
||||
* Set charset=utf-8 for `text/javascript`
|
||||
|
||||
1.0.1 / 2014-06-24
|
||||
==================
|
||||
|
||||
* Add `text/jsx` type
|
||||
|
||||
1.0.0 / 2014-05-12
|
||||
==================
|
||||
|
||||
* Return `false` for unknown types
|
||||
* Set charset=utf-8 for `application/json`
|
||||
|
||||
0.1.0 / 2014-05-02
|
||||
==================
|
||||
|
||||
* Initial release
|
||||
23
backend/node_modules/multer/node_modules/mime-types/LICENSE
generated
vendored
Normal file
23
backend/node_modules/multer/node_modules/mime-types/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
113
backend/node_modules/multer/node_modules/mime-types/README.md
generated
vendored
Normal file
113
backend/node_modules/multer/node_modules/mime-types/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
# mime-types
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][ci-image]][ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
The ultimate javascript content-type utility.
|
||||
|
||||
Similar to [the `mime@1.x` module](https://www.npmjs.com/package/mime), except:
|
||||
|
||||
- __No fallbacks.__ Instead of naively returning the first available type,
|
||||
`mime-types` simply returns `false`, so do
|
||||
`var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
|
||||
- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
|
||||
- No `.define()` functionality
|
||||
- Bug fixes for `.lookup(path)`
|
||||
|
||||
Otherwise, the API is compatible with `mime` 1.x.
|
||||
|
||||
## Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install mime-types
|
||||
```
|
||||
|
||||
## Adding Types
|
||||
|
||||
All mime types are based on [mime-db](https://www.npmjs.com/package/mime-db),
|
||||
so open a PR there if you'd like to add mime types.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var mime = require('mime-types')
|
||||
```
|
||||
|
||||
All functions return `false` if input is invalid or not found.
|
||||
|
||||
### mime.lookup(path)
|
||||
|
||||
Lookup the content-type associated with a file.
|
||||
|
||||
```js
|
||||
mime.lookup('json') // 'application/json'
|
||||
mime.lookup('.md') // 'text/markdown'
|
||||
mime.lookup('file.html') // 'text/html'
|
||||
mime.lookup('folder/file.js') // 'application/javascript'
|
||||
mime.lookup('folder/.htaccess') // false
|
||||
|
||||
mime.lookup('cats') // false
|
||||
```
|
||||
|
||||
### mime.contentType(type)
|
||||
|
||||
Create a full content-type header given a content-type or extension.
|
||||
When given an extension, `mime.lookup` is used to get the matching
|
||||
content-type, otherwise the given content-type is used. Then if the
|
||||
content-type does not already have a `charset` parameter, `mime.charset`
|
||||
is used to get the default charset and add to the returned content-type.
|
||||
|
||||
```js
|
||||
mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
|
||||
mime.contentType('file.json') // 'application/json; charset=utf-8'
|
||||
mime.contentType('text/html') // 'text/html; charset=utf-8'
|
||||
mime.contentType('text/html; charset=iso-8859-1') // 'text/html; charset=iso-8859-1'
|
||||
|
||||
// from a full path
|
||||
mime.contentType(path.extname('/path/to/file.json')) // 'application/json; charset=utf-8'
|
||||
```
|
||||
|
||||
### mime.extension(type)
|
||||
|
||||
Get the default extension for a content-type.
|
||||
|
||||
```js
|
||||
mime.extension('application/octet-stream') // 'bin'
|
||||
```
|
||||
|
||||
### mime.charset(type)
|
||||
|
||||
Lookup the implied default charset of a content-type.
|
||||
|
||||
```js
|
||||
mime.charset('text/markdown') // 'UTF-8'
|
||||
```
|
||||
|
||||
### var type = mime.types[extension]
|
||||
|
||||
A map of content-types by extension.
|
||||
|
||||
### [extensions...] = mime.extensions[type]
|
||||
|
||||
A map of extensions by content-type.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[ci-image]: https://badgen.net/github/checks/jshttp/mime-types/master?label=ci
|
||||
[ci-url]: https://github.com/jshttp/mime-types/actions/workflows/ci.yml
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/mime-types/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-types?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/mime-types
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/mime-types
|
||||
[npm-url]: https://npmjs.org/package/mime-types
|
||||
[npm-version-image]: https://badgen.net/npm/v/mime-types
|
||||
188
backend/node_modules/multer/node_modules/mime-types/index.js
generated
vendored
Normal file
188
backend/node_modules/multer/node_modules/mime-types/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
/*!
|
||||
* mime-types
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var db = require('mime-db')
|
||||
var extname = require('path').extname
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/
|
||||
var TEXT_TYPE_REGEXP = /^text\//i
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports.charset = charset
|
||||
exports.charsets = { lookup: charset }
|
||||
exports.contentType = contentType
|
||||
exports.extension = extension
|
||||
exports.extensions = Object.create(null)
|
||||
exports.lookup = lookup
|
||||
exports.types = Object.create(null)
|
||||
|
||||
// Populate the extensions/types maps
|
||||
populateMaps(exports.extensions, exports.types)
|
||||
|
||||
/**
|
||||
* Get the default charset for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function charset (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
var mime = match && db[match[1].toLowerCase()]
|
||||
|
||||
if (mime && mime.charset) {
|
||||
return mime.charset
|
||||
}
|
||||
|
||||
// default text/* to utf-8
|
||||
if (match && TEXT_TYPE_REGEXP.test(match[1])) {
|
||||
return 'UTF-8'
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a full Content-Type header given a MIME type or extension.
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function contentType (str) {
|
||||
// TODO: should this even be in this module?
|
||||
if (!str || typeof str !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
var mime = str.indexOf('/') === -1
|
||||
? exports.lookup(str)
|
||||
: str
|
||||
|
||||
if (!mime) {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use content-type or other module
|
||||
if (mime.indexOf('charset') === -1) {
|
||||
var charset = exports.charset(mime)
|
||||
if (charset) mime += '; charset=' + charset.toLowerCase()
|
||||
}
|
||||
|
||||
return mime
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default extension for a MIME type.
|
||||
*
|
||||
* @param {string} type
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function extension (type) {
|
||||
if (!type || typeof type !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// TODO: use media-typer
|
||||
var match = EXTRACT_TYPE_REGEXP.exec(type)
|
||||
|
||||
// get extensions
|
||||
var exts = match && exports.extensions[match[1].toLowerCase()]
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
/**
|
||||
* Lookup the MIME type for a file path/extension.
|
||||
*
|
||||
* @param {string} path
|
||||
* @return {boolean|string}
|
||||
*/
|
||||
|
||||
function lookup (path) {
|
||||
if (!path || typeof path !== 'string') {
|
||||
return false
|
||||
}
|
||||
|
||||
// get the extension ("ext" or ".ext" or full path)
|
||||
var extension = extname('x.' + path)
|
||||
.toLowerCase()
|
||||
.substr(1)
|
||||
|
||||
if (!extension) {
|
||||
return false
|
||||
}
|
||||
|
||||
return exports.types[extension] || false
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the extensions and types maps.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function populateMaps (extensions, types) {
|
||||
// source preference (least -> most)
|
||||
var preference = ['nginx', 'apache', undefined, 'iana']
|
||||
|
||||
Object.keys(db).forEach(function forEachMimeType (type) {
|
||||
var mime = db[type]
|
||||
var exts = mime.extensions
|
||||
|
||||
if (!exts || !exts.length) {
|
||||
return
|
||||
}
|
||||
|
||||
// mime -> extensions
|
||||
extensions[type] = exts
|
||||
|
||||
// extension -> mime
|
||||
for (var i = 0; i < exts.length; i++) {
|
||||
var extension = exts[i]
|
||||
|
||||
if (types[extension]) {
|
||||
var from = preference.indexOf(db[types[extension]].source)
|
||||
var to = preference.indexOf(mime.source)
|
||||
|
||||
if (types[extension] !== 'application/octet-stream' &&
|
||||
(from > to || (from === to && types[extension].substr(0, 12) === 'application/'))) {
|
||||
// skip the remapping
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// set the extension -> mime
|
||||
types[extension] = type
|
||||
}
|
||||
})
|
||||
}
|
||||
44
backend/node_modules/multer/node_modules/mime-types/package.json
generated
vendored
Normal file
44
backend/node_modules/multer/node_modules/mime-types/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "mime-types",
|
||||
"description": "The ultimate javascript content-type utility.",
|
||||
"version": "2.1.35",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jeremiah Senkpiel <fishrock123@rocketmail.com> (https://searchbeam.jit.su)",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"types"
|
||||
],
|
||||
"repository": "jshttp/mime-types",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-standard": "14.1.1",
|
||||
"eslint-plugin-import": "2.25.4",
|
||||
"eslint-plugin-markdown": "2.2.1",
|
||||
"eslint-plugin-node": "11.1.0",
|
||||
"eslint-plugin-promise": "5.2.0",
|
||||
"eslint-plugin-standard": "4.1.0",
|
||||
"mocha": "9.2.2",
|
||||
"nyc": "15.1.0"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec test/test.js",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
||||
259
backend/node_modules/multer/node_modules/type-is/HISTORY.md
generated
vendored
Normal file
259
backend/node_modules/multer/node_modules/type-is/HISTORY.md
generated
vendored
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
1.6.18 / 2019-04-26
|
||||
===================
|
||||
|
||||
* Fix regression passing request object to `typeis.is`
|
||||
|
||||
1.6.17 / 2019-04-25
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.24
|
||||
- Add Apple file extensions from IANA
|
||||
- Add extension `.csl` to `application/vnd.citationstyles.style+xml`
|
||||
- Add extension `.es` to `application/ecmascript`
|
||||
- Add extension `.nq` to `application/n-quads`
|
||||
- Add extension `.nt` to `application/n-triples`
|
||||
- Add extension `.owl` to `application/rdf+xml`
|
||||
- Add extensions `.siv` and `.sieve` to `application/sieve`
|
||||
- Add extensions from IANA for `image/*` types
|
||||
- Add extensions from IANA for `model/*` types
|
||||
- Add extensions to HEIC image types
|
||||
- Add new mime types
|
||||
- Add `text/mdx` with extension `.mdx`
|
||||
* perf: prevent internal `throw` on invalid type
|
||||
|
||||
1.6.16 / 2018-02-16
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.18
|
||||
- Add `application/raml+yaml` with extension `.raml`
|
||||
- Add `application/wasm` with extension `.wasm`
|
||||
- Add `text/shex` with extension `.shex`
|
||||
- Add extensions for JPEG-2000 images
|
||||
- Add extensions from IANA for `message/*` types
|
||||
- Add extension `.mjs` to `application/javascript`
|
||||
- Add extension `.wadl` to `application/vnd.sun.wadl+xml`
|
||||
- Add extension `.gz` to `application/gzip`
|
||||
- Add glTF types and extensions
|
||||
- Add new mime types
|
||||
- Update extensions `.md` and `.markdown` to be `text/markdown`
|
||||
- Update font MIME types
|
||||
- Update `text/hjson` to registered `application/hjson`
|
||||
|
||||
1.6.15 / 2017-03-31
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.15
|
||||
- Add new mime types
|
||||
|
||||
1.6.14 / 2016-11-18
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.13
|
||||
- Add new mime types
|
||||
|
||||
1.6.13 / 2016-05-18
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.11
|
||||
- Add new mime types
|
||||
|
||||
1.6.12 / 2016-02-28
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.10
|
||||
- Add new mime types
|
||||
- Fix extension of `application/dash+xml`
|
||||
- Update primary extension for `audio/mp4`
|
||||
|
||||
1.6.11 / 2016-01-29
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.9
|
||||
- Add new mime types
|
||||
|
||||
1.6.10 / 2015-12-01
|
||||
===================
|
||||
|
||||
* deps: mime-types@~2.1.8
|
||||
- Add new mime types
|
||||
|
||||
1.6.9 / 2015-09-27
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.7
|
||||
- Add new mime types
|
||||
|
||||
1.6.8 / 2015-09-04
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.6
|
||||
- Add new mime types
|
||||
|
||||
1.6.7 / 2015-08-20
|
||||
==================
|
||||
|
||||
* Fix type error when given invalid type to match against
|
||||
* deps: mime-types@~2.1.5
|
||||
- Add new mime types
|
||||
|
||||
1.6.6 / 2015-07-31
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.4
|
||||
- Add new mime types
|
||||
|
||||
1.6.5 / 2015-07-16
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.3
|
||||
- Add new mime types
|
||||
|
||||
1.6.4 / 2015-07-01
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.2
|
||||
- Add new mime types
|
||||
* perf: enable strict mode
|
||||
* perf: remove argument reassignment
|
||||
|
||||
1.6.3 / 2015-06-08
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.1.1
|
||||
- Add new mime types
|
||||
* perf: reduce try block size
|
||||
* perf: remove bitwise operations
|
||||
|
||||
1.6.2 / 2015-05-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.11
|
||||
- Add new mime types
|
||||
|
||||
1.6.1 / 2015-03-13
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.10
|
||||
- Add new mime types
|
||||
|
||||
1.6.0 / 2015-02-12
|
||||
==================
|
||||
|
||||
* fix false-positives in `hasBody` `Transfer-Encoding` check
|
||||
* support wildcard for both type and subtype (`*/*`)
|
||||
|
||||
1.5.7 / 2015-02-09
|
||||
==================
|
||||
|
||||
* fix argument reassignment
|
||||
* deps: mime-types@~2.0.9
|
||||
- Add new mime types
|
||||
|
||||
1.5.6 / 2015-01-29
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.8
|
||||
- Add new mime types
|
||||
|
||||
1.5.5 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.7
|
||||
- Add new mime types
|
||||
- Fix missing extensions
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
- deps: mime-db@~1.5.0
|
||||
|
||||
1.5.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.4
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.5.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.3
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.5.2 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.2
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.1.0
|
||||
|
||||
1.5.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* deps: media-typer@0.3.0
|
||||
* deps: mime-types@~2.0.1
|
||||
- Support Node.js 0.6
|
||||
|
||||
1.5.0 / 2014-09-05
|
||||
==================
|
||||
|
||||
* fix `hasbody` to be true for `content-length: 0`
|
||||
|
||||
1.4.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* update mime-types
|
||||
|
||||
1.3.2 / 2014-06-24
|
||||
==================
|
||||
|
||||
* use `~` range on mime-types
|
||||
|
||||
1.3.1 / 2014-06-19
|
||||
==================
|
||||
|
||||
* fix global variable leak
|
||||
|
||||
1.3.0 / 2014-06-19
|
||||
==================
|
||||
|
||||
* improve type parsing
|
||||
|
||||
- invalid media type never matches
|
||||
- media type not case-sensitive
|
||||
- extra LWS does not affect results
|
||||
|
||||
1.2.2 / 2014-06-19
|
||||
==================
|
||||
|
||||
* fix behavior on unknown type argument
|
||||
|
||||
1.2.1 / 2014-06-03
|
||||
==================
|
||||
|
||||
* switch dependency from `mime` to `mime-types@1.0.0`
|
||||
|
||||
1.2.0 / 2014-05-11
|
||||
==================
|
||||
|
||||
* support suffix matching:
|
||||
|
||||
- `+json` matches `application/vnd+json`
|
||||
- `*/vnd+json` matches `application/vnd+json`
|
||||
- `application/*+json` matches `application/vnd+json`
|
||||
|
||||
1.1.0 / 2014-04-12
|
||||
==================
|
||||
|
||||
* add non-array values support
|
||||
* expose internal utilities:
|
||||
|
||||
- `.is()`
|
||||
- `.hasBody()`
|
||||
- `.normalize()`
|
||||
- `.match()`
|
||||
|
||||
1.0.1 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `multipart` as a shorthand
|
||||
23
backend/node_modules/multer/node_modules/type-is/LICENSE
generated
vendored
Normal file
23
backend/node_modules/multer/node_modules/type-is/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
170
backend/node_modules/multer/node_modules/type-is/README.md
generated
vendored
Normal file
170
backend/node_modules/multer/node_modules/type-is/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
# type-is
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Infer the content-type of a request.
|
||||
|
||||
### Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install type-is
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var http = require('http')
|
||||
var typeis = require('type-is')
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
var istext = typeis(req, ['text/*'])
|
||||
res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text')
|
||||
})
|
||||
```
|
||||
|
||||
### typeis(request, types)
|
||||
|
||||
Checks if the `request` is one of the `types`. If the request has no body,
|
||||
even if there is a `Content-Type` header, then `null` is returned. If the
|
||||
`Content-Type` header is invalid or does not matches any of the `types`, then
|
||||
`false` is returned. Otherwise, a string of the type that matched is returned.
|
||||
|
||||
The `request` argument is expected to be a Node.js HTTP request. The `types`
|
||||
argument is an array of type strings.
|
||||
|
||||
Each type in the `types` array can be one of the following:
|
||||
|
||||
- A file extension name such as `json`. This name will be returned if matched.
|
||||
- A mime type such as `application/json`.
|
||||
- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`.
|
||||
The full mime type will be returned if matched.
|
||||
- A suffix such as `+json`. This can be combined with a wildcard such as
|
||||
`*/vnd+json` or `application/*+json`. The full mime type will be returned
|
||||
if matched.
|
||||
|
||||
Some examples to illustrate the inputs and returned value:
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
// req.headers.content-type = 'application/json'
|
||||
|
||||
typeis(req, ['json']) // => 'json'
|
||||
typeis(req, ['html', 'json']) // => 'json'
|
||||
typeis(req, ['application/*']) // => 'application/json'
|
||||
typeis(req, ['application/json']) // => 'application/json'
|
||||
|
||||
typeis(req, ['html']) // => false
|
||||
```
|
||||
|
||||
### typeis.hasBody(request)
|
||||
|
||||
Returns a Boolean if the given `request` has a body, regardless of the
|
||||
`Content-Type` header.
|
||||
|
||||
Having a body has no relation to how large the body is (it may be 0 bytes).
|
||||
This is similar to how file existence works. If a body does exist, then this
|
||||
indicates that there is data to read from the Node.js request stream.
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
if (typeis.hasBody(req)) {
|
||||
// read the body, since there is one
|
||||
|
||||
req.on('data', function (chunk) {
|
||||
// ...
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
### typeis.is(mediaType, types)
|
||||
|
||||
Checks if the `mediaType` is one of the `types`. If the `mediaType` is invalid
|
||||
or does not matches any of the `types`, then `false` is returned. Otherwise, a
|
||||
string of the type that matched is returned.
|
||||
|
||||
The `mediaType` argument is expected to be a
|
||||
[media type](https://tools.ietf.org/html/rfc6838) string. The `types` argument
|
||||
is an array of type strings.
|
||||
|
||||
Each type in the `types` array can be one of the following:
|
||||
|
||||
- A file extension name such as `json`. This name will be returned if matched.
|
||||
- A mime type such as `application/json`.
|
||||
- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`.
|
||||
The full mime type will be returned if matched.
|
||||
- A suffix such as `+json`. This can be combined with a wildcard such as
|
||||
`*/vnd+json` or `application/*+json`. The full mime type will be returned
|
||||
if matched.
|
||||
|
||||
Some examples to illustrate the inputs and returned value:
|
||||
|
||||
<!-- eslint-disable no-undef -->
|
||||
|
||||
```js
|
||||
var mediaType = 'application/json'
|
||||
|
||||
typeis.is(mediaType, ['json']) // => 'json'
|
||||
typeis.is(mediaType, ['html', 'json']) // => 'json'
|
||||
typeis.is(mediaType, ['application/*']) // => 'application/json'
|
||||
typeis.is(mediaType, ['application/json']) // => 'application/json'
|
||||
|
||||
typeis.is(mediaType, ['html']) // => false
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Example body parser
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var typeis = require('type-is')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(function bodyParser (req, res, next) {
|
||||
if (!typeis.hasBody(req)) {
|
||||
return next()
|
||||
}
|
||||
|
||||
switch (typeis(req, ['urlencoded', 'json', 'multipart'])) {
|
||||
case 'urlencoded':
|
||||
// parse urlencoded body
|
||||
throw new Error('implement urlencoded body parsing')
|
||||
case 'json':
|
||||
// parse json body
|
||||
throw new Error('implement json body parsing')
|
||||
case 'multipart':
|
||||
// parse multipart body
|
||||
throw new Error('implement multipart body parsing')
|
||||
default:
|
||||
// 415 error code
|
||||
res.statusCode = 415
|
||||
res.end()
|
||||
break
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/type-is/master
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master
|
||||
[node-version-image]: https://badgen.net/npm/node/type-is
|
||||
[node-version-url]: https://nodejs.org/en/download
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/type-is
|
||||
[npm-url]: https://npmjs.org/package/type-is
|
||||
[npm-version-image]: https://badgen.net/npm/v/type-is
|
||||
[travis-image]: https://badgen.net/travis/jshttp/type-is/master
|
||||
[travis-url]: https://travis-ci.org/jshttp/type-is
|
||||
266
backend/node_modules/multer/node_modules/type-is/index.js
generated
vendored
Normal file
266
backend/node_modules/multer/node_modules/type-is/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,266 @@
|
|||
/*!
|
||||
* type-is
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var typer = require('media-typer')
|
||||
var mime = require('mime-types')
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = typeofrequest
|
||||
module.exports.is = typeis
|
||||
module.exports.hasBody = hasbody
|
||||
module.exports.normalize = normalize
|
||||
module.exports.match = mimeMatch
|
||||
|
||||
/**
|
||||
* Compare a `value` content-type with `types`.
|
||||
* Each `type` can be an extension like `html`,
|
||||
* a special shortcut like `multipart` or `urlencoded`,
|
||||
* or a mime type.
|
||||
*
|
||||
* If no types match, `false` is returned.
|
||||
* Otherwise, the first `type` that matches is returned.
|
||||
*
|
||||
* @param {String} value
|
||||
* @param {Array} types
|
||||
* @public
|
||||
*/
|
||||
|
||||
function typeis (value, types_) {
|
||||
var i
|
||||
var types = types_
|
||||
|
||||
// remove parameters and normalize
|
||||
var val = tryNormalizeType(value)
|
||||
|
||||
// no type or invalid
|
||||
if (!val) {
|
||||
return false
|
||||
}
|
||||
|
||||
// support flattened arguments
|
||||
if (types && !Array.isArray(types)) {
|
||||
types = new Array(arguments.length - 1)
|
||||
for (i = 0; i < types.length; i++) {
|
||||
types[i] = arguments[i + 1]
|
||||
}
|
||||
}
|
||||
|
||||
// no types, return the content type
|
||||
if (!types || !types.length) {
|
||||
return val
|
||||
}
|
||||
|
||||
var type
|
||||
for (i = 0; i < types.length; i++) {
|
||||
if (mimeMatch(normalize(type = types[i]), val)) {
|
||||
return type[0] === '+' || type.indexOf('*') !== -1
|
||||
? val
|
||||
: type
|
||||
}
|
||||
}
|
||||
|
||||
// no matches
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a request has a request body.
|
||||
* A request with a body __must__ either have `transfer-encoding`
|
||||
* or `content-length` headers set.
|
||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
|
||||
*
|
||||
* @param {Object} request
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function hasbody (req) {
|
||||
return req.headers['transfer-encoding'] !== undefined ||
|
||||
!isNaN(req.headers['content-length'])
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the incoming request contains the "Content-Type"
|
||||
* header field, and it contains any of the give mime `type`s.
|
||||
* If there is no request body, `null` is returned.
|
||||
* If there is no content type, `false` is returned.
|
||||
* Otherwise, it returns the first `type` that matches.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // With Content-Type: text/html; charset=utf-8
|
||||
* this.is('html'); // => 'html'
|
||||
* this.is('text/html'); // => 'text/html'
|
||||
* this.is('text/*', 'application/json'); // => 'text/html'
|
||||
*
|
||||
* // When Content-Type is application/json
|
||||
* this.is('json', 'urlencoded'); // => 'json'
|
||||
* this.is('application/json'); // => 'application/json'
|
||||
* this.is('html', 'application/*'); // => 'application/json'
|
||||
*
|
||||
* this.is('html'); // => false
|
||||
*
|
||||
* @param {String|Array} types...
|
||||
* @return {String|false|null}
|
||||
* @public
|
||||
*/
|
||||
|
||||
function typeofrequest (req, types_) {
|
||||
var types = types_
|
||||
|
||||
// no body
|
||||
if (!hasbody(req)) {
|
||||
return null
|
||||
}
|
||||
|
||||
// support flattened arguments
|
||||
if (arguments.length > 2) {
|
||||
types = new Array(arguments.length - 1)
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
types[i] = arguments[i + 1]
|
||||
}
|
||||
}
|
||||
|
||||
// request content type
|
||||
var value = req.headers['content-type']
|
||||
|
||||
return typeis(value, types)
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a mime type.
|
||||
* If it's a shorthand, expand it to a valid mime type.
|
||||
*
|
||||
* In general, you probably want:
|
||||
*
|
||||
* var type = is(req, ['urlencoded', 'json', 'multipart']);
|
||||
*
|
||||
* Then use the appropriate body parsers.
|
||||
* These three are the most common request body types
|
||||
* and are thus ensured to work.
|
||||
*
|
||||
* @param {String} type
|
||||
* @private
|
||||
*/
|
||||
|
||||
function normalize (type) {
|
||||
if (typeof type !== 'string') {
|
||||
// invalid type
|
||||
return false
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case 'urlencoded':
|
||||
return 'application/x-www-form-urlencoded'
|
||||
case 'multipart':
|
||||
return 'multipart/*'
|
||||
}
|
||||
|
||||
if (type[0] === '+') {
|
||||
// "+json" -> "*/*+json" expando
|
||||
return '*/*' + type
|
||||
}
|
||||
|
||||
return type.indexOf('/') === -1
|
||||
? mime.lookup(type)
|
||||
: type
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if `expected` mime type
|
||||
* matches `actual` mime type with
|
||||
* wildcard and +suffix support.
|
||||
*
|
||||
* @param {String} expected
|
||||
* @param {String} actual
|
||||
* @return {Boolean}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function mimeMatch (expected, actual) {
|
||||
// invalid type
|
||||
if (expected === false) {
|
||||
return false
|
||||
}
|
||||
|
||||
// split types
|
||||
var actualParts = actual.split('/')
|
||||
var expectedParts = expected.split('/')
|
||||
|
||||
// invalid format
|
||||
if (actualParts.length !== 2 || expectedParts.length !== 2) {
|
||||
return false
|
||||
}
|
||||
|
||||
// validate type
|
||||
if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
|
||||
return false
|
||||
}
|
||||
|
||||
// validate suffix wildcard
|
||||
if (expectedParts[1].substr(0, 2) === '*+') {
|
||||
return expectedParts[1].length <= actualParts[1].length + 1 &&
|
||||
expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
|
||||
}
|
||||
|
||||
// validate subtype
|
||||
if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a type and remove parameters.
|
||||
*
|
||||
* @param {string} value
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function normalizeType (value) {
|
||||
// parse the type
|
||||
var type = typer.parse(value)
|
||||
|
||||
// remove the parameters
|
||||
type.parameters = undefined
|
||||
|
||||
// reformat it
|
||||
return typer.format(type)
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to normalize a type and remove parameters.
|
||||
*
|
||||
* @param {string} value
|
||||
* @return {string}
|
||||
* @private
|
||||
*/
|
||||
|
||||
function tryNormalizeType (value) {
|
||||
if (!value) {
|
||||
return null
|
||||
}
|
||||
|
||||
try {
|
||||
return normalizeType(value)
|
||||
} catch (err) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
45
backend/node_modules/multer/node_modules/type-is/package.json
generated
vendored
Normal file
45
backend/node_modules/multer/node_modules/type-is/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "type-is",
|
||||
"description": "Infer the content-type of a request.",
|
||||
"version": "1.6.18",
|
||||
"contributors": [
|
||||
"Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "jshttp/type-is",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "5.16.0",
|
||||
"eslint-config-standard": "12.0.0",
|
||||
"eslint-plugin-import": "2.17.2",
|
||||
"eslint-plugin-markdown": "1.0.0",
|
||||
"eslint-plugin-node": "8.0.1",
|
||||
"eslint-plugin-promise": "4.1.1",
|
||||
"eslint-plugin-standard": "4.0.0",
|
||||
"mocha": "6.1.4",
|
||||
"nyc": "14.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint --plugin markdown --ext js,md .",
|
||||
"test": "mocha --reporter spec --check-leaks --bail test/",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test",
|
||||
"test-travis": "nyc --reporter=text npm test"
|
||||
},
|
||||
"keywords": [
|
||||
"content",
|
||||
"type",
|
||||
"checking"
|
||||
]
|
||||
}
|
||||
57
backend/node_modules/multer/package.json
generated
vendored
Normal file
57
backend/node_modules/multer/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "multer",
|
||||
"description": "Middleware for handling `multipart/form-data`.",
|
||||
"version": "2.0.2",
|
||||
"contributors": [
|
||||
"Hage Yaapa <captain@hacksparrow.com> (http://www.hacksparrow.com)",
|
||||
"Jaret Pfluger <https://github.com/jpfluger>",
|
||||
"Linus Unnebäck <linus@folkdatorn.se>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "expressjs/multer",
|
||||
"keywords": [
|
||||
"form",
|
||||
"post",
|
||||
"multipart",
|
||||
"form-data",
|
||||
"formdata",
|
||||
"express",
|
||||
"middleware"
|
||||
],
|
||||
"dependencies": {
|
||||
"append-field": "^1.0.0",
|
||||
"busboy": "^1.6.0",
|
||||
"concat-stream": "^2.0.0",
|
||||
"mkdirp": "^0.5.6",
|
||||
"object-assign": "^4.1.1",
|
||||
"type-is": "^1.6.18",
|
||||
"xtend": "^4.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"deep-equal": "^2.0.3",
|
||||
"express": "^4.21.2",
|
||||
"form-data": "^4.0.2",
|
||||
"fs-temp": "^1.2.1",
|
||||
"mocha": "^11.5.0",
|
||||
"nyc": "^15.1.0",
|
||||
"rimraf": "^2.4.1",
|
||||
"standard": "^14.3.3",
|
||||
"testdata-w3c-json-form": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.16.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"storage/",
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"lint:fix": "standard --fix",
|
||||
"test": "mocha --reporter spec --exit --check-leaks test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
||||
66
backend/node_modules/multer/storage/disk.js
generated
vendored
Normal file
66
backend/node_modules/multer/storage/disk.js
generated
vendored
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
var fs = require('fs')
|
||||
var os = require('os')
|
||||
var path = require('path')
|
||||
var crypto = require('crypto')
|
||||
var mkdirp = require('mkdirp')
|
||||
|
||||
function getFilename (req, file, cb) {
|
||||
crypto.randomBytes(16, function (err, raw) {
|
||||
cb(err, err ? undefined : raw.toString('hex'))
|
||||
})
|
||||
}
|
||||
|
||||
function getDestination (req, file, cb) {
|
||||
cb(null, os.tmpdir())
|
||||
}
|
||||
|
||||
function DiskStorage (opts) {
|
||||
this.getFilename = (opts.filename || getFilename)
|
||||
|
||||
if (typeof opts.destination === 'string') {
|
||||
mkdirp.sync(opts.destination)
|
||||
this.getDestination = function ($0, $1, cb) { cb(null, opts.destination) }
|
||||
} else {
|
||||
this.getDestination = (opts.destination || getDestination)
|
||||
}
|
||||
}
|
||||
|
||||
DiskStorage.prototype._handleFile = function _handleFile (req, file, cb) {
|
||||
var that = this
|
||||
|
||||
that.getDestination(req, file, function (err, destination) {
|
||||
if (err) return cb(err)
|
||||
|
||||
that.getFilename(req, file, function (err, filename) {
|
||||
if (err) return cb(err)
|
||||
|
||||
var finalPath = path.join(destination, filename)
|
||||
var outStream = fs.createWriteStream(finalPath)
|
||||
|
||||
file.stream.pipe(outStream)
|
||||
outStream.on('error', cb)
|
||||
outStream.on('finish', function () {
|
||||
cb(null, {
|
||||
destination: destination,
|
||||
filename: filename,
|
||||
path: finalPath,
|
||||
size: outStream.bytesWritten
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
DiskStorage.prototype._removeFile = function _removeFile (req, file, cb) {
|
||||
var path = file.path
|
||||
|
||||
delete file.destination
|
||||
delete file.filename
|
||||
delete file.path
|
||||
|
||||
fs.unlink(path, cb)
|
||||
}
|
||||
|
||||
module.exports = function (opts) {
|
||||
return new DiskStorage(opts)
|
||||
}
|
||||
21
backend/node_modules/multer/storage/memory.js
generated
vendored
Normal file
21
backend/node_modules/multer/storage/memory.js
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
var concat = require('concat-stream')
|
||||
|
||||
function MemoryStorage (opts) {}
|
||||
|
||||
MemoryStorage.prototype._handleFile = function _handleFile (req, file, cb) {
|
||||
file.stream.pipe(concat({ encoding: 'buffer' }, function (data) {
|
||||
cb(null, {
|
||||
buffer: data,
|
||||
size: data.length
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
MemoryStorage.prototype._removeFile = function _removeFile (req, file, cb) {
|
||||
delete file.buffer
|
||||
cb(null)
|
||||
}
|
||||
|
||||
module.exports = function (opts) {
|
||||
return new MemoryStorage(opts)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue