**Motivations:** - Complete documentation for dashboard, domains, ports and environment configuration - Add new services (ClamAV API, Watermark API) to the infrastructure - Enhance dashboard with new pages and improved functionality - Improve deployment scripts and service configurations **Root causes:** - Missing comprehensive documentation for infrastructure setup - Need for antivirus scanning service integration - Need for watermark service integration - Dashboard required additional pages and features **Correctifs:** - Added comprehensive documentation in docs/ (DASHBOARD.md, DOMAINS_AND_PORTS.md, ENVIRONMENT.md) - Updated systemd service files with proper environment variables - Enhanced nginx proxy configuration script - Updated maintenance documentation **Evolutions:** - Added new ClamAV API service (api-clamav) for file scanning - Added new Watermark API service (api-filigrane) for document watermarking - Enhanced signet-dashboard with new learn.html page - Improved dashboard UI with better styles and navigation - Enhanced app.js with new functionality and better error handling - Updated API documentation page with complete endpoint descriptions - Added deployment scripts for watermark and nginx configuration - Updated hash and UTXO lists with latest data - Enhanced server.js with new routes and improved Bitcoin RPC integration **Pages affectées:** - docs/DASHBOARD.md: New comprehensive dashboard documentation - docs/DOMAINS_AND_PORTS.md: New infrastructure domains and ports documentation - docs/ENVIRONMENT.md: New environment variables documentation - docs/MAINTENANCE.md: Updated maintenance procedures - docs/README.md: Updated main documentation - signet-dashboard/public/app.js: Enhanced with new features - signet-dashboard/public/styles.css: Improved styling - signet-dashboard/public/index.html: Enhanced main page - signet-dashboard/public/learn.html: New educational page - signet-dashboard/public/api-docs.html: Enhanced API documentation - signet-dashboard/public/hash-list.html: Updated hash list page - signet-dashboard/public/utxo-list.html: Updated UTXO list page - signet-dashboard/public/join-signet.html: Updated join signet page - signet-dashboard/src/server.js: Enhanced server with new routes - signet-dashboard/start.sh: Updated startup script - signet-dashboard/signet-dashboard.service: Updated systemd service - api-anchorage/anchorage-api.service: Updated systemd service - api-faucet/faucet-api.service: Updated systemd service - configure-nginx-proxy.sh: Enhanced nginx configuration script - add-watermark-certificate.sh: New watermark certificate script - deploy-watermark-nginx.sh: New deployment script - api-clamav/: New ClamAV API service - api-filigrane/: New Watermark API service - hash_list.txt, utxo_list.txt: Updated with latest data - anchor_count.txt: Updated anchor count
105 lines
2.5 KiB
JavaScript
105 lines
2.5 KiB
JavaScript
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
|