Skip to content

Commit 48ab3a4

Browse files
committed
feat: countries api url as option
1 parent df258cb commit 48ab3a4

File tree

6 files changed

+15
-4
lines changed

6 files changed

+15
-4
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
version: 2.1
66
orbs:
7-
node: circleci/node@5.1.1
7+
node: circleci/node@5.2.0
88
defaults: &defaults
99
working_directory: ~/repo
1010
docker:

packages/common-types/src/plugin.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ export interface iPluginOptions<ComponentType = unknown> {
105105
* When a country is provided forms will omit that field
106106
*/
107107
country?: string;
108+
/**
109+
* Countries API base endpoint
110+
*
111+
* Get better performance with the nuxt module
112+
* @see https://www.npmjs.com/package/nuxt-countries-api
113+
*
114+
* @default "https://countries.xamu.com.co/api/v1"
115+
*/
116+
countriesUrl?: string;
108117
/**
109118
* Disable automatic animations
110119
*

packages/components-vue/src/composables/countries.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import useFetch from "./fetch";
1111
* @composable
1212
*/
1313
export default function useCountries() {
14-
const { country: defaultCountry } = inject<iPluginOptions>("xamu") || {};
14+
const { country: defaultCountry, countriesUrl = "https://countries.xamu.com.co/api/v1" } =
15+
inject<iPluginOptions>("xamu") || {};
1516
const { withUrlParams } = useFetch();
1617

17-
const countriesUrl = "https://countries.xamu.com.co/api/v1";
1818
const fallbackCountry = {} as iCountry & { states?: iState[] };
1919

2020
async function getCountries(): Promise<iCountry[]> {

packages/components-vue/src/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const XamuPlugin: Plugin<
2525
locale,
2626
lang: "en",
2727
first: 10,
28+
countriesUrl: "https://countries.xamu.com.co/api/v1",
2829
// override defaults
2930
...options,
3031
};

packages/nuxt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default defineNuxtConfig({
3939
});
4040
```
4141

42-
| Name | Type | Type | Description |
42+
| Name | Type | Default | Description |
4343
| ------------------ | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
4444
| webComponents | boolean | false | Use web components |
4545
| globalComponents | boolean \| tComponent[] | true | Register all or specific components globally. If `true`, all components will be registered globally. If an array is provided, only the components specified in the array will be registered globally. |

packages/nuxt/src/module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default defineNuxtModule<XamuModuleOptions>({
2929
locale,
3030
lang: "en",
3131
first: 10,
32+
countriesUrl: "https://countries.xamu.com.co/api/v1",
3233
},
3334
async setup(moduleOptions, nuxt) {
3435
const { globalComponents, componentPrefix, image } = moduleOptions;

0 commit comments

Comments
 (0)