speedly 2.0.9 → 2.0.11
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
type InitConfig = {
|
|
3
3
|
notFoundHandler?: boolean;
|
|
4
|
+
homeHandler?: boolean;
|
|
4
5
|
errorHandler?: boolean;
|
|
5
6
|
jsonParser?: boolean;
|
|
7
|
+
documentation?: boolean;
|
|
6
8
|
urlEncodedParser?: boolean;
|
|
7
9
|
cookieParser?: boolean;
|
|
8
10
|
staticFiles?: boolean;
|
package/dist/cjs/config/init.js
CHANGED
|
@@ -5,10 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = speedly;
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const document_1 = __importDefault(require("../document"));
|
|
8
11
|
const defaultConfig = {
|
|
9
12
|
notFoundHandler: true,
|
|
10
13
|
errorHandler: true,
|
|
14
|
+
homeHandler: true,
|
|
11
15
|
jsonParser: true,
|
|
16
|
+
documentation: true,
|
|
12
17
|
urlEncodedParser: true,
|
|
13
18
|
cookieParser: true,
|
|
14
19
|
staticFiles: true,
|
|
@@ -31,8 +36,18 @@ function speedly(config = {}) {
|
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
if (finalConfig.documentation &&
|
|
40
|
+
fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")))
|
|
41
|
+
(0, document_1.default)(app, path_1.default.join(process.cwd(), "src/module"));
|
|
34
42
|
if (finalConfig.staticFiles)
|
|
35
43
|
app.use("/static", express_1.default.static("public"));
|
|
44
|
+
if (finalConfig.homeHandler) {
|
|
45
|
+
app.get("/", (req, res) => {
|
|
46
|
+
res.send(`<h1>Welcome to ${require(path_1.default.join(process.cwd(), "package.json")).name} App</h1>
|
|
47
|
+
<p>Your app is running successfully.</p>
|
|
48
|
+
<p>Visit <a href="/docs">/docs</a> for API documentation.</p>`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
36
51
|
// user can call this manually if needed
|
|
37
52
|
const registerFallbacks = () => {
|
|
38
53
|
if (finalConfig.notFoundHandler) {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import express from "express";
|
|
2
2
|
type InitConfig = {
|
|
3
3
|
notFoundHandler?: boolean;
|
|
4
|
+
homeHandler?: boolean;
|
|
4
5
|
errorHandler?: boolean;
|
|
5
6
|
jsonParser?: boolean;
|
|
7
|
+
documentation?: boolean;
|
|
6
8
|
urlEncodedParser?: boolean;
|
|
7
9
|
cookieParser?: boolean;
|
|
8
10
|
staticFiles?: boolean;
|
package/dist/esm/config/init.js
CHANGED
|
@@ -5,10 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = speedly;
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const document_1 = __importDefault(require("../document"));
|
|
8
11
|
const defaultConfig = {
|
|
9
12
|
notFoundHandler: true,
|
|
10
13
|
errorHandler: true,
|
|
14
|
+
homeHandler: true,
|
|
11
15
|
jsonParser: true,
|
|
16
|
+
documentation: true,
|
|
12
17
|
urlEncodedParser: true,
|
|
13
18
|
cookieParser: true,
|
|
14
19
|
staticFiles: true,
|
|
@@ -31,8 +36,18 @@ function speedly(config = {}) {
|
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
}
|
|
39
|
+
if (finalConfig.documentation &&
|
|
40
|
+
fs_1.default.existsSync(path_1.default.join(process.cwd(), "src/module")))
|
|
41
|
+
(0, document_1.default)(app, path_1.default.join(process.cwd(), "src/module"));
|
|
34
42
|
if (finalConfig.staticFiles)
|
|
35
43
|
app.use("/static", express_1.default.static("public"));
|
|
44
|
+
if (finalConfig.homeHandler) {
|
|
45
|
+
app.get("/", (req, res) => {
|
|
46
|
+
res.send(`<h1>Welcome to ${require(path_1.default.join(process.cwd(), "package.json")).name} App</h1>
|
|
47
|
+
<p>Your app is running successfully.</p>
|
|
48
|
+
<p>Visit <a href="/docs">/docs</a> for API documentation.</p>`);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
36
51
|
// user can call this manually if needed
|
|
37
52
|
const registerFallbacks = () => {
|
|
38
53
|
if (finalConfig.notFoundHandler) {
|