@nzz/q-server
Version:
__Q__ is a system that lets journalists create visual elements for stories. It is developed by [NZZ Storytelling](https://www.nzz.ch/storytelling) and used in the [NZZ](https://www.nzz.ch) newsroom.
27 lines (20 loc) • 687 B
JavaScript
const AWS = require('aws-sdk');
const getRoutes = require('./routes.js').getRoutes;
const assets = {
register: function(server, options, next) {
if (!options.s3 || !options.s3.accessKey || !options.s3.secretKey || !options.s3.region || !options.s3.bucket) {
return next(new Error('You need to provide these options: s3.accessKey, s3.secretKey, s3.region, s3.bucket'));
}
const s3 = new AWS.S3({
accessKeyId: options.s3.accessKey,
secretAccessKey: options.s3.secretKey,
region: options.s3.region
});
server.route(getRoutes(s3, options));
next();
}
}
assets.register.attributes = {
name: 'q-assets-s3'
}
module.exports = assets;