Skip to content

Commit 21f9aaa

Browse files
committed
Add remaining documentation in readme and webpack config for library
1 parent 75c3500 commit 21f9aaa

File tree

8 files changed

+14
-26
lines changed

8 files changed

+14
-26
lines changed

README.md

+4-11
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,10 @@ Lord of the Rings SDK
77
`npm install @skapicic/lotr-sdk`
88

99
### Initialisation:
10-
In the head of your page initialise the sdk by running
11-
1210
```
13-
<script src="lotr.js">
14-
</script>
15-
<script>
16-
Lotr.init({ apiKey: 'yourApiKey' });
17-
</script>
11+
import { LotrClient } from '@skapicic/lotr-sdk'
12+
13+
const lotrClient = new LotrClient('YOUR_API_KEY');
1814
```
1915

2016
That's it!
@@ -30,7 +26,7 @@ Entities that are supported for the current version are
3026
* Quotes
3127

3228
All the mentioned entities support getting by id or list.
33-
The list API supports pagination, sorting and filtering. (see <a name="examples">examples</a>)
29+
The list API supports pagination, sorting and filtering. (see [examples](#examples))
3430
All methods return Promises that are free to use asynchronously throughout the code.
3531

3632
## Filter API
@@ -76,6 +72,3 @@ Lotr.books({
7672
]
7773
});
7874
```
79-
80-
81-

dist/lotr.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "@skapicic/lotr-sdk",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"description": "An SDK for The Lord of the Rings",
55
"main": "./dist/lotr.js",
66
"scripts": {
7-
"build": "webpack",
7+
"build": "webpack --mode=production",
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
1010
"repository": {

src/client/client.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export class Client {
1111
}
1212

1313
// TODO: consider caching and other nice-to-have features
14-
public init(config: ClientConfig) {
14+
public config(config: ClientConfig) {
1515
this.apiKey = config.apiKey;
1616
}
1717

src/index.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
import {Lotr as LotrClient} from './lotr';
1+
const main = require('./lotr');
22

3-
declare global {
4-
var Lotr: LotrClient;
5-
}
6-
7-
(function() {
8-
window.Lotr = new LotrClient();
9-
}());
3+
exports.LotrClient = main.Lotr;

src/lotr.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Lotr {
3737
this.chapterService = new ChapterService(this.client);
3838
}
3939

40-
public init(config: ClientConfig) {
40+
public config(config: ClientConfig) {
4141
this.client.init(config);
4242
}
4343

tsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
"target": "es5",
77
"jsx": "react",
88
"allowJs": true,
9-
"moduleResolution": "node",
10-
"sourceMap": true
9+
"moduleResolution": "node"
1110
},
1211
"exclude": [
1312
"node_modules"

webpack.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,7 @@ module.exports = {
1717
output: {
1818
filename: 'lotr.js',
1919
path: path.resolve(__dirname, 'dist'),
20+
library: 'eTrack',
21+
libraryTarget: 'umd'
2022
},
2123
};

0 commit comments

Comments
 (0)