@modular-rest/server 1.3.3 → 1.4.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.
- package/package.json +1 -1
- package/src/application.js +7 -7
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -12,8 +12,8 @@ let defaultServiceRoot = __dirname + '/services';
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {{
|
|
14
14
|
* cors: any; // Options for @koa/cors middleware.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* modulesPath: string; // Root directory of your router.js/db.js files.
|
|
16
|
+
* staticPath: string; // Root directory for uploaded files.
|
|
17
17
|
* onBeforeInit: (koaApp) => void; // A callback called before initializing the Koa server.
|
|
18
18
|
* onAfterInit: (koaApp) => void; // A callback called after server initialization.
|
|
19
19
|
* port: number; // Server port.
|
|
@@ -71,9 +71,9 @@ module.exports = async function createRest(options) {
|
|
|
71
71
|
/**
|
|
72
72
|
* Plug In KoaStatic
|
|
73
73
|
*/
|
|
74
|
-
if (options.
|
|
74
|
+
if (options.staticPath)
|
|
75
75
|
app.use(koaStatic({
|
|
76
|
-
rootDir: options.
|
|
76
|
+
rootDir: options.staticPath,
|
|
77
77
|
rootPath: '/assets/',
|
|
78
78
|
|
|
79
79
|
}));
|
|
@@ -118,15 +118,15 @@ module.exports = async function createRest(options) {
|
|
|
118
118
|
*
|
|
119
119
|
* Plug in routes and database
|
|
120
120
|
*/
|
|
121
|
-
if (options.
|
|
121
|
+
if (options.modulesPath) {
|
|
122
122
|
|
|
123
123
|
// Plug in user routes
|
|
124
|
-
await Combination.combineRoutesByFilePath(options.
|
|
124
|
+
await Combination.combineRoutesByFilePath(options.modulesPath, app);
|
|
125
125
|
|
|
126
126
|
// Collect user CollectionDefinitions (db.js files)
|
|
127
127
|
let userDatabaseDetail = [];
|
|
128
128
|
userDatabaseDetail = await Combination.combineModulesByFilePath({
|
|
129
|
-
rootDirectory: options.
|
|
129
|
+
rootDirectory: options.modulesPath,
|
|
130
130
|
filename: {
|
|
131
131
|
name: 'db',
|
|
132
132
|
extension: '.js'
|