anu-verzum 1.19.0 → 1.21.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 +15 -1
- package/dist/index.d.ts +3 -0
- package/dist/server-api/server-api.d.ts +3 -0
- package/dist/server-api/server-api.js +12 -5
- package/package.json +1 -1
- package/webpack.config.js +2 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<h3>@author: <strong>Anubis-programmer</strong></h3>
|
|
6
6
|
<h3>@license: <strong>MIT</strong></h3>
|
|
7
|
-
<h3>@version: <strong>1.
|
|
7
|
+
<h3>@version: <strong>1.21.0</strong></h3>
|
|
8
8
|
|
|
9
9
|
<br>
|
|
10
10
|
|
|
@@ -73,6 +73,20 @@ module.exports = require('anu-verzum/webpack.config')(__dirname, {
|
|
|
73
73
|
});
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
Use `plugins` to append additional webpack plugins after the built-in `HtmlWebpackPlugin`:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
const webpack = require('webpack');
|
|
80
|
+
|
|
81
|
+
module.exports = require('anu-verzum/webpack.config')(__dirname, {
|
|
82
|
+
plugins: [
|
|
83
|
+
new webpack.DefinePlugin({
|
|
84
|
+
'process.env.API_URL': JSON.stringify(process.env.API_URL)
|
|
85
|
+
})
|
|
86
|
+
]
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
76
90
|
<h3 id="importing-in-your-files">Importing in your files</h3>
|
|
77
91
|
|
|
78
92
|
Every file that contains JSX must import `Anu`, because the JSX transform expands to `Anu.createElement(...)` calls at compile time:
|
package/dist/index.d.ts
CHANGED
|
@@ -116,6 +116,9 @@ declare const Anu: {
|
|
|
116
116
|
};
|
|
117
117
|
};
|
|
118
118
|
ServerAPI: {
|
|
119
|
+
configure: ({ baseURL }: {
|
|
120
|
+
baseURL?: string;
|
|
121
|
+
}) => void;
|
|
119
122
|
get: <T = any>(url: string, params?: Record<string, any>) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
120
123
|
post: <T = any>(url: string, data: unknown) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
121
124
|
put: <T = any>(url: string, data: unknown) => Promise<import(".").ApiSuccessResponse<T>>;
|
|
@@ -7,6 +7,9 @@ export type ApiErrorResponse = {
|
|
|
7
7
|
response: null;
|
|
8
8
|
};
|
|
9
9
|
declare const ServerAPI: {
|
|
10
|
+
configure: ({ baseURL }: {
|
|
11
|
+
baseURL?: string;
|
|
12
|
+
}) => void;
|
|
10
13
|
get: <T = any>(url: string, params?: Record<string, any>) => Promise<ApiSuccessResponse<T>>;
|
|
11
14
|
post: <T = any>(url: string, data: unknown) => Promise<ApiSuccessResponse<T>>;
|
|
12
15
|
put: <T = any>(url: string, data: unknown) => Promise<ApiSuccessResponse<T>>;
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
let _baseURL = '';
|
|
8
|
+
const _resolveURL = url => /^https?:\/\//.test(url) ? url : `${_baseURL}${url}`;
|
|
7
9
|
const SUCCESS_STATUS_CODES = [200, 201, 202, 203, 204, 205, 206, 207, 208, 226];
|
|
8
10
|
const CLIENT_ERROR_STATUS_CODES = [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 421, 422, 423, 424, 425, 426, 428, 429, 431, 451];
|
|
9
11
|
const SERVER_ERROR_STATUS_CODES = [500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511];
|
|
@@ -105,10 +107,15 @@ const _serverFileAPI = (url, files, data = {}) => (successHandler, errorHandler)
|
|
|
105
107
|
XHR.send(formData);
|
|
106
108
|
};
|
|
107
109
|
const ServerAPI = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
configure: ({
|
|
111
|
+
baseURL = ''
|
|
112
|
+
}) => {
|
|
113
|
+
_baseURL = baseURL.replace(/\/$/, '');
|
|
114
|
+
},
|
|
115
|
+
get: (url, params) => new Promise(_serverGetAPI(_resolveURL(url), params)),
|
|
116
|
+
post: (url, data) => new Promise(_serverPostAPI(_resolveURL(url), data)),
|
|
117
|
+
put: (url, data) => new Promise(_serverPutAPI(_resolveURL(url), data)),
|
|
118
|
+
delete: (url, params) => new Promise(_serverDeleteAPI(_resolveURL(url), params)),
|
|
119
|
+
file: (url, files, data) => new Promise(_serverFileAPI(_resolveURL(url), files, data))
|
|
113
120
|
};
|
|
114
121
|
var _default = exports.default = ServerAPI;
|
package/package.json
CHANGED
package/webpack.config.js
CHANGED