@almighty-shogun/utils 1.4.2 → 1.5.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 +0 -21
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/package.json +1 -2
- package/src/index.ts +0 -2
- package/dist/axiosHttpLog.d.ts +0 -8
- package/dist/axiosHttpLog.d.ts.map +0 -1
- package/dist/axiosHttpLog.js +0 -4
- package/dist/axiosInstancesRegister.d.ts +0 -19
- package/dist/axiosInstancesRegister.d.ts.map +0 -1
- package/dist/axiosInstancesRegister.js +0 -20
- package/src/axiosHttpLog.ts +0 -11
- package/src/axiosInstancesRegister.ts +0 -41
package/README.md
CHANGED
|
@@ -5,27 +5,6 @@ A small package that contains common utilities used in all my projects.
|
|
|
5
5
|
## 📃 Prerequisites
|
|
6
6
|
- **[Node.js](https://nodejs.org/en/)**: >= v23.11.1
|
|
7
7
|
|
|
8
|
-
## 💻 Installation
|
|
9
|
-
|
|
10
|
-
### Step 1
|
|
11
|
-
Install the package using your package manager of choice.
|
|
12
|
-
```shell
|
|
13
|
-
bun add @almighty-shogun/utils
|
|
14
|
-
yarn add @almighty-shogun/utils
|
|
15
|
-
npm install @almighty-shogun/utils
|
|
16
|
-
pnpm install @almighty-shogun/utils
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Step 2
|
|
20
|
-
Import a utility function from the package and use it.
|
|
21
|
-
```ts
|
|
22
|
-
import { getWeather } from '@almighty-shogun/utils'
|
|
23
|
-
|
|
24
|
-
const weatherData = await getWeather(52.374, 4.8897);
|
|
25
|
-
|
|
26
|
-
console.log(`Current weather in Amsterdam: ${weatherData.current.temperature.current} °C`);
|
|
27
|
-
```
|
|
28
|
-
|
|
29
8
|
## 📦 Building
|
|
30
9
|
- Use the command `bun install` in the root directory to install the required dependencies.
|
|
31
10
|
- Run `bun --cwd packages/utils build` to build the package.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export type { Weather, WeatherItem } from './internal/weather';
|
|
2
2
|
export { getCountry, getCountries } from './internal/localization';
|
|
3
|
-
export { default as axiosHttpLog } from './axiosHttpLog';
|
|
4
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister';
|
|
5
3
|
export { default as containsRoutePrefix } from './containsRoutePrefix';
|
|
6
4
|
export { default as disableZoom } from './disableZoom';
|
|
7
5
|
export { default as formatCelsius } from './formatCelsius';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAC5D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { getCountry, getCountries } from './internal/localization';
|
|
2
|
-
export { default as axiosHttpLog } from './axiosHttpLog';
|
|
3
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister';
|
|
4
2
|
export { default as containsRoutePrefix } from './containsRoutePrefix';
|
|
5
3
|
export { default as disableZoom } from './disableZoom';
|
|
6
4
|
export { default as formatCelsius } from './formatCelsius';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almighty-shogun/utils",
|
|
3
3
|
"description": "A small package that contains common utilities used in all my projects.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"scripts": {
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@types/luxon": "^3.7.1",
|
|
40
|
-
"axios": "^1.13.2",
|
|
41
40
|
"luxon": "^3.7.2",
|
|
42
41
|
"vue-router": "^4.6.3"
|
|
43
42
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export type { Weather, WeatherItem } from './internal/weather'
|
|
2
2
|
export { getCountry, getCountries } from './internal/localization'
|
|
3
3
|
|
|
4
|
-
export { default as axiosHttpLog } from './axiosHttpLog'
|
|
5
|
-
export { default as axiosInstancesRegister } from './axiosInstancesRegister'
|
|
6
4
|
export { default as containsRoutePrefix } from './containsRoutePrefix'
|
|
7
5
|
export { default as disableZoom } from './disableZoom'
|
|
8
6
|
export { default as formatCelsius } from './formatCelsius'
|
package/dist/axiosHttpLog.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosHttpLog.d.ts","sourceRoot":"","sources":["../src/axiosHttpLog.ts"],"names":[],"mappings":"AAAA,KAAK,SAAS,GAAG;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,WAAW,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,CAIjF"}
|
package/dist/axiosHttpLog.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { InternalAxiosRequestConfig, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
2
|
-
type RegisterInstance<Name extends string = string> = {
|
|
3
|
-
name: Name;
|
|
4
|
-
url: string;
|
|
5
|
-
responseInterceptors?: [
|
|
6
|
-
(response: any) => any,
|
|
7
|
-
(error: any) => any
|
|
8
|
-
];
|
|
9
|
-
requestInterceptors?: [
|
|
10
|
-
(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig,
|
|
11
|
-
(error: any) => any
|
|
12
|
-
];
|
|
13
|
-
config?: AxiosRequestConfig;
|
|
14
|
-
};
|
|
15
|
-
export default function <const T extends readonly RegisterInstance[]>(instances: T): {
|
|
16
|
-
[K in T[number]['name']]: AxiosInstance;
|
|
17
|
-
};
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=axiosInstancesRegister.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"axiosInstancesRegister.d.ts","sourceRoot":"","sources":["../src/axiosInstancesRegister.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAA;AAE1F,KAAK,gBAAgB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI;IAClD,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,oBAAoB,CAAC,EAAE;QACnB,CAAC,QAAQ,EAAE,GAAG,KAAK,GAAG;QACtB,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;KACtB,CAAC;IACF,mBAAmB,CAAC,EAAE;QAClB,CAAC,MAAM,EAAE,0BAA0B,KAAK,0BAA0B;QAClE,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG;KACtB,CAAC;IACF,MAAM,CAAC,EAAE,kBAAkB,CAAC;CAC/B,CAAA;AAED,MAAM,CAAC,OAAO,WAAU,KAAK,CAAC,CAAC,SAAS,SAAS,gBAAgB,EAAE,EAAE,SAAS,EAAE,CAAC,GAAG;KAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa;CAAE,CAuB9H"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
export default function (instances) {
|
|
3
|
-
const instancesMap = {};
|
|
4
|
-
instances.forEach(instance => {
|
|
5
|
-
const axiosInstance = axios.create({
|
|
6
|
-
baseURL: instance.url,
|
|
7
|
-
...instance.config
|
|
8
|
-
});
|
|
9
|
-
if (instance.responseInterceptors) {
|
|
10
|
-
const [onSuccess, onError] = instance.responseInterceptors;
|
|
11
|
-
axiosInstance.interceptors.response.use(onSuccess, onError);
|
|
12
|
-
}
|
|
13
|
-
if (instance.requestInterceptors) {
|
|
14
|
-
const [onSuccess, onError] = instance.requestInterceptors;
|
|
15
|
-
axiosInstance.interceptors.request.use(onSuccess, onError);
|
|
16
|
-
}
|
|
17
|
-
instancesMap[instance.name] = axiosInstance;
|
|
18
|
-
});
|
|
19
|
-
return instancesMap;
|
|
20
|
-
}
|
package/src/axiosHttpLog.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
type AxiosData = {
|
|
2
|
-
status: number;
|
|
3
|
-
url: string;
|
|
4
|
-
message: string;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function (name: string, data: AxiosData, isRejected: boolean): void {
|
|
8
|
-
const logMethod = isRejected ? console.error : console.info;
|
|
9
|
-
|
|
10
|
-
logMethod(`${name}: [HTTP ${data.status}] ${data.url} ${data.message}`);
|
|
11
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import type { InternalAxiosRequestConfig, AxiosInstance, AxiosRequestConfig } from 'axios'
|
|
3
|
-
|
|
4
|
-
type RegisterInstance<Name extends string = string> = {
|
|
5
|
-
name: Name;
|
|
6
|
-
url: string;
|
|
7
|
-
responseInterceptors?: [
|
|
8
|
-
(response: any) => any,
|
|
9
|
-
(error: any) => any
|
|
10
|
-
];
|
|
11
|
-
requestInterceptors?: [
|
|
12
|
-
(config: InternalAxiosRequestConfig) => InternalAxiosRequestConfig,
|
|
13
|
-
(error: any) => any
|
|
14
|
-
];
|
|
15
|
-
config?: AxiosRequestConfig;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export default function<const T extends readonly RegisterInstance[]>(instances: T): { [K in T[number]['name']]: AxiosInstance } {
|
|
19
|
-
const instancesMap = {} as { [K in T[number]['name']]: AxiosInstance };
|
|
20
|
-
|
|
21
|
-
instances.forEach(instance => {
|
|
22
|
-
const axiosInstance = axios.create({
|
|
23
|
-
baseURL: instance.url,
|
|
24
|
-
...instance.config
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
if (instance.responseInterceptors) {
|
|
28
|
-
const [onSuccess, onError] = instance.responseInterceptors;
|
|
29
|
-
axiosInstance.interceptors.response.use(onSuccess, onError);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (instance.requestInterceptors) {
|
|
33
|
-
const [onSuccess, onError] = instance.requestInterceptors;
|
|
34
|
-
axiosInstance.interceptors.request.use(onSuccess, onError);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
instancesMap[instance.name as T[number]['name']] = axiosInstance;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
return instancesMap;
|
|
41
|
-
}
|