@modular-rest/server 1.12.1 → 1.13.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.
@@ -102,7 +102,7 @@ class User {
102
102
  static loadFromModel(model) {
103
103
  return new Promise((done, reject) => {
104
104
  // check required fields
105
- const isValidData = (0, validator_1.validator)(model, 'fullname email password permission');
105
+ const isValidData = (0, validator_1.validator)(model, '_id permissionGroup');
106
106
  if (!isValidData.isValid) {
107
107
  return reject(User.notValid(model));
108
108
  }
package/dist/config.d.ts CHANGED
@@ -3,9 +3,12 @@ import { CollectionDefinition } from './class/collection_definition';
3
3
  import { PermissionGroup } from './class/security';
4
4
  import { CmsTrigger } from './class/cms_trigger';
5
5
  import { DefinedFunction } from './services/functions/service';
6
- import cors from '@koa/cors';
6
+ import { Options as KoaCorsOptions } from '@koa/cors';
7
7
  import { Options as KoaStaticOptionsBase } from 'koa-static';
8
- export interface StaticPathOptions extends KoaStaticOptionsBase {
8
+ /**
9
+ * The options for the static file server, it's a combination of modular-rest and [koa-static options](https://github.com/koajs/static?tab=readme-ov-file#options)
10
+ */
11
+ export type StaticPathOptions = KoaStaticOptionsBase & {
9
12
  /**
10
13
  * The actual path of the static files on your server
11
14
  */
@@ -14,7 +17,7 @@ export interface StaticPathOptions extends KoaStaticOptionsBase {
14
17
  * The path you want to serve the static files from
15
18
  */
16
19
  path: string;
17
- }
20
+ };
18
21
  /**
19
22
  * JWT keypair configuration
20
23
  * @interface KeyPair
@@ -30,12 +33,10 @@ interface KeyPair {
30
33
  * @interface MongoOptions
31
34
  * @property {string} dbPrefix - Prefix for database names
32
35
  * @property {string} mongoBaseAddress - MongoDB connection URL
33
- * @property {string} [addressMap] - Optional address mapping configuration
34
36
  */
35
37
  interface MongoOptions {
36
38
  dbPrefix: string;
37
39
  mongoBaseAddress: string;
38
- addressMap?: string;
39
40
  }
40
41
  /**
41
42
  * Admin user configuration
@@ -50,7 +51,7 @@ interface AdminUser {
50
51
  /**
51
52
  * Configuration options for creating a REST API instance
52
53
  * @interface RestOptions
53
- * @property {cors.Options} [cors] - CORS configuration options
54
+ * @property {KoaCorsOptions} [cors] - CORS configuration [options](https://github.com/koajs/cors?tab=readme-ov-file#corsoptions)
54
55
  * @property {string} [modulesPath] - Path to custom modules directory
55
56
  * @property {string} [uploadDirectory] - Directory for file uploads
56
57
  * @property {any} [koaBodyOptions] - Options for koa-body middleware
@@ -70,7 +71,7 @@ interface AdminUser {
70
71
  * @property {DefinedFunction[]} [functions] - Custom API functions
71
72
  */
72
73
  export interface RestOptions {
73
- cors?: cors.Options;
74
+ cors?: KoaCorsOptions;
74
75
  modulesPath?: string;
75
76
  uploadDirectory?: string;
76
77
  koaBodyOptions?: any;
@@ -1,2 +1,2 @@
1
- import { PermissionGroup } from './index';
1
+ import { PermissionGroup } from './class/security';
2
2
  export declare const permissionGroups: PermissionGroup[];
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.permissionGroups = void 0;
4
- const index_1 = require("./index");
4
+ const security_1 = require("./class/security");
5
5
  exports.permissionGroups = [
6
- new index_1.PermissionGroup({
6
+ new security_1.PermissionGroup({
7
7
  title: 'anonymous',
8
8
  isAnonymous: true,
9
9
  allowedAccessTypes: ['anonymous_access'],
10
10
  }),
11
- new index_1.PermissionGroup({
11
+ new security_1.PermissionGroup({
12
12
  title: 'end-user',
13
13
  isDefault: true,
14
14
  allowedAccessTypes: [
@@ -18,7 +18,7 @@ exports.permissionGroups = [
18
18
  'remove_file_access',
19
19
  ],
20
20
  }),
21
- new index_1.PermissionGroup({
21
+ new security_1.PermissionGroup({
22
22
  title: 'administrator',
23
23
  allowedAccessTypes: [
24
24
  'user_access',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modular-rest/server",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "TypeScript version of a nodejs module based on KOAJS for developing Rest-APIs in a modular solution.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/class/user.ts CHANGED
@@ -146,7 +146,7 @@ export class User {
146
146
  static loadFromModel(model: any): Promise<User> {
147
147
  return new Promise((done, reject) => {
148
148
  // check required fields
149
- const isValidData = validateObject(model, 'fullname email password permission');
149
+ const isValidData = validateObject(model, '_id permissionGroup');
150
150
 
151
151
  if (!isValidData.isValid) {
152
152
  return reject(User.notValid(model));
package/src/config.ts CHANGED
@@ -4,10 +4,13 @@ import { CollectionDefinition } from './class/collection_definition';
4
4
  import { PermissionGroup } from './class/security';
5
5
  import { CmsTrigger } from './class/cms_trigger';
6
6
  import { DefinedFunction } from './services/functions/service';
7
- import cors from '@koa/cors';
7
+ import { Options as KoaCorsOptions } from '@koa/cors';
8
8
  import { Options as KoaStaticOptionsBase } from 'koa-static';
9
9
 
10
- export interface StaticPathOptions extends KoaStaticOptionsBase {
10
+ /**
11
+ * The options for the static file server, it's a combination of modular-rest and [koa-static options](https://github.com/koajs/static?tab=readme-ov-file#options)
12
+ */
13
+ export type StaticPathOptions = KoaStaticOptionsBase & {
11
14
  /**
12
15
  * The actual path of the static files on your server
13
16
  */
@@ -16,7 +19,7 @@ export interface StaticPathOptions extends KoaStaticOptionsBase {
16
19
  * The path you want to serve the static files from
17
20
  */
18
21
  path: string;
19
- }
22
+ };
20
23
 
21
24
  /**
22
25
  * JWT keypair configuration
@@ -34,12 +37,10 @@ interface KeyPair {
34
37
  * @interface MongoOptions
35
38
  * @property {string} dbPrefix - Prefix for database names
36
39
  * @property {string} mongoBaseAddress - MongoDB connection URL
37
- * @property {string} [addressMap] - Optional address mapping configuration
38
40
  */
39
41
  interface MongoOptions {
40
42
  dbPrefix: string;
41
43
  mongoBaseAddress: string;
42
- addressMap?: string;
43
44
  }
44
45
 
45
46
  /**
@@ -56,7 +57,7 @@ interface AdminUser {
56
57
  /**
57
58
  * Configuration options for creating a REST API instance
58
59
  * @interface RestOptions
59
- * @property {cors.Options} [cors] - CORS configuration options
60
+ * @property {KoaCorsOptions} [cors] - CORS configuration [options](https://github.com/koajs/cors?tab=readme-ov-file#corsoptions)
60
61
  * @property {string} [modulesPath] - Path to custom modules directory
61
62
  * @property {string} [uploadDirectory] - Directory for file uploads
62
63
  * @property {any} [koaBodyOptions] - Options for koa-body middleware
@@ -76,7 +77,7 @@ interface AdminUser {
76
77
  * @property {DefinedFunction[]} [functions] - Custom API functions
77
78
  */
78
79
  export interface RestOptions {
79
- cors?: cors.Options;
80
+ cors?: KoaCorsOptions;
80
81
  modulesPath?: string;
81
82
  uploadDirectory?: string;
82
83
  koaBodyOptions?: any;
@@ -1,4 +1,4 @@
1
- import { PermissionGroup } from './index';
1
+ import { PermissionGroup } from './class/security';
2
2
 
3
3
  export const permissionGroups = [
4
4
  new PermissionGroup({
package/typedoc.mjs CHANGED
@@ -2,10 +2,10 @@ export default {
2
2
  plugin: ['typedoc-plugin-missing-exports', 'typedoc-plugin-markdown'],
3
3
 
4
4
  disableSources: true,
5
- excludeProtected: false,
5
+ excludeProtected: true,
6
6
  excludeInternal: false,
7
7
  excludePrivate: false,
8
- excludeExternals: false,
8
+ excludeExternals: true,
9
9
 
10
10
  //
11
11
  // Formatting `typedoc-plugin-markdown`