Skip to content

Commit 599cdc6

Browse files
committed
feat: include nuxt-country-api module
1 parent b834f7b commit 599cdc6

File tree

5 files changed

+17
-4
lines changed

5 files changed

+17
-4
lines changed

packages/common-types/src/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ export interface iPluginOptions<ComponentType = unknown> {
108108
/**
109109
* Countries API base endpoint
110110
*
111-
* Get better performance with the nuxt module
111+
* If using nuxt, get better performance with the module
112112
* @see https://www.npmjs.com/package/nuxt-countries-api
113113
*
114+
* Using an absolute path will enable the module
115+
*
114116
* @default "https://countries.xamu.com.co/api/v1"
115117
*/
116118
countriesUrl?: string;

packages/nuxt/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@open-xamu-co/ui-components-vue": "link:../components-vue",
5151
"@types/lodash": "^4.14.192",
5252
"lodash": "^4.17.21",
53+
"nuxt-countries-api": "^1.0.3",
5354
"sweetalert2": "^11.7.5"
5455
},
5556
"devDependencies": {
@@ -66,4 +67,4 @@
6667
"node": ">=18",
6768
"yarn": ">=1.22.4"
6869
}
69-
}
70+
}

packages/nuxt/src/module.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable @typescript-eslint/ban-ts-comment */
2+
import path from "node:path";
23
import {
34
defineNuxtModule,
45
addPlugin,
@@ -32,7 +33,7 @@ export default defineNuxtModule<XamuModuleOptions>({
3233
countriesUrl: "https://countries.xamu.com.co/api/v1",
3334
},
3435
async setup(moduleOptions, nuxt) {
35-
const { globalComponents, componentPrefix, image } = moduleOptions;
36+
const { globalComponents, componentPrefix, image, countriesUrl } = moduleOptions;
3637
const { resolve } = createResolver(import.meta.url);
3738
const runtimePath = resolve("./runtime");
3839

@@ -50,6 +51,10 @@ export default defineNuxtModule<XamuModuleOptions>({
5051
...image,
5152
});
5253

54+
if (countriesUrl && path.isAbsolute(countriesUrl)) {
55+
await installModule("nuxt-countries-api", { base: countriesUrl });
56+
}
57+
5358
// Filter and register components if enabled
5459
if (globalComponents) {
5560
const components = Array.isArray(globalComponents) ? globalComponents : componentNames;

packages/nuxt/src/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { iPluginOptions } from "@open-xamu-co/ui-common-types";
99
export interface XamuModuleOptions
1010
extends iPluginOptions<VueComponent | FunctionalComponent | DefineComponent> {
1111
/**
12-
* Nuxt image plugin options
12+
* Nuxt image module options
1313
*/
1414
image?: Partial<NuxtImageOptions>;
1515
}

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10415,6 +10415,11 @@ nuxi@^3.10.0:
1041510415
optionalDependencies:
1041610416
fsevents "~2.3.3"
1041710417

10418+
nuxt-countries-api@^1.0.3:
10419+
version "1.0.3"
10420+
resolved "https://registry.yarnpkg.com/nuxt-countries-api/-/nuxt-countries-api-1.0.3.tgz#2b43ff984bca2f26a53c9edb3c9b11ba615ecf49"
10421+
integrity sha512-PWcE8B7et2bLdUk10xjHsDhmi/aIv6G0FfUML4wJ/K04jLKbkpOKEDcGhTy+Hvx8DaCexbKtWBs5vwckDCclLg==
10422+
1041810423
nuxt@^3.10.1:
1041910424
version "3.10.1"
1042010425
resolved "https://registry.yarnpkg.com/nuxt/-/nuxt-3.10.1.tgz#b0236e73df6db8f8465a4d1088c54a6a995e554c"

0 commit comments

Comments
 (0)