@ar4mirez/hapi-aws 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,33 @@
1
+ Copyright (c) 2017, Project contributors
2
+
3
+ Copyright (c) 2017, Angel Ramirez
4
+
5
+ Copyright (c) 2017, Cuemby, LLC
6
+
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are met:
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+ * The names of any contributors may not be used to endorse or promote
17
+ products derived from this software without specific prior written
18
+ permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY
24
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ * * *
32
+
33
+ The complete list of contributors can be found at: https://github.com/ar4mirez/hapi-octopus/graphs/contributors
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # hapi-aws
2
+
3
+ AWS plugin for HapiJS.
4
+
5
+ [![travis build](https://img.shields.io/travis/ar4mirez/hapi-aws.svg?style=flat-square)](https://travis-ci.org/ar4mirez/hapi-aws)
6
+ [![codecov coverage](https://img.shields.io/codecov/c/github/ar4mirez/hapi-aws.svg?style=flat-square)](https://codecov.io/github/ar4mirez/hapi-aws)
7
+ [![version](https://img.shields.io/npm/v/hapi-aws.svg?style=flat-square)](http://npm.im/hapi-aws)
8
+ [![downloads](https://img.shields.io/npm/dm/hapi-aws.svg?style=flat-square)](http://npm-stat.com/charts.html?package=hapi-aws&from=2015-08-01)
9
+ [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
10
+
11
+ [![Dependency Status](https://david-dm.org/ar4mirez/hapi-aws.svg)](https://david-dm.org/ar4mirez/hapi-aws)
12
+ [![devDependency Status](https://david-dm.org/ar4mirez/hapi-aws/dev-status.svg?theme=shields.io)](https://david-dm.org/ar4mirez/hapi-aws?type=dev)
13
+ [![Build Status](https://travis-ci.org/ar4mirez/hapi-aws.svg?branch=master)](https://travis-ci.org/ar4mirez/hapi-aws)
14
+
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ $ npm install hapi-aws
20
+ ```
21
+
22
+
23
+ ## Usage
24
+
25
+ ```javascript
26
+ // Using server register.
27
+
28
+ server.register({
29
+ register: require('hapi-aws'),
30
+ options: {
31
+ global: {
32
+ accessKeyId: 'accessKeyId',
33
+ secretAccessKey: 'secretAccessKey',
34
+ region: 'us-east-1'
35
+ },
36
+ services: [{
37
+ name: 'ec2Identification',
38
+ service: 'EC2',
39
+ options: {
40
+ accessKeyId: 'anotherAccessKeyId',
41
+ secretAccessKey: 'anotherSecretAccessKey',
42
+ }
43
+ }, {
44
+ name: 's3Identification',
45
+ service: 'S3',
46
+ options: {
47
+ region: 'us-west-2'
48
+ }
49
+ }]
50
+ }
51
+ })
52
+
53
+ // Using manifest.
54
+ {
55
+ ...
56
+ registration: [{
57
+ plugin: 'hapi-aws',
58
+ options: {
59
+ global: {
60
+ accessKeyId: 'accessKeyId',
61
+ secretAccessKey: 'secretAccessKey',
62
+ region: 'us-east-1'
63
+ },
64
+ services: [{
65
+ name: 's3Identification',
66
+ service: 'S3',
67
+ options: {
68
+ region: 'us-west-2'
69
+ }
70
+ }]
71
+ }
72
+ }]
73
+ }
74
+ ```
75
+
76
+ ## AWS Supported services
77
+ Check the following services here: [AWS Services](https://github.com/aws/aws-sdk-js/blob/master/SERVICES.md)
78
+
79
+ ***When passing a service please drop the AWS namespace example:***
80
+
81
+ `service.name: [string]` used later to access the service like: `server.plugins['hapi-aws'].aws.ec2Identification`
82
+
83
+ `service.service: [string]` from the previous list exmple: `EC2`
package/lib/index.js ADDED
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ const Joi = require('joi');
4
+ const Schemas = require('./schemas');
5
+
6
+ const validateOptions = {
7
+ abortEarly: false
8
+ };
9
+
10
+ exports.plugin = {
11
+ pkg: require('../package.json'),
12
+
13
+ register: async (server, options) => {
14
+
15
+ const { error: globalError, value: globalConfig } = Schemas.global.validate(
16
+ options.global || {},
17
+ validateOptions
18
+ );
19
+
20
+ if (globalError) {
21
+ throw globalError;
22
+ }
23
+
24
+ const { error: servicesError, value: servicesConfig } = Schemas.services.validate(
25
+ options.services || [],
26
+ validateOptions
27
+ );
28
+
29
+ if (servicesError) {
30
+ throw servicesError;
31
+ }
32
+
33
+ const services = {};
34
+
35
+ for (const item of servicesConfig) {
36
+ // item.client is a pre-instantiated AWS SDK v3 client
37
+ services[item.name] = item.client;
38
+ }
39
+
40
+ server.expose('aws', services);
41
+ server.decorate('server', 'aws', services);
42
+ server.decorate('request', 'aws', services);
43
+ }
44
+ };
package/lib/schemas.js ADDED
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ const Joi = require('joi');
4
+
5
+ exports.global = Joi.object({
6
+ region: Joi.string().default('us-east-1'),
7
+ credentials: Joi.object({
8
+ accessKeyId: Joi.string().required(),
9
+ secretAccessKey: Joi.string().required()
10
+ }).optional()
11
+ });
12
+
13
+ exports.services = Joi.array().items(
14
+ Joi.object({
15
+ name: Joi.string().required(),
16
+ client: Joi.any().required()
17
+ })
18
+ ).default([]);
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@ar4mirez/hapi-aws",
3
+ "description": "AWS SDK v3 plugin for HapiJS.",
4
+ "version": "3.0.2",
5
+ "author": "Angel Ramirez <angel@cuemby.com>",
6
+ "main": "lib/index.js",
7
+ "engines": {
8
+ "node": ">=18.0.0"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/ar4mirez/hapi-aws/issues"
12
+ },
13
+ "homepage": "https://github.com/ar4mirez/hapi-aws#readme",
14
+ "license": "ISC",
15
+ "dependencies": {
16
+ "@aws-sdk/client-codecommit": "^3.0.0",
17
+ "joi": "^17.13.3"
18
+ },
19
+ "devDependencies": {
20
+ "@hapi/code": "^9.0.3",
21
+ "@hapi/hapi": "^21.4.4",
22
+ "@hapi/lab": "^26.0.0"
23
+ },
24
+ "scripts": {
25
+ "test": "lab -v -c"
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/ar4mirez/hapi-aws.git"
30
+ },
31
+ "files": [
32
+ "lib/",
33
+ "package.json",
34
+ "README.md"
35
+ ]
36
+ }