@modular-rest/server 1.5.0 → 1.5.2
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 +52 -9
package/package.json
CHANGED
package/src/application.js
CHANGED
|
@@ -9,13 +9,61 @@ let UserService = require("./services/user_manager/service");
|
|
|
9
9
|
|
|
10
10
|
let defaultServiceRoot = __dirname + "/services";
|
|
11
11
|
|
|
12
|
+
// staticOptions = {
|
|
13
|
+
// /**
|
|
14
|
+
// * directory that is to be served
|
|
15
|
+
// */
|
|
16
|
+
// rootDir?: string | undefined;
|
|
17
|
+
// /**
|
|
18
|
+
// * optional rewrite path
|
|
19
|
+
// */
|
|
20
|
+
// rootPath?: string | undefined;
|
|
21
|
+
// /**
|
|
22
|
+
// * optional default file to serve if requested static is missing
|
|
23
|
+
// */
|
|
24
|
+
// notFoundFile?: string | undefined;
|
|
25
|
+
// /**
|
|
26
|
+
// * request access log to console
|
|
27
|
+
// */
|
|
28
|
+
// log?: boolean | undefined;
|
|
29
|
+
// /**
|
|
30
|
+
// * don't execute any downstream middleware. defaults to true
|
|
31
|
+
// */
|
|
32
|
+
// last?: boolean | undefined;
|
|
33
|
+
// /**
|
|
34
|
+
// * Browser cache max-age in milliseconds. defaults to 0
|
|
35
|
+
// */
|
|
36
|
+
// maxage?: number | undefined;
|
|
37
|
+
// /**
|
|
38
|
+
// * Allow transfer of hidden files. defaults to false
|
|
39
|
+
// */
|
|
40
|
+
// hidden?: boolean | undefined;
|
|
41
|
+
// /**
|
|
42
|
+
// * Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested
|
|
43
|
+
// */
|
|
44
|
+
// gzip?: boolean | undefined;
|
|
45
|
+
// /**
|
|
46
|
+
// * Try to serve the brotli version of a file automatically when brotli is supported by a client and in the requested
|
|
47
|
+
// */
|
|
48
|
+
// brotli?: boolean | undefined;
|
|
49
|
+
// index?: string | undefined;
|
|
50
|
+
// }
|
|
51
|
+
|
|
12
52
|
/**
|
|
13
53
|
* @param {{
|
|
14
54
|
* cors: any; // Options for @koa/cors middleware.
|
|
15
55
|
* modulesPath: string; // Root directory of your router.js/db.js files.
|
|
16
56
|
* static: {
|
|
17
|
-
*
|
|
18
|
-
* rootPath: string; // Root path
|
|
57
|
+
* rootDir: string; // Root directory of your static files.
|
|
58
|
+
* rootPath: string; // Root path of your static files.
|
|
59
|
+
* notFoundFile: string; // Not found file.
|
|
60
|
+
* log: boolean; // Log requests to console.
|
|
61
|
+
* last: boolean; // Don't execute any downstream middleware.
|
|
62
|
+
* maxage: number; // Browser cache max-age in milliseconds.
|
|
63
|
+
* hidden: boolean; // Allow transfer of hidden files.
|
|
64
|
+
* gzip: boolean; // Try to serve the gzipped version of a file automatically when gzip is supported by a client and if the requested
|
|
65
|
+
* brotli: boolean; // Try to serve the brotli version of a file automatically when brotli is supported by a client and in the requested
|
|
66
|
+
* index: string; // Index file.
|
|
19
67
|
* };
|
|
20
68
|
* onBeforeInit: (koaApp) => void; // A callback called before initializing the Koa server.
|
|
21
69
|
* onAfterInit: (koaApp) => void; // A callback called after server initialization.
|
|
@@ -73,13 +121,8 @@ module.exports = async function createRest(options) {
|
|
|
73
121
|
/**
|
|
74
122
|
* Plug In KoaStatic
|
|
75
123
|
*/
|
|
76
|
-
if (options.
|
|
77
|
-
app.use(
|
|
78
|
-
koaStatic({
|
|
79
|
-
rootDir: options.static.dir,
|
|
80
|
-
rootPath: options.static.rootPath || "/assets/",
|
|
81
|
-
})
|
|
82
|
-
);
|
|
124
|
+
if (options.static) {
|
|
125
|
+
app.use(koaStatic(options.static));
|
|
83
126
|
}
|
|
84
127
|
|
|
85
128
|
/**
|