@formio/appserver 1.1.2 → 1.1.4
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 +1 -1
- package/lib/index.js +13 -12
- package/lib/server.d.ts +180 -0
- package/lib/server.js +86 -0
- package/package.json +1 -1
- package/server.js +1 -0
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ node index
|
|
|
54
54
|
This library uses environment variables to configure the configurations required to run the server. These are as follows.
|
|
55
55
|
|
|
56
56
|
| Variable Name | Required | Description | Example |
|
|
57
|
-
|
|
57
|
+
|--------------|-----|-----------|-----|
|
|
58
58
|
| MONGO | yes | Your MongoDB Connection string to use the default DB. | mongodb://localhost:27017/appserver |
|
|
59
59
|
| PROJECT_ENDPOINT | yes | The endpoint for your deployed Form.io Enterprise project. | https://mydeployment.com/myproject |
|
|
60
60
|
| PROJECT_KEY | yes | The API Key for your deployed Form.io Enterprise Project. | abc123 |
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Actions = exports.Auth = exports.Database = exports.Processor = exports.Prepper = exports.Server = exports.Modules = void 0;
|
|
7
|
+
// Load the license key.
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
let licenseKey = (0, get_1.default)(process.env, 'LICENSE_KEY', '');
|
|
11
|
+
if (!licenseKey) {
|
|
12
|
+
try {
|
|
13
|
+
licenseKey = fs_1.default.readFileSync(path_1.default.join((0, process_2.cwd)(), 'license.txt'), 'utf8');
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.log('No license key found. Please set the LICENSE_KEY environment variable or create a license.txt file in the root of the project.');
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
const appserver_core_1 = require("@formio/appserver-core");
|
|
8
21
|
const auth_1 = require("./auth");
|
|
9
22
|
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return auth_1.Auth; } });
|
|
@@ -17,22 +30,10 @@ const prepare_1 = require("./prepare");
|
|
|
17
30
|
Object.defineProperty(exports, "Prepper", { enumerable: true, get: function () { return prepare_1.Prepper; } });
|
|
18
31
|
const process_2 = require("process");
|
|
19
32
|
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const fs_1 = __importDefault(require("fs"));
|
|
21
|
-
const get_1 = __importDefault(require("lodash/get"));
|
|
22
33
|
const defaultsDeep_1 = __importDefault(require("lodash/defaultsDeep"));
|
|
23
34
|
const packageJson = require('../package.json');
|
|
24
35
|
const appCorePackage = require('@formio/appserver-core/package.json');
|
|
25
36
|
const corePackage = require('@formio/core');
|
|
26
|
-
// Load the license key.
|
|
27
|
-
let licenseKey = (0, get_1.default)(process.env, 'LICENSE_KEY', '');
|
|
28
|
-
if (!licenseKey) {
|
|
29
|
-
try {
|
|
30
|
-
licenseKey = fs_1.default.readFileSync(path_1.default.join((0, process_2.cwd)(), 'license.txt'), 'utf8');
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
console.error('No license key found. Please set the LICENSE_KEY environment variable or create a license.txt file in the root of the project.');
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
37
|
exports.Modules = {
|
|
37
38
|
db: db_1.Database,
|
|
38
39
|
auth: auth_1.Auth,
|
package/lib/server.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/// <reference types="express" />
|
|
2
|
+
import { Server as CoreServer } from '@formio/appserver-core';
|
|
3
|
+
import { Auth } from "./auth";
|
|
4
|
+
import { Database } from "./db";
|
|
5
|
+
import Actions from "./actions";
|
|
6
|
+
import { Processor } from "./process";
|
|
7
|
+
import { Prepper } from './prepare';
|
|
8
|
+
import { AppServerScope, Processor as ProcessorType, Prepper as PrepperType } from '@formio/appserver-types';
|
|
9
|
+
export declare const Modules: {
|
|
10
|
+
db: typeof Database;
|
|
11
|
+
auth: typeof Auth;
|
|
12
|
+
processor: ProcessorType;
|
|
13
|
+
prepper: PrepperType;
|
|
14
|
+
actions: {
|
|
15
|
+
save: {
|
|
16
|
+
readonly info: {
|
|
17
|
+
name: string;
|
|
18
|
+
title: string;
|
|
19
|
+
description: string;
|
|
20
|
+
priority: number;
|
|
21
|
+
defaults: {
|
|
22
|
+
handler: string[];
|
|
23
|
+
method: string[];
|
|
24
|
+
};
|
|
25
|
+
access: {
|
|
26
|
+
handler: boolean;
|
|
27
|
+
method: boolean;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
mappingComponents(scope: import("@formio/appserver-types").ActionScope): Promise<any>;
|
|
31
|
+
settingsForm(scope: import("@formio/appserver-types").ActionScope): Promise<any>;
|
|
32
|
+
saveToForm(scope: import("@formio/appserver-types").ActionScope, resource: string): undefined;
|
|
33
|
+
childSubmission(scope: import("@formio/appserver-types").ActionScope, req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse, submission: any): any;
|
|
34
|
+
childResponse(scope: import("@formio/appserver-types").ActionScope, req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse): void;
|
|
35
|
+
executor(scope: import("@formio/appserver-types").ActionScope): Promise<(req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
|
|
36
|
+
};
|
|
37
|
+
login: {
|
|
38
|
+
readonly info: {
|
|
39
|
+
name: string;
|
|
40
|
+
title: string;
|
|
41
|
+
description: string;
|
|
42
|
+
priority: number;
|
|
43
|
+
defaults: {
|
|
44
|
+
handler: string[];
|
|
45
|
+
method: string[];
|
|
46
|
+
};
|
|
47
|
+
access: {
|
|
48
|
+
handler: boolean;
|
|
49
|
+
method: boolean;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
settingsForm(scope: import("@formio/appserver-types").ActionScope): Promise<({
|
|
53
|
+
type: string;
|
|
54
|
+
label: string;
|
|
55
|
+
key: string;
|
|
56
|
+
placeholder: string;
|
|
57
|
+
dataSrc: string;
|
|
58
|
+
valueProperty: string;
|
|
59
|
+
data: {
|
|
60
|
+
json: any;
|
|
61
|
+
};
|
|
62
|
+
multiple: boolean;
|
|
63
|
+
validate: {
|
|
64
|
+
required: boolean;
|
|
65
|
+
};
|
|
66
|
+
input?: undefined;
|
|
67
|
+
description?: undefined;
|
|
68
|
+
defaultValue?: undefined;
|
|
69
|
+
suffix?: undefined;
|
|
70
|
+
} | {
|
|
71
|
+
type: string;
|
|
72
|
+
input: boolean;
|
|
73
|
+
label: string;
|
|
74
|
+
key: string;
|
|
75
|
+
placeholder: string;
|
|
76
|
+
dataSrc: string;
|
|
77
|
+
valueProperty: string;
|
|
78
|
+
data: {
|
|
79
|
+
json: any;
|
|
80
|
+
};
|
|
81
|
+
multiple: boolean;
|
|
82
|
+
validate: {
|
|
83
|
+
required: boolean;
|
|
84
|
+
};
|
|
85
|
+
description?: undefined;
|
|
86
|
+
defaultValue?: undefined;
|
|
87
|
+
suffix?: undefined;
|
|
88
|
+
} | {
|
|
89
|
+
type: string;
|
|
90
|
+
key: string;
|
|
91
|
+
input: boolean;
|
|
92
|
+
label: string;
|
|
93
|
+
description: string;
|
|
94
|
+
defaultValue: string;
|
|
95
|
+
placeholder?: undefined;
|
|
96
|
+
dataSrc?: undefined;
|
|
97
|
+
valueProperty?: undefined;
|
|
98
|
+
data?: undefined;
|
|
99
|
+
multiple?: undefined;
|
|
100
|
+
validate?: undefined;
|
|
101
|
+
suffix?: undefined;
|
|
102
|
+
} | {
|
|
103
|
+
type: string;
|
|
104
|
+
key: string;
|
|
105
|
+
input: boolean;
|
|
106
|
+
label: string;
|
|
107
|
+
description: string;
|
|
108
|
+
defaultValue: string;
|
|
109
|
+
suffix: string;
|
|
110
|
+
placeholder?: undefined;
|
|
111
|
+
dataSrc?: undefined;
|
|
112
|
+
valueProperty?: undefined;
|
|
113
|
+
data?: undefined;
|
|
114
|
+
multiple?: undefined;
|
|
115
|
+
validate?: undefined;
|
|
116
|
+
})[]>;
|
|
117
|
+
waitText(time: number): string;
|
|
118
|
+
checkAttempts(scope: import("@formio/appserver-types").ActionScope, error: any, user: import("@formio/appserver-types").User): Promise<any>;
|
|
119
|
+
executor(scope: import("@formio/appserver-types").ActionScope): Promise<(req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse, next: import("express").NextFunction) => Promise<void>>;
|
|
120
|
+
};
|
|
121
|
+
role: {
|
|
122
|
+
readonly info: {
|
|
123
|
+
name: string;
|
|
124
|
+
title: string;
|
|
125
|
+
description: string;
|
|
126
|
+
priority: number;
|
|
127
|
+
defaults: {
|
|
128
|
+
handler: string[];
|
|
129
|
+
method: string[];
|
|
130
|
+
};
|
|
131
|
+
access: {
|
|
132
|
+
handler: boolean;
|
|
133
|
+
method: boolean;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
settingsForm(scope: import("@formio/appserver-types").ActionScope): Promise<({
|
|
137
|
+
type: string;
|
|
138
|
+
input: boolean;
|
|
139
|
+
label: string;
|
|
140
|
+
key: string;
|
|
141
|
+
placeholder: string;
|
|
142
|
+
template: string;
|
|
143
|
+
dataSrc: string;
|
|
144
|
+
data: {
|
|
145
|
+
json: string;
|
|
146
|
+
};
|
|
147
|
+
valueProperty: string;
|
|
148
|
+
multiple: boolean;
|
|
149
|
+
validate: {
|
|
150
|
+
required: boolean;
|
|
151
|
+
};
|
|
152
|
+
} | {
|
|
153
|
+
type: string;
|
|
154
|
+
input: boolean;
|
|
155
|
+
label: string;
|
|
156
|
+
key: string;
|
|
157
|
+
placeholder: string;
|
|
158
|
+
template: string;
|
|
159
|
+
dataSrc: string;
|
|
160
|
+
data: {
|
|
161
|
+
json: unknown[];
|
|
162
|
+
};
|
|
163
|
+
valueProperty: string;
|
|
164
|
+
multiple: boolean;
|
|
165
|
+
validate: {
|
|
166
|
+
required: boolean;
|
|
167
|
+
};
|
|
168
|
+
})[]>;
|
|
169
|
+
executor(scope: import("@formio/appserver-types").ActionScope): Promise<(req: import("@formio/appserver-types").SubmissionRequest, res: import("@formio/appserver-types").SubmissionResponse, next: import("express").NextFunction) => Promise<void | import("@formio/appserver-types").SubmissionResponse>>;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
export declare class Server extends CoreServer {
|
|
174
|
+
constructor(config?: AppServerScope);
|
|
175
|
+
}
|
|
176
|
+
export { Prepper };
|
|
177
|
+
export { Processor };
|
|
178
|
+
export { Database };
|
|
179
|
+
export { Auth };
|
|
180
|
+
export { Actions };
|
package/lib/server.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Actions = exports.Auth = exports.Database = exports.Processor = exports.Prepper = exports.Server = exports.Modules = void 0;
|
|
7
|
+
// Load the license key.
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
let licenseKey = (0, get_1.default)(process.env, 'LICENSE_KEY', '');
|
|
11
|
+
if (!licenseKey) {
|
|
12
|
+
try {
|
|
13
|
+
licenseKey = fs_1.default.readFileSync(path_1.default.join((0, process_2.cwd)(), 'license.txt'), 'utf8');
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.log('No license key found. Please set the LICENSE_KEY environment variable or create a license.txt file in the root of the project.');
|
|
17
|
+
process.exit();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const appserver_core_1 = require("@formio/appserver-core");
|
|
21
|
+
const auth_1 = require("./auth");
|
|
22
|
+
Object.defineProperty(exports, "Auth", { enumerable: true, get: function () { return auth_1.Auth; } });
|
|
23
|
+
const db_1 = require("./db");
|
|
24
|
+
Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return db_1.Database; } });
|
|
25
|
+
const actions_1 = __importDefault(require("./actions"));
|
|
26
|
+
exports.Actions = actions_1.default;
|
|
27
|
+
const process_1 = require("./process");
|
|
28
|
+
Object.defineProperty(exports, "Processor", { enumerable: true, get: function () { return process_1.Processor; } });
|
|
29
|
+
const prepare_1 = require("./prepare");
|
|
30
|
+
Object.defineProperty(exports, "Prepper", { enumerable: true, get: function () { return prepare_1.Prepper; } });
|
|
31
|
+
const process_2 = require("process");
|
|
32
|
+
const path_1 = __importDefault(require("path"));
|
|
33
|
+
const defaultsDeep_1 = __importDefault(require("lodash/defaultsDeep"));
|
|
34
|
+
const packageJson = require('../package.json');
|
|
35
|
+
const appCorePackage = require('@formio/appserver-core/package.json');
|
|
36
|
+
const corePackage = require('@formio/core');
|
|
37
|
+
exports.Modules = {
|
|
38
|
+
db: db_1.Database,
|
|
39
|
+
auth: auth_1.Auth,
|
|
40
|
+
processor: process_1.Processor,
|
|
41
|
+
prepper: prepare_1.Prepper,
|
|
42
|
+
actions: actions_1.default
|
|
43
|
+
};
|
|
44
|
+
class Server extends appserver_core_1.Server {
|
|
45
|
+
constructor(config = {}) {
|
|
46
|
+
if (config.processors) {
|
|
47
|
+
exports.Modules.processor.processors = config.processors;
|
|
48
|
+
}
|
|
49
|
+
if (config.preppers) {
|
|
50
|
+
exports.Modules.prepper.preppers = config.preppers;
|
|
51
|
+
}
|
|
52
|
+
if (!config.actions) {
|
|
53
|
+
config.actions = {};
|
|
54
|
+
}
|
|
55
|
+
super({
|
|
56
|
+
db: config.db || new exports.Modules.db({
|
|
57
|
+
url: (0, get_1.default)(process.env, 'MONGO', "mongodb://localhost:27017/subserver"),
|
|
58
|
+
config: (0, get_1.default)(process.env, 'MONGO_CONFIG', "{}")
|
|
59
|
+
}),
|
|
60
|
+
processor: exports.Modules.processor,
|
|
61
|
+
prepper: exports.Modules.prepper,
|
|
62
|
+
auth: config.auth || new exports.Modules.auth(),
|
|
63
|
+
actions: Object.assign(Object.assign({}, exports.Modules.actions), config.actions),
|
|
64
|
+
config: (0, defaultsDeep_1.default)(config.config || {}, {
|
|
65
|
+
license: licenseKey,
|
|
66
|
+
cache: ((0, get_1.default)(process.env, 'PROJECT_CACHE', true)).toString() === 'true',
|
|
67
|
+
status: {
|
|
68
|
+
'@formio/appserver': packageJson.version,
|
|
69
|
+
'@formio/appserver-core': appCorePackage.version,
|
|
70
|
+
'@formio/core': corePackage.version
|
|
71
|
+
},
|
|
72
|
+
auth: {
|
|
73
|
+
portal: (0, get_1.default)(process.env, 'PORTAL_SECRET', ''),
|
|
74
|
+
secret: (0, get_1.default)(process.env, 'JWT_SECRET', ''),
|
|
75
|
+
expire: (0, get_1.default)(process.env, 'JWT_EXPIRE_TIME', 240)
|
|
76
|
+
},
|
|
77
|
+
project: {
|
|
78
|
+
url: (0, get_1.default)(process.env, 'PROJECT_ENDPOINT', ''),
|
|
79
|
+
key: (0, get_1.default)(process.env, 'PROJECT_KEY', '')
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
hooks: config.hooks || {}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.Server = Server;
|
package/package.json
CHANGED
package/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lib/server.js';
|