resora 0.1.6 → 0.1.8

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/bin/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import{copyFileSync as e,existsSync as t,mkdirSync as n,readFileSync as r,rmSync as i,writeFileSync as a}from"fs";import o,{dirname as s,join as c}from"path";import{createRequire as l}from"module";import{fileURLToPath as u}from"url";import{Command as d,Kernel as f}from"@h3ravel/musket";const p=o.dirname(u(import.meta.url));let m=o.resolve(p,`../node_modules/resora/stubs`);t(m)||(m=o.resolve(p,`../stubs`));const h=(e={})=>Object.assign({resourcesDir:`src/resources`,stubsDir:m,stubs:{config:`resora.config.stub`,resource:`resource.stub`,collection:`resource.collection.stub`}},e,{stubs:Object.assign({config:`resora.config.stub`,resource:`resource.stub`,collection:`resource.collection.stub`},e.stubs||{})});var g=class{command;config={};constructor(e={}){this.config=h(e);let n=l(import.meta.url),r=[c(process.cwd(),`resora.config.ts`),c(process.cwd(),`resora.config.js`),c(process.cwd(),`resora.config.cjs`)];for(let e of r)if(t(e))try{let{default:t}=n(e);Object.assign(this.config,h(t));break}catch(t){console.error(`Error loading config file at ${e}:`,t)}}init(){let n=c(process.cwd(),`resora.config.js`),i=c(this.config.stubsDir,this.config.stubs.config);return t(n)&&!this.command.option(`force`)&&(this.command.error(`Error: ${n} already exists.`),process.exit(1)),this.ensureDirectory(n),t(n)&&this.command.option(`force`)&&e(n,n.replace(/\.js$/,`.backup.${Date.now()}.js`)),a(n,r(i,`utf-8`)),{path:n}}ensureDirectory(e){let r=s(e);t(r)||n(r,{recursive:!0})}generateFile(e,n,o,s){t(n)&&!s?.force?(this.command.error(`Error: ${n} already exists.`),process.exit(1)):t(n)&&s?.force&&i(n);let c=r(e,`utf-8`);for(let[e,t]of Object.entries(o))c=c.replace(RegExp(`{{${e}}}`,`g`),t);return this.ensureDirectory(n),a(n,c),n}makeResource(e,n){let r=e;n?.collection&&!e.endsWith(`Collection`)&&!e.endsWith(`Resource`)?r+=`Collection`:!n?.collection&&!e.endsWith(`Resource`)&&!e.endsWith(`Collection`)&&(r+=`Resource`);let i=`${r}.ts`,a=c(this.config.resourcesDir,i),o=c(this.config.stubsDir,n?.collection||e.endsWith(`Collection`)?this.config.stubs.collection:this.config.stubs.resource);t(o)||(this.command.error(`Error: Stub file ${o} not found.`),process.exit(1));let s=r.replace(/(Resource|Collection)$/,``)+`Resource`,l=`/**
2
+ import{copyFileSync as e,existsSync as t,mkdirSync as n,readFileSync as r,rmSync as i,writeFileSync as a}from"fs";import o,{dirname as s,join as c}from"path";import{createRequire as l}from"module";import{Command as u,Kernel as d}from"@h3ravel/musket";let f=o.resolve(process.cwd(),`node_modules/resora/stubs`);t(f)||(f=o.resolve(process.cwd(),`stubs`));const p=()=>({stubsDir:f,preferredCase:`camel`,paginatedExtras:[`meta`,`links`],paginatedLinks:{first:`first`,last:`last`,prev:`prev`,next:`next`},paginatedMeta:{to:`to`,from:`from`,links:`links`,path:`path`,total:`total`,per_page:`per_page`,last_page:`last_page`,current_page:`current_page`},resourcesDir:`src/resources`,stubs:{config:`resora.config.stub`,resource:`resource.stub`,collection:`resource.collection.stub`}}),m=(e={})=>{let t=p();return Object.assign(t,e,{stubs:Object.assign(t.stubs,e.stubs||{})})};var h=class{command;config={};constructor(e={}){this.config=m(e);let n=l(import.meta.url),r=[c(process.cwd(),`resora.config.ts`),c(process.cwd(),`resora.config.js`),c(process.cwd(),`resora.config.cjs`)];for(let e of r)if(t(e))try{let{default:t}=n(e);Object.assign(this.config,t);break}catch(t){console.error(`Error loading config file at ${e}:`,t)}}init(){let n=c(process.cwd(),`resora.config.js`),i=c(this.config.stubsDir,this.config.stubs.config);return t(n)&&!this.command.option(`force`)&&(this.command.error(`Error: ${n} already exists.`),process.exit(1)),this.ensureDirectory(n),t(n)&&this.command.option(`force`)&&e(n,n.replace(/\.js$/,`.backup.${Date.now()}.js`)),a(n,r(i,`utf-8`)),{path:n}}ensureDirectory(e){let r=s(e);t(r)||n(r,{recursive:!0})}generateFile(e,n,o,s){t(n)&&!s?.force?(this.command.error(`Error: ${n} already exists.`),process.exit(1)):t(n)&&s?.force&&i(n);let c=r(e,`utf-8`);for(let[e,t]of Object.entries(o))c=c.replace(RegExp(`{{${e}}}`,`g`),t);return this.ensureDirectory(n),a(n,c),n}makeResource(e,n){let r=e;n?.collection&&!e.endsWith(`Collection`)&&!e.endsWith(`Resource`)?r+=`Collection`:!n?.collection&&!e.endsWith(`Resource`)&&!e.endsWith(`Collection`)&&(r+=`Resource`);let i=`${r}.ts`,a=c(this.config.resourcesDir,i),o=c(this.config.stubsDir,n?.collection||e.endsWith(`Collection`)?this.config.stubs.collection:this.config.stubs.resource);t(o)||(this.command.error(`Error: Stub file ${o} not found.`),process.exit(1));let s=r.replace(/(Resource|Collection)$/,``)+`Resource`,l=`/**
3
3
  * The resource that this collection collects.
4
4
  */
5
5
  collects = ${s}
6
- `,u=`import ${s} from './${s}'\n`,d=(!!n?.collection||e.endsWith(`Collection`))&&t(c(this.config.resourcesDir,`${s}.ts`)),f=this.generateFile(o,a,{ResourceName:r,CollectionResourceName:r.replace(/(Resource|Collection)$/,``)+`Resource`,"collects = Resource":d?l:``,"import = Resource":d?u:``},n);return{name:r,path:f}}},_=class extends d{signature=`init
6
+ `,u=`import ${s} from './${s}'\n`,d=(!!n?.collection||e.endsWith(`Collection`))&&t(c(this.config.resourcesDir,`${s}.ts`)),f=this.generateFile(o,a,{ResourceName:r,CollectionResourceName:r.replace(/(Resource|Collection)$/,``)+`Resource`,"collects = Resource":d?l:``,"import = Resource":d?u:``},n);return{name:r,path:f}}},g=class extends u{signature=`init
7
7
  {--force : Force overwrite if config file already exists (existing file will be backed up) }
8
- `;description=`Initialize Resora`;async handle(){this.app.command=this,this.app.init(),this.success(`Resora initialized`)}},v=class extends d{signature=`#create:
8
+ `;description=`Initialize Resora`;async handle(){this.app.command=this,this.app.init(),this.success(`Resora initialized`)}},_=class extends u{signature=`#create:
9
9
  {resource : Generates a new resource file.
10
10
  | {name : Name of the resource to create}
11
11
  | {--c|collection : Make a resource collection}
@@ -19,11 +19,11 @@ import{copyFileSync as e,existsSync as t,mkdirSync as n,readFileSync as r,rmSync
19
19
  | {prefix : prefix of the resources to create, "Admin" will create AdminResource, AdminCollection}
20
20
  | {--force : Create the resource or collection file even if it already exists.}
21
21
  }
22
- `;description=`Create a new resource or resource collection file`;async handle(){this.app.command=this;let e=``,t=this.dictionary.name||this.dictionary.baseCommand;if([`resource`,`collection`].includes(t)&&!this.argument(`name`))return void this.error(`Error: Name argument is required.`);if(t===`all`&&!this.argument(`prefix`))return void this.error(`Error: Prefix argument is required.`);switch(t){case`resource`:({path:e}=this.app.makeResource(this.argument(`name`),this.options()));break;case`collection`:({path:e}=this.app.makeResource(this.argument(`name`)+`Collection`,this.options()));break;case`all`:{let t=this.app.makeResource(this.argument(`prefix`),{force:this.option(`force`)}),n=this.app.makeResource(this.argument(`prefix`)+`Collection`,{collection:!0,force:this.option(`force`)});e=`${t.path}, ${n.path}`;break}default:this.fail(`Unknown action: ${t}`)}this.success(`Created: ${e}`)}},y=String.raw`
22
+ `;description=`Create a new resource or resource collection file`;async handle(){this.app.command=this;let e=``,t=this.dictionary.name||this.dictionary.baseCommand;if([`resource`,`collection`].includes(t)&&!this.argument(`name`))return void this.error(`Error: Name argument is required.`);if(t===`all`&&!this.argument(`prefix`))return void this.error(`Error: Prefix argument is required.`);switch(t){case`resource`:({path:e}=this.app.makeResource(this.argument(`name`),this.options()));break;case`collection`:({path:e}=this.app.makeResource(this.argument(`name`)+`Collection`,this.options()));break;case`all`:{let t=this.app.makeResource(this.argument(`prefix`),{force:this.option(`force`)}),n=this.app.makeResource(this.argument(`prefix`)+`Collection`,{collection:!0,force:this.option(`force`)});e=`${t.path}, ${n.path}`;break}default:this.fail(`Unknown action: ${t}`)}this.success(`Created: ${e}`)}},v=String.raw`
23
23
  _____
24
24
  | __ \
25
25
  | |__) |___ ___ ___ _ __ __ _
26
26
  | _ // _ \/ __|/ _ \| '__/ _, |
27
27
  | | \ \ __/\__ \ (_) | | | (_| |
28
28
  |_| \_\___||___/\___/|_| \__,_|
29
- `;const b=new g;await f.init(b,{logo:y,name:`Resora CLI`,baseCommands:[v,_],exceptionHandler(e){throw e}});export{};
29
+ `;const y=new h;await d.init(y,{logo:v,name:`Resora CLI`,baseCommands:[_,g],exceptionHandler(e){throw e}});export{};
package/dist/index.cjs CHANGED
@@ -30,7 +30,6 @@ let fs = require("fs");
30
30
  let path = require("path");
31
31
  path = __toESM(path);
32
32
  let module$1 = require("module");
33
- let url = require("url");
34
33
  let _h3ravel_musket = require("@h3ravel/musket");
35
34
 
36
35
  //#region src/ApiResource.ts
@@ -46,9 +45,37 @@ function ApiResource(instance) {
46
45
 
47
46
  //#endregion
48
47
  //#region src/utility.ts
49
- const __dirname$1 = /* @__PURE__ */ path.default.dirname((0, url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
50
- let stubsDir = path.default.resolve(__dirname$1, "../node_modules/resora/stubs");
51
- if (!(0, fs.existsSync)(stubsDir)) stubsDir = path.default.resolve(__dirname$1, "../stubs");
48
+ let stubsDir = path.default.resolve(process.cwd(), "node_modules/resora/stubs");
49
+ if (!(0, fs.existsSync)(stubsDir)) stubsDir = path.default.resolve(process.cwd(), "stubs");
50
+ const getDefaultConfig = () => {
51
+ return {
52
+ stubsDir,
53
+ preferredCase: "camel",
54
+ paginatedExtras: ["meta", "links"],
55
+ paginatedLinks: {
56
+ first: "first",
57
+ last: "last",
58
+ prev: "prev",
59
+ next: "next"
60
+ },
61
+ paginatedMeta: {
62
+ to: "to",
63
+ from: "from",
64
+ links: "links",
65
+ path: "path",
66
+ total: "total",
67
+ per_page: "per_page",
68
+ last_page: "last_page",
69
+ current_page: "current_page"
70
+ },
71
+ resourcesDir: "src/resources",
72
+ stubs: {
73
+ config: "resora.config.stub",
74
+ resource: "resource.stub",
75
+ collection: "resource.collection.stub"
76
+ }
77
+ };
78
+ };
52
79
  /**
53
80
  * Define the configuration for the package
54
81
  *
@@ -56,19 +83,8 @@ if (!(0, fs.existsSync)(stubsDir)) stubsDir = path.default.resolve(__dirname$1,
56
83
  * @returns The merged configuration object
57
84
  */
58
85
  const defineConfig = (userConfig = {}) => {
59
- return Object.assign({
60
- resourcesDir: "src/resources",
61
- stubsDir,
62
- stubs: {
63
- config: "resora.config.stub",
64
- resource: "resource.stub",
65
- collection: "resource.collection.stub"
66
- }
67
- }, userConfig, { stubs: Object.assign({
68
- config: "resora.config.stub",
69
- resource: "resource.stub",
70
- collection: "resource.collection.stub"
71
- }, userConfig.stubs || {}) });
86
+ const defaultConfig = getDefaultConfig();
87
+ return Object.assign(defaultConfig, userConfig, { stubs: Object.assign(defaultConfig.stubs, userConfig.stubs || {}) });
72
88
  };
73
89
 
74
90
  //#endregion
@@ -86,7 +102,7 @@ var CliApp = class {
86
102
  ];
87
103
  for (const configPath of possibleConfigPaths) if ((0, fs.existsSync)(configPath)) try {
88
104
  const { default: userConfig } = require(configPath);
89
- Object.assign(this.config, defineConfig(userConfig));
105
+ Object.assign(this.config, userConfig);
90
106
  break;
91
107
  } catch (e) {
92
108
  console.error(`Error loading config file at ${configPath}:`, e);
@@ -702,4 +718,5 @@ exports.MakeResource = MakeResource;
702
718
  exports.Resource = Resource;
703
719
  exports.ResourceCollection = ResourceCollection;
704
720
  exports.ServerResponse = ServerResponse;
705
- exports.defineConfig = defineConfig;
721
+ exports.defineConfig = defineConfig;
722
+ exports.getDefaultConfig = getDefaultConfig;
package/dist/index.d.cts CHANGED
@@ -165,11 +165,11 @@ interface Cursor {
165
165
  }
166
166
  interface Config {
167
167
  /**
168
- * @description The directory where resource files are stored. This is the location where the generated resource files will be saved. It should be a valid path on the file system.
168
+ * @description The directory where resource files are stored. This is the location where the generated resource files will be saved. It should be a valid path on the file system relative to the project root.
169
169
  */
170
170
  resourcesDir: string;
171
171
  /**
172
- * @description The directory where stub files are stored. Stub files are templates used for generating resource files. This should also be a valid path on the file system where the stub templates are located.
172
+ * @description The directory where stub files are stored. Stub files are templates used for generating resource files. This should also be a valid path on the file system relative to the project root where the stub templates are located.
173
173
  */
174
174
  stubsDir: string;
175
175
  /**
@@ -189,12 +189,45 @@ interface Config {
189
189
  */
190
190
  collection: string;
191
191
  };
192
+ /**
193
+ * @description This option allows you to specify the case style that should be used for the keys in API responses returned by the resources.
194
+ */
195
+ preferredCase: 'camel' | 'snake' | 'pascal' | 'kebab';
196
+ /**
197
+ * @description This option allows you to specify the extra properties that should be included in the response body when a resource is paginated. You can choose to include either 'meta', 'links', or both, or you can provide custom property names for these extras.
198
+ */
199
+ paginatedExtras: ['meta', 'links'] | {
200
+ meta?: string | undefined;
201
+ links?: string | undefined;
202
+ };
203
+ /**
204
+ * @description This option allows you to specify the property names that should be used for pagination links in the response body when a resource is paginated. You can provide custom property names for the pagination links, and if not specified, the default property names will be used.
205
+ */
206
+ paginatedLinks: {
207
+ first?: string | undefined;
208
+ last?: string | undefined;
209
+ prev?: string | undefined;
210
+ next?: string | undefined;
211
+ };
212
+ /**
213
+ * @description This option allows you to specify the property names that should be used for pagination metadata in the response body when a resource is paginated. You can provide custom property names for properties, and if not specified, the default property names will be used.
214
+ */
215
+ paginatedMeta: {
216
+ to?: string | undefined;
217
+ from?: string | undefined;
218
+ links?: string | undefined;
219
+ path?: string | undefined;
220
+ total?: string | undefined;
221
+ per_page?: string | undefined;
222
+ last_page?: string | undefined;
223
+ current_page?: string | undefined;
224
+ };
192
225
  }
193
226
  //#endregion
194
227
  //#region src/cli/CliApp.d.ts
195
228
  declare class CliApp {
196
229
  command: Command;
197
- private config;
230
+ protected config: Config;
198
231
  constructor(config?: Partial<Config>);
199
232
  /**
200
233
  * Initialize Resora by creating a default config file in the current directory
@@ -491,6 +524,7 @@ declare class GenericResource<R extends NonCollectible | Collectible | ResourceD
491
524
  }
492
525
  //#endregion
493
526
  //#region src/utility.d.ts
527
+ declare const getDefaultConfig: () => Config;
494
528
  /**
495
529
  * Define the configuration for the package
496
530
  *
@@ -501,4 +535,4 @@ declare const defineConfig: (userConfig?: Partial<Omit<Config, "stubs">> & {
501
535
  stubs?: Partial<Config["stubs"]>;
502
536
  }) => Config;
503
537
  //#endregion
504
- export { ApiResource, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ServerResponse, defineConfig };
538
+ export { ApiResource, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ServerResponse, defineConfig, getDefaultConfig };
package/dist/index.d.mts CHANGED
@@ -165,11 +165,11 @@ interface Cursor {
165
165
  }
166
166
  interface Config {
167
167
  /**
168
- * @description The directory where resource files are stored. This is the location where the generated resource files will be saved. It should be a valid path on the file system.
168
+ * @description The directory where resource files are stored. This is the location where the generated resource files will be saved. It should be a valid path on the file system relative to the project root.
169
169
  */
170
170
  resourcesDir: string;
171
171
  /**
172
- * @description The directory where stub files are stored. Stub files are templates used for generating resource files. This should also be a valid path on the file system where the stub templates are located.
172
+ * @description The directory where stub files are stored. Stub files are templates used for generating resource files. This should also be a valid path on the file system relative to the project root where the stub templates are located.
173
173
  */
174
174
  stubsDir: string;
175
175
  /**
@@ -189,12 +189,45 @@ interface Config {
189
189
  */
190
190
  collection: string;
191
191
  };
192
+ /**
193
+ * @description This option allows you to specify the case style that should be used for the keys in API responses returned by the resources.
194
+ */
195
+ preferredCase: 'camel' | 'snake' | 'pascal' | 'kebab';
196
+ /**
197
+ * @description This option allows you to specify the extra properties that should be included in the response body when a resource is paginated. You can choose to include either 'meta', 'links', or both, or you can provide custom property names for these extras.
198
+ */
199
+ paginatedExtras: ['meta', 'links'] | {
200
+ meta?: string | undefined;
201
+ links?: string | undefined;
202
+ };
203
+ /**
204
+ * @description This option allows you to specify the property names that should be used for pagination links in the response body when a resource is paginated. You can provide custom property names for the pagination links, and if not specified, the default property names will be used.
205
+ */
206
+ paginatedLinks: {
207
+ first?: string | undefined;
208
+ last?: string | undefined;
209
+ prev?: string | undefined;
210
+ next?: string | undefined;
211
+ };
212
+ /**
213
+ * @description This option allows you to specify the property names that should be used for pagination metadata in the response body when a resource is paginated. You can provide custom property names for properties, and if not specified, the default property names will be used.
214
+ */
215
+ paginatedMeta: {
216
+ to?: string | undefined;
217
+ from?: string | undefined;
218
+ links?: string | undefined;
219
+ path?: string | undefined;
220
+ total?: string | undefined;
221
+ per_page?: string | undefined;
222
+ last_page?: string | undefined;
223
+ current_page?: string | undefined;
224
+ };
192
225
  }
193
226
  //#endregion
194
227
  //#region src/cli/CliApp.d.ts
195
228
  declare class CliApp {
196
229
  command: Command;
197
- private config;
230
+ protected config: Config;
198
231
  constructor(config?: Partial<Config>);
199
232
  /**
200
233
  * Initialize Resora by creating a default config file in the current directory
@@ -491,6 +524,7 @@ declare class GenericResource<R extends NonCollectible | Collectible | ResourceD
491
524
  }
492
525
  //#endregion
493
526
  //#region src/utility.d.ts
527
+ declare const getDefaultConfig: () => Config;
494
528
  /**
495
529
  * Define the configuration for the package
496
530
  *
@@ -501,4 +535,4 @@ declare const defineConfig: (userConfig?: Partial<Omit<Config, "stubs">> & {
501
535
  stubs?: Partial<Config["stubs"]>;
502
536
  }) => Config;
503
537
  //#endregion
504
- export { ApiResource, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ServerResponse, defineConfig };
538
+ export { ApiResource, CliApp, Collectible, CollectionBody, Config, Cursor, GenericBody, GenericResource, MakeResource, MetaData, NonCollectible, PaginatedMetaData, Pagination, Resource, ResourceBody, ResourceCollection, ResourceData, ResourceDef, ResponseData, ResponseDataCollection, ServerResponse, defineConfig, getDefaultConfig };
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
2
2
  import path, { dirname, join } from "path";
3
3
  import { createRequire } from "module";
4
- import { fileURLToPath } from "url";
5
4
  import { Command } from "@h3ravel/musket";
6
5
 
7
6
  //#region src/ApiResource.ts
@@ -17,9 +16,37 @@ function ApiResource(instance) {
17
16
 
18
17
  //#endregion
19
18
  //#region src/utility.ts
20
- const __dirname = /* @__PURE__ */ path.dirname(fileURLToPath(import.meta.url));
21
- let stubsDir = path.resolve(__dirname, "../node_modules/resora/stubs");
22
- if (!existsSync(stubsDir)) stubsDir = path.resolve(__dirname, "../stubs");
19
+ let stubsDir = path.resolve(process.cwd(), "node_modules/resora/stubs");
20
+ if (!existsSync(stubsDir)) stubsDir = path.resolve(process.cwd(), "stubs");
21
+ const getDefaultConfig = () => {
22
+ return {
23
+ stubsDir,
24
+ preferredCase: "camel",
25
+ paginatedExtras: ["meta", "links"],
26
+ paginatedLinks: {
27
+ first: "first",
28
+ last: "last",
29
+ prev: "prev",
30
+ next: "next"
31
+ },
32
+ paginatedMeta: {
33
+ to: "to",
34
+ from: "from",
35
+ links: "links",
36
+ path: "path",
37
+ total: "total",
38
+ per_page: "per_page",
39
+ last_page: "last_page",
40
+ current_page: "current_page"
41
+ },
42
+ resourcesDir: "src/resources",
43
+ stubs: {
44
+ config: "resora.config.stub",
45
+ resource: "resource.stub",
46
+ collection: "resource.collection.stub"
47
+ }
48
+ };
49
+ };
23
50
  /**
24
51
  * Define the configuration for the package
25
52
  *
@@ -27,19 +54,8 @@ if (!existsSync(stubsDir)) stubsDir = path.resolve(__dirname, "../stubs");
27
54
  * @returns The merged configuration object
28
55
  */
29
56
  const defineConfig = (userConfig = {}) => {
30
- return Object.assign({
31
- resourcesDir: "src/resources",
32
- stubsDir,
33
- stubs: {
34
- config: "resora.config.stub",
35
- resource: "resource.stub",
36
- collection: "resource.collection.stub"
37
- }
38
- }, userConfig, { stubs: Object.assign({
39
- config: "resora.config.stub",
40
- resource: "resource.stub",
41
- collection: "resource.collection.stub"
42
- }, userConfig.stubs || {}) });
57
+ const defaultConfig = getDefaultConfig();
58
+ return Object.assign(defaultConfig, userConfig, { stubs: Object.assign(defaultConfig.stubs, userConfig.stubs || {}) });
43
59
  };
44
60
 
45
61
  //#endregion
@@ -57,7 +73,7 @@ var CliApp = class {
57
73
  ];
58
74
  for (const configPath of possibleConfigPaths) if (existsSync(configPath)) try {
59
75
  const { default: userConfig } = require(configPath);
60
- Object.assign(this.config, defineConfig(userConfig));
76
+ Object.assign(this.config, userConfig);
61
77
  break;
62
78
  } catch (e) {
63
79
  console.error(`Error loading config file at ${configPath}:`, e);
@@ -666,4 +682,4 @@ var Resource = class {
666
682
  };
667
683
 
668
684
  //#endregion
669
- export { ApiResource, CliApp, GenericResource, MakeResource, Resource, ResourceCollection, ServerResponse, defineConfig };
685
+ export { ApiResource, CliApp, GenericResource, MakeResource, Resource, ResourceCollection, ServerResponse, defineConfig, getDefaultConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resora",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "A structured API response layer for Node.js and TypeScript with automatic JSON responses, collection support, and pagination handling.",
5
5
  "keywords": [
6
6
  "api",