@nocobase/server 0.7.0-alpha.7 → 0.7.0-alpha.72
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/lib/acl/available-action.js +37 -35
- package/lib/acl/index.js +45 -21
- package/lib/app-manager.d.ts +3 -3
- package/lib/app-manager.js +151 -72
- package/lib/application.d.ts +3 -2
- package/lib/application.js +291 -153
- package/lib/commands/console.d.ts +2 -3
- package/lib/commands/console.js +33 -24
- package/lib/commands/db-auth.d.ts +3 -0
- package/lib/commands/db-auth.js +26 -0
- package/lib/commands/db-clean.d.ts +3 -0
- package/lib/commands/db-clean.js +27 -0
- package/lib/commands/db-sync.d.ts +2 -4
- package/lib/commands/db-sync.js +25 -23
- package/lib/commands/index.d.ts +1 -2
- package/lib/commands/index.js +29 -29
- package/lib/commands/install.d.ts +2 -4
- package/lib/commands/install.js +68 -20
- package/lib/commands/start.d.ts +2 -4
- package/lib/commands/start.js +28 -22
- package/lib/commands/upgrade.d.ts +6 -0
- package/lib/commands/upgrade.js +45 -0
- package/lib/helper.js +132 -61
- package/lib/index.js +85 -32
- package/lib/middlewares/data-wrapping.js +65 -55
- package/lib/middlewares/index.js +30 -14
- package/lib/middlewares/table2resource.js +89 -52
- package/lib/plugin-manager.js +124 -55
- package/lib/plugin.js +65 -45
- package/lib/read-config.js +159 -64
- package/package.json +8 -13
- package/esm/acl/available-action.d.ts +0 -5
- package/esm/acl/available-action.js +0 -36
- package/esm/acl/available-action.js.map +0 -1
- package/esm/acl/index.d.ts +0 -2
- package/esm/acl/index.js +0 -19
- package/esm/acl/index.js.map +0 -1
- package/esm/app-manager.d.ts +0 -19
- package/esm/app-manager.js +0 -69
- package/esm/app-manager.js.map +0 -1
- package/esm/application.d.ts +0 -97
- package/esm/application.js +0 -156
- package/esm/application.js.map +0 -1
- package/esm/commands/console.d.ts +0 -4
- package/esm/commands/console.js +0 -25
- package/esm/commands/console.js.map +0 -1
- package/esm/commands/create-plugin/create-plugin.d.ts +0 -2
- package/esm/commands/create-plugin/create-plugin.js +0 -29
- package/esm/commands/create-plugin/create-plugin.js.map +0 -1
- package/esm/commands/create-plugin/index.d.ts +0 -5
- package/esm/commands/create-plugin/index.js +0 -6
- package/esm/commands/create-plugin/index.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js +0 -11
- package/esm/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/esm/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/esm/commands/create-plugin/resources/templates/plugin.js +0 -12
- package/esm/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/esm/commands/db-sync.d.ts +0 -5
- package/esm/commands/db-sync.js +0 -25
- package/esm/commands/db-sync.js.map +0 -1
- package/esm/commands/index.d.ts +0 -3
- package/esm/commands/index.js +0 -26
- package/esm/commands/index.js.map +0 -1
- package/esm/commands/install.d.ts +0 -5
- package/esm/commands/install.js +0 -23
- package/esm/commands/install.js.map +0 -1
- package/esm/commands/start.d.ts +0 -5
- package/esm/commands/start.js +0 -23
- package/esm/commands/start.js.map +0 -1
- package/esm/helper.d.ts +0 -7
- package/esm/helper.js +0 -59
- package/esm/helper.js.map +0 -1
- package/esm/index.d.ts +0 -7
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/middlewares/data-wrapping.d.ts +0 -3
- package/esm/middlewares/data-wrapping.js +0 -54
- package/esm/middlewares/data-wrapping.js.map +0 -1
- package/esm/middlewares/index.d.ts +0 -2
- package/esm/middlewares/index.js +0 -3
- package/esm/middlewares/index.js.map +0 -1
- package/esm/middlewares/table2resource.d.ts +0 -6
- package/esm/middlewares/table2resource.js +0 -51
- package/esm/middlewares/table2resource.js.map +0 -1
- package/esm/plugin-manager.d.ts +0 -23
- package/esm/plugin-manager.js +0 -57
- package/esm/plugin-manager.js.map +0 -1
- package/esm/plugin.d.ts +0 -32
- package/esm/plugin.js +0 -43
- package/esm/plugin.js.map +0 -1
- package/esm/read-config.d.ts +0 -8
- package/esm/read-config.js +0 -63
- package/esm/read-config.js.map +0 -1
- package/lib/acl/available-action.js.map +0 -1
- package/lib/acl/index.js.map +0 -1
- package/lib/app-manager.js.map +0 -1
- package/lib/application.js.map +0 -1
- package/lib/commands/console.js.map +0 -1
- package/lib/commands/create-plugin/create-plugin.d.ts +0 -2
- package/lib/commands/create-plugin/create-plugin.js +0 -31
- package/lib/commands/create-plugin/create-plugin.js.map +0 -1
- package/lib/commands/create-plugin/index.d.ts +0 -5
- package/lib/commands/create-plugin/index.js +0 -8
- package/lib/commands/create-plugin/index.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/package-json.d.ts +0 -11
- package/lib/commands/create-plugin/resources/templates/package-json.js +0 -13
- package/lib/commands/create-plugin/resources/templates/package-json.js.map +0 -1
- package/lib/commands/create-plugin/resources/templates/plugin.d.ts +0 -4
- package/lib/commands/create-plugin/resources/templates/plugin.js +0 -33
- package/lib/commands/create-plugin/resources/templates/plugin.js.map +0 -1
- package/lib/commands/db-sync.js.map +0 -1
- package/lib/commands/index.js.map +0 -1
- package/lib/commands/install.js.map +0 -1
- package/lib/commands/start.js.map +0 -1
- package/lib/helper.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/middlewares/data-wrapping.js.map +0 -1
- package/lib/middlewares/index.js.map +0 -1
- package/lib/middlewares/table2resource.js.map +0 -1
- package/lib/plugin-manager.js.map +0 -1
- package/lib/plugin.js.map +0 -1
- package/lib/read-config.js.map +0 -1
- package/tsconfig.build.json +0 -9
package/lib/commands/index.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
exports
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.registerCli = registerCli;
|
|
7
|
+
|
|
8
|
+
function registerCli(app) {
|
|
9
|
+
require('./console').default(app);
|
|
10
|
+
|
|
11
|
+
require('./db-auth').default(app);
|
|
12
|
+
|
|
13
|
+
require('./db-clean').default(app);
|
|
14
|
+
|
|
15
|
+
require('./db-sync').default(app);
|
|
16
|
+
|
|
17
|
+
require('./install').default(app);
|
|
18
|
+
|
|
19
|
+
require('./start').default(app);
|
|
20
|
+
|
|
21
|
+
require('./upgrade').default(app); // development only with @nocobase/cli
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
app.command('build').argument('[packages...]');
|
|
25
|
+
app.command('clean');
|
|
26
|
+
app.command('dev').usage('[options]').option('-p, --port [port]').option('--client').option('--server');
|
|
27
|
+
app.command('doc').argument('[cmd]', '', 'dev');
|
|
28
|
+
app.command('test').option('-c, --db-clean');
|
|
29
|
+
app.command('umi');
|
|
30
|
+
}
|
package/lib/commands/install.js
CHANGED
|
@@ -1,25 +1,73 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _chalk() {
|
|
9
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
10
|
+
|
|
11
|
+
_chalk = function _chalk() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
+
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
+
|
|
24
|
+
var _default = app => {
|
|
25
|
+
app.command('install').option('-f, --force').option('-c, --clean').option('-s, --silent').option('-r, --repeat [repeat]').action( /*#__PURE__*/_asyncToGenerator(function* (...cliArgs) {
|
|
26
|
+
let installed = false;
|
|
27
|
+
const opts = cliArgs[0];
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
yield app.db.auth({
|
|
31
|
+
repeat: opts.repeat || 1
|
|
32
|
+
});
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.log(_chalk().default.red('Unable to connect to the database. Please check the database environment variables in the .env file.'));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.clean) && !(opts === null || opts === void 0 ? void 0 : opts.force)) {
|
|
39
|
+
const tables = yield app.db.sequelize.getQueryInterface().showAllTables();
|
|
40
|
+
|
|
41
|
+
if (tables.includes('collections')) {
|
|
42
|
+
installed = true;
|
|
43
|
+
|
|
44
|
+
if (!opts.silent) {
|
|
45
|
+
console.log('NocoBase is already installed. To reinstall, please execute:');
|
|
46
|
+
console.log();
|
|
47
|
+
let command = '$ yarn nocobase install -f';
|
|
48
|
+
console.log(_chalk().default.yellow(command));
|
|
49
|
+
console.log();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!opts.silent || !installed) {
|
|
57
|
+
console.log(`Start installing NocoBase`);
|
|
58
|
+
}
|
|
59
|
+
|
|
14
60
|
yield app.install({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
61
|
+
cliArgs,
|
|
62
|
+
clean: opts.clean,
|
|
63
|
+
sync: {
|
|
64
|
+
force: opts.force
|
|
65
|
+
}
|
|
20
66
|
});
|
|
21
67
|
yield app.stop({
|
|
22
|
-
|
|
68
|
+
cliArgs
|
|
23
69
|
});
|
|
24
|
-
});
|
|
25
|
-
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.default = _default;
|
package/lib/commands/start.d.ts
CHANGED
package/lib/commands/start.js
CHANGED
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
9
|
+
|
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
+
|
|
12
|
+
var _default = app => {
|
|
13
|
+
app.command('start').option('-s, --silent').option('-p, --port [post]').option('-h, --host [host]').action( /*#__PURE__*/_asyncToGenerator(function* (...cliArgs) {
|
|
14
|
+
const opts = cliArgs[0];
|
|
15
|
+
const port = opts.port || process.env.APP_PORT || 13000;
|
|
16
|
+
const host = opts.host || process.env.APP_HOST || '0.0.0.0';
|
|
16
17
|
yield app.start({
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
cliArgs,
|
|
19
|
+
listen: {
|
|
20
|
+
port,
|
|
21
|
+
host
|
|
22
|
+
}
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
|
|
25
|
+
if (!opts.silent) {
|
|
26
|
+
console.log(`🚀 NocoBase server running at: http://${host === '0.0.0.0' ? 'localhost' : host}:${port}/`);
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.default = _default;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _chalk() {
|
|
9
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
10
|
+
|
|
11
|
+
_chalk = function _chalk() {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
21
|
+
|
|
22
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* TODO
|
|
26
|
+
*/
|
|
27
|
+
var _default = app => {
|
|
28
|
+
app.command('upgrade').action( /*#__PURE__*/_asyncToGenerator(function* (...cliArgs) {
|
|
29
|
+
const opts = cliArgs[0];
|
|
30
|
+
console.log('upgrading...');
|
|
31
|
+
const force = false;
|
|
32
|
+
yield app.db.sync({
|
|
33
|
+
force,
|
|
34
|
+
alter: {
|
|
35
|
+
drop: force
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
yield app.stop({
|
|
39
|
+
cliArgs
|
|
40
|
+
});
|
|
41
|
+
console.log(_chalk().default.green(`✨ NocoBase has been upgraded to v${app.getVersion()}`));
|
|
42
|
+
}));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
exports.default = _default;
|
package/lib/helper.js
CHANGED
|
@@ -1,69 +1,140 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDatabase = createDatabase;
|
|
7
|
+
exports.createI18n = createI18n;
|
|
8
|
+
exports.createResourcer = createResourcer;
|
|
9
|
+
exports.registerMiddlewares = registerMiddlewares;
|
|
10
|
+
|
|
11
|
+
function _cors() {
|
|
12
|
+
const data = _interopRequireDefault(require("@koa/cors"));
|
|
13
|
+
|
|
14
|
+
_cors = function _cors() {
|
|
15
|
+
return data;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _database() {
|
|
22
|
+
const data = _interopRequireDefault(require("@nocobase/database"));
|
|
23
|
+
|
|
24
|
+
_database = function _database() {
|
|
25
|
+
return data;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return data;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function _resourcer() {
|
|
32
|
+
const data = _interopRequireDefault(require("@nocobase/resourcer"));
|
|
33
|
+
|
|
34
|
+
_resourcer = function _resourcer() {
|
|
35
|
+
return data;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _i18next() {
|
|
42
|
+
const data = _interopRequireDefault(require("i18next"));
|
|
43
|
+
|
|
44
|
+
_i18next = function _i18next() {
|
|
45
|
+
return data;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _koaBodyparser() {
|
|
52
|
+
const data = _interopRequireDefault(require("koa-bodyparser"));
|
|
53
|
+
|
|
54
|
+
_koaBodyparser = function _koaBodyparser() {
|
|
55
|
+
return data;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var _dataWrapping = require("./middlewares/data-wrapping");
|
|
62
|
+
|
|
63
|
+
var _table2resource = require("./middlewares/table2resource");
|
|
64
|
+
|
|
65
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
66
|
+
|
|
67
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
68
|
+
|
|
69
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
70
|
+
|
|
71
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
72
|
+
|
|
73
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
74
|
+
|
|
75
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
76
|
+
|
|
23
77
|
function createI18n(options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
78
|
+
const instance = _i18next().default.createInstance();
|
|
79
|
+
|
|
80
|
+
instance.init(_objectSpread({
|
|
81
|
+
lng: 'en-US',
|
|
82
|
+
resources: {}
|
|
83
|
+
}, options.i18n));
|
|
84
|
+
return instance;
|
|
27
85
|
}
|
|
28
|
-
|
|
86
|
+
|
|
29
87
|
function createDatabase(options) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
88
|
+
if (options.database instanceof _database().default) {
|
|
89
|
+
return options.database;
|
|
90
|
+
} else {
|
|
91
|
+
return new (_database().default)(options.database);
|
|
92
|
+
}
|
|
36
93
|
}
|
|
37
|
-
|
|
94
|
+
|
|
38
95
|
function createResourcer(options) {
|
|
39
|
-
|
|
96
|
+
return new (_resourcer().default)(_objectSpread({}, options.resourcer));
|
|
40
97
|
}
|
|
41
|
-
|
|
98
|
+
|
|
42
99
|
function registerMiddlewares(app, options) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
100
|
+
if (options.bodyParser !== false) {
|
|
101
|
+
app.use((0, _koaBodyparser().default)(_objectSpread({}, options.bodyParser)));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
app.use((0, _cors().default)(_objectSpread({
|
|
105
|
+
exposeHeaders: ['content-disposition']
|
|
106
|
+
}, options.cors)));
|
|
107
|
+
app.use( /*#__PURE__*/function () {
|
|
108
|
+
var _ref = _asyncToGenerator(function* (ctx, next) {
|
|
109
|
+
ctx.getBearerToken = () => {
|
|
110
|
+
return ctx.get('Authorization').replace(/^Bearer\s+/gi, '');
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
ctx.db = app.db;
|
|
114
|
+
ctx.resourcer = app.resourcer;
|
|
115
|
+
const i18n = app.i18n.cloneInstance({
|
|
116
|
+
initImmediate: false
|
|
117
|
+
});
|
|
118
|
+
ctx.i18n = i18n;
|
|
119
|
+
ctx.t = i18n.t.bind(i18n);
|
|
120
|
+
const lng = ctx.get('X-Locale') || ctx.request.query.locale || ctx.acceptsLanguages().shift() || 'en-US';
|
|
121
|
+
|
|
122
|
+
if (lng !== '*' && lng) {
|
|
123
|
+
i18n.changeLanguage(lng);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
yield next();
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return function (_x, _x2) {
|
|
130
|
+
return _ref.apply(this, arguments);
|
|
131
|
+
};
|
|
132
|
+
}());
|
|
133
|
+
|
|
134
|
+
if (options.dataWrapping !== false) {
|
|
135
|
+
app.use((0, _dataWrapping.dataWrapping)());
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
app.use((0, _table2resource.table2resource)());
|
|
139
|
+
app.use(app.resourcer.restApiMiddleware());
|
|
140
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,35 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
13
5
|
});
|
|
14
|
-
var
|
|
15
|
-
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
AppManager: true,
|
|
8
|
+
middlewares: true
|
|
16
9
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
10
|
+
Object.defineProperty(exports, "AppManager", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _appManager.AppManager;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "default", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _application.Application;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
exports.middlewares = void 0;
|
|
23
|
+
|
|
24
|
+
var _appManager = require("./app-manager");
|
|
25
|
+
|
|
26
|
+
var _application = require("./application");
|
|
27
|
+
|
|
28
|
+
Object.keys(_application).forEach(function (key) {
|
|
29
|
+
if (key === "default" || key === "__esModule") return;
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
+
if (key in exports && exports[key] === _application[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function get() {
|
|
35
|
+
return _application[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
var _middlewares = _interopRequireWildcard(require("./middlewares"));
|
|
41
|
+
|
|
42
|
+
exports.middlewares = _middlewares;
|
|
43
|
+
|
|
44
|
+
var _plugin = require("./plugin");
|
|
45
|
+
|
|
46
|
+
Object.keys(_plugin).forEach(function (key) {
|
|
47
|
+
if (key === "default" || key === "__esModule") return;
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
49
|
+
if (key in exports && exports[key] === _plugin[key]) return;
|
|
50
|
+
Object.defineProperty(exports, key, {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function get() {
|
|
53
|
+
return _plugin[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
var _pluginManager = require("./plugin-manager");
|
|
59
|
+
|
|
60
|
+
Object.keys(_pluginManager).forEach(function (key) {
|
|
61
|
+
if (key === "default" || key === "__esModule") return;
|
|
62
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
63
|
+
if (key in exports && exports[key] === _pluginManager[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function get() {
|
|
67
|
+
return _pluginManager[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _readConfig = require("./read-config");
|
|
73
|
+
|
|
74
|
+
Object.keys(_readConfig).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
77
|
+
if (key in exports && exports[key] === _readConfig[key]) return;
|
|
78
|
+
Object.defineProperty(exports, key, {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _readConfig[key];
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
87
|
+
|
|
88
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|