Skip to content

Commit f2cb731

Browse files
author
Íñigo Marquínez Prado
committed
feat: added files for best practices (linter, hooks, jest, README)
1 parent cc14182 commit f2cb731

File tree

6 files changed

+99
-0
lines changed

6 files changed

+99
-0
lines changed

.eslintrc.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es2021": true,
6+
"node": true,
7+
"jest": true
8+
},
9+
"extends": [
10+
"standard"
11+
],
12+
"parserOptions": {
13+
"ecmaVersion": 12
14+
},
15+
"rules": {
16+
"no-extra-semi": "off",
17+
"semi": "off"
18+
}
19+
}

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx commitlint --edit $1

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
14.17.6

README.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Systemic AWS S3
2+
3+
A [Systemic](https://guidesmiths.github.io/systemic/#/) component for the [AWS S3 SDK v3](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html).
4+
5+
## How to use it
6+
7+
### Configuration
8+
9+
A typical, simple configuration looks like this:
10+
11+
```json
12+
{
13+
"region": "us-east-1",
14+
"credentials": {
15+
"secretAccessKey": "test",
16+
"accessKeyId": "test"
17+
}
18+
}
19+
```
20+
21+
[Here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html) you can finde the complete configuration interface of S3Client class constructor that set the region, credentials and other options.
22+
23+
### Initialize the component
24+
25+
As with any other [Systemic component](https://guidesmiths.github.io/systemic/#/?id=components), you can run it with the `start` method:
26+
27+
```js
28+
const initAWSS3 = require('systemic-aws-s3');
29+
const { start } = initAWSS3();
30+
31+
const api = await start({ config }); // configuration similar to the one above
32+
```
33+
34+
### Call the API commands
35+
36+
As the AWS API has dozens of commands, intead of having one wrapper for each of them, the component exposes one single command `commandExecutor` that can be used to call any of the commands exposed by the api:
37+
38+
For example, to list all the objects in a specific bucket:
39+
40+
```js
41+
const listObjectConfig = {
42+
commandParams: { Bucket: bucketName },
43+
commandName: 'listObjects'
44+
}
45+
const res = await api.commandExecutor(listObjectConfig);
46+
```
47+
48+
You can check all the available commands [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/classes/s3.html).
49+
50+
### Custom commands
51+
52+
In the future, this component will also expose some custom commands not supported by the official API.
53+
54+
## Guide for developers
55+
56+
### How to test it
57+
58+
You can test the whole test suite running one of these commands:
59+
60+
```bash
61+
# all tests will be executed once
62+
npm run test
63+
64+
# tests will be executed every time code changes (useful when coding)
65+
npm run test:watch
66+
```
67+
68+
In case that you want to just execute a certain test case, you can also use these scripts to up / tear down the infra.
69+
70+
```bash
71+
npm run infra:up
72+
npm run infra:down
73+
```

commitlint.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {extends: ['@commitlint/config-conventional']}

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./test/jest.config.project');

0 commit comments

Comments
 (0)