@baadal-sdk/dapi 0.31.6 → 1.0.0
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/README.md +62 -2
- package/dist/index.d.ts +674 -0
- package/dist/index.js +1118 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -106
- package/LICENSE.txt +0 -21
- package/dist/cjs/index.js +0 -3
- package/dist/cjs/index.js.LICENSE.txt +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.LICENSE.txt +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/package.json +0 -3
- package/dist/types/aws/client.d.ts +0 -13
- package/dist/types/aws/client.d.ts.map +0 -1
- package/dist/types/aws/db.d.ts +0 -291
- package/dist/types/aws/db.d.ts.map +0 -1
- package/dist/types/aws/index.d.ts +0 -12
- package/dist/types/aws/index.d.ts.map +0 -1
- package/dist/types/aws/s3.d.ts +0 -90
- package/dist/types/aws/s3.d.ts.map +0 -1
- package/dist/types/common/common.model.d.ts +0 -4
- package/dist/types/common/common.model.d.ts.map +0 -1
- package/dist/types/common/const.d.ts +0 -4
- package/dist/types/common/const.d.ts.map +0 -1
- package/dist/types/common/error.d.ts +0 -4
- package/dist/types/common/error.d.ts.map +0 -1
- package/dist/types/common/logger.d.ts +0 -29
- package/dist/types/common/logger.d.ts.map +0 -1
- package/dist/types/fs/index.d.ts +0 -102
- package/dist/types/fs/index.d.ts.map +0 -1
- package/dist/types/gh/index.d.ts +0 -22
- package/dist/types/gh/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/index.d.ts.map +0 -1
- package/src/aws/client.ts +0 -18
- package/src/aws/db.ts +0 -764
- package/src/aws/index.ts +0 -33
- package/src/aws/s3.ts +0 -476
- package/src/common/common.model.ts +0 -3
- package/src/common/const.ts +0 -3
- package/src/common/error.ts +0 -12
- package/src/common/logger.ts +0 -18
- package/src/fs/index.ts +0 -316
- package/src/gh/index.ts +0 -60
- package/src/index.ts +0 -8
- package/src/typings/index.d.ts +0 -0
- package/src/utils/index.ts +0 -39
package/README.md
CHANGED
|
@@ -1,2 +1,62 @@
|
|
|
1
|
-
# dapi
|
|
2
|
-
|
|
1
|
+
# @baadal-sdk/dapi
|
|
2
|
+
|
|
3
|
+
Dead-simple API wrappers for AWS, GitHub, and common utils
|
|
4
|
+
|
|
5
|
+
## AWS
|
|
6
|
+
```bash
|
|
7
|
+
brew install awscli
|
|
8
|
+
aws --version
|
|
9
|
+
aws configure # creates `~/.aws/credentials` and `~/.aws/config`
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { aws } from '@baadal-sdk/dapi'
|
|
14
|
+
|
|
15
|
+
await aws.db.writeItem({
|
|
16
|
+
table: 'greetings',
|
|
17
|
+
{ msg: 'hello world' }, // data
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
await aws.s3.putObject(
|
|
21
|
+
'mybucket',
|
|
22
|
+
'greetings/msg.txt', // s3 path
|
|
23
|
+
'hello world', // contents
|
|
24
|
+
)
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## GitHub
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { gh } from '@baadal-sdk/dapi'
|
|
31
|
+
|
|
32
|
+
const github = gh.getInstance(process.env.GITHUB_TOKEN!, 'org-name')
|
|
33
|
+
const { data } = await github.getContent('repo-name', 'packages/client/CHANGELOG.md')
|
|
34
|
+
console.log(data.content)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## fs (file system)
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import { fs } from '@baadal-sdk/dapi'
|
|
41
|
+
|
|
42
|
+
const filepath = 'demo/sandbox/01/02/hello.txt'
|
|
43
|
+
await fs.writeFile(filepath, 'hello world')
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
> tree demo/sandbox
|
|
48
|
+
|
|
49
|
+
demo/sandbox
|
|
50
|
+
├── 01
|
|
51
|
+
│ └── 02
|
|
52
|
+
│ └── hello.txt
|
|
53
|
+
├── sample.txt
|
|
54
|
+
└── xyz
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
const dirpath = 'demo/sandbox'
|
|
59
|
+
const output = await fs.readDir(dirpath)
|
|
60
|
+
console.log(output)
|
|
61
|
+
// { dirs: [ '01', 'xyz' ], files: [ 'sample.txt' ] }
|
|
62
|
+
```
|