Skip to content

Commit a44da72

Browse files
committed
use decorate instead of method
1 parent 2e2726b commit a44da72

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ module.exports = (server, options, next) => {
5959
}
6060
});
6161
// also expose a plugin method on hapi server:
62-
server.method('uploadToS3', (file, callback) => {
63-
s3put(file, options, callback);
62+
server.decorate('server', 'uploadToS3', (file, localOptions, callback) => {
63+
if (typeof localOptions === 'function') {
64+
callback = localOptions;
65+
localOptions = {};
66+
}
67+
localOptions = aug({}, options, localOptions);
68+
69+
s3put(file, localOptions, callback);
6470
});
6571
next();
6672
};

0 commit comments

Comments
 (0)