@cley_faye/boilerplate 3.7.2 → 3.9.1
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 +3 -2
- package/lib/express/logger.d.ts +4 -4
- package/lib/express/middlewares/bodylogger.d.ts +1 -1
- package/lib/express.d.ts +12 -3
- package/lib/express.js +13 -4
- package/lib/grunt/reactapp/webpack.d.ts +1 -1
- package/lib/grunt/reactapp/webpack.js +2 -2
- package/lib/grunt/reactapp.d.ts +1 -1
- package/lib/winston.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -426,7 +426,7 @@ import {appStart} from "@cley_faye/boilerplate/lib/express.js";
|
|
|
426
426
|
|
|
427
427
|
appStart({
|
|
428
428
|
app,
|
|
429
|
-
|
|
429
|
+
listenInterface: false,
|
|
430
430
|
port: 3000,
|
|
431
431
|
shutdownFunction: () => {;},
|
|
432
432
|
logger: consoleLogger,
|
|
@@ -435,7 +435,8 @@ appStart({
|
|
|
435
435
|
|
|
436
436
|
The settings are:
|
|
437
437
|
|
|
438
|
-
-
|
|
438
|
+
- listenInterface: listen only to localhost or not. Can also be used to specify the address of an
|
|
439
|
+
interface to bind to.
|
|
439
440
|
- port: port to listen to. Can be 0 to use a random available port
|
|
440
441
|
- shutdownFunction: a function to call after the server stop listening
|
|
441
442
|
- logger: a winston logger to log that the server started listening
|
package/lib/express/logger.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import expressWinston, { BaseLoggerOptions } from "express-winston";
|
|
2
2
|
import { Request, Router } from "express";
|
|
3
3
|
import { LogOptions, UserFromReqFunc } from "./pipelinebuilder.js";
|
|
4
|
-
export declare type LoggerOptions = expressWinston.
|
|
4
|
+
export declare type LoggerOptions = expressWinston.BaseLoggerOptions | boolean;
|
|
5
5
|
interface ErrorLoggerConfiguration {
|
|
6
6
|
collapseNodeModules?: boolean;
|
|
7
7
|
}
|
|
@@ -16,7 +16,7 @@ export interface RequestWithLoggingData extends Request {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
/** Return the default value for route logger is it is set as `true` */
|
|
19
|
-
export declare const defaultRouteLoggerConfig: (userFromReq?: UserFromReqFunc
|
|
20
|
-
export declare const registerRouteLogger: (app: Router, logOptions?: LogOptions
|
|
21
|
-
export declare const registerErrorLogger: (app: Router, logOptions?: LogOptions
|
|
19
|
+
export declare const defaultRouteLoggerConfig: (userFromReq?: UserFromReqFunc) => BaseLoggerOptions;
|
|
20
|
+
export declare const registerRouteLogger: (app: Router, logOptions?: LogOptions) => void;
|
|
21
|
+
export declare const registerErrorLogger: (app: Router, logOptions?: LogOptions) => void;
|
|
22
22
|
export {};
|
|
@@ -6,4 +6,4 @@ export interface ExtraLoggingOptions {
|
|
|
6
6
|
/** Do not expose the "hidden" body props */
|
|
7
7
|
noHiddenBodyProps?: boolean;
|
|
8
8
|
}
|
|
9
|
-
export declare const bodyLogger: (bodyProps?: string
|
|
9
|
+
export declare const bodyLogger: (bodyProps?: Array<string>, extraLoggingData?: ExtraLoggingData, options?: ExtraLoggingOptions) => (req: Request, res: Response, next: NextFunction) => void;
|
package/lib/express.d.ts
CHANGED
|
@@ -99,14 +99,23 @@ import { PipelineSettings, LogFunction } from "./express/pipelinebuilder.js";
|
|
|
99
99
|
* @return
|
|
100
100
|
* The returned object can be used
|
|
101
101
|
*/
|
|
102
|
-
export declare const createPipeline: (settings: PipelineSettings, debugLog?: LogFunction
|
|
102
|
+
export declare const createPipeline: (settings: PipelineSettings, debugLog?: LogFunction) => express.Router;
|
|
103
103
|
/**
|
|
104
104
|
* Configure the views rendering engine for an ExpressJS App
|
|
105
105
|
*/
|
|
106
|
-
export declare const setViewEngine: (app: express.Express, viewEngine: string, viewsDirectory: string, extraLocals?: Record<string, string | number>
|
|
106
|
+
export declare const setViewEngine: (app: express.Express, viewEngine: string, viewsDirectory: string, extraLocals?: Record<string, string | number>) => void;
|
|
107
107
|
export interface StartDefinition {
|
|
108
108
|
app: express.Application;
|
|
109
|
+
/** @deprecated use listenInterface instead */
|
|
109
110
|
allowNonLocal?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Which interface to listen on.
|
|
113
|
+
*
|
|
114
|
+
* Defaults to `false` which means listen only on localhost.
|
|
115
|
+
* Set to `true` to listen on all interfaces
|
|
116
|
+
* Set to an IP to bind on a specific interface.
|
|
117
|
+
*/
|
|
118
|
+
listenInterface?: boolean | string;
|
|
110
119
|
port?: number;
|
|
111
120
|
shutdownFunction?: () => void;
|
|
112
121
|
logger?: winston.Logger;
|
|
@@ -135,4 +144,4 @@ export interface StartResult {
|
|
|
135
144
|
*
|
|
136
145
|
* @property server
|
|
137
146
|
*/
|
|
138
|
-
export declare const appStart: ({ app, allowNonLocal, port, shutdownFunction, logger, }: StartDefinition) => Promise<StartResult>;
|
|
147
|
+
export declare const appStart: ({ app, allowNonLocal, listenInterface, port, shutdownFunction, logger, }: StartDefinition) => Promise<StartResult>;
|
package/lib/express.js
CHANGED
|
@@ -169,7 +169,7 @@ exports.setViewEngine = setViewEngine;
|
|
|
169
169
|
*
|
|
170
170
|
* @property server
|
|
171
171
|
*/
|
|
172
|
-
const appStart = ({ app, allowNonLocal, port, shutdownFunction, logger, }) => new Promise(resolve => {
|
|
172
|
+
const appStart = ({ app, allowNonLocal, listenInterface, port, shutdownFunction, logger, }) => new Promise(resolve => {
|
|
173
173
|
let server = null;
|
|
174
174
|
const readyCallback = () => {
|
|
175
175
|
if (server === null) {
|
|
@@ -186,9 +186,18 @@ const appStart = ({ app, allowNonLocal, port, shutdownFunction, logger, }) => ne
|
|
|
186
186
|
server,
|
|
187
187
|
});
|
|
188
188
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
if (allowNonLocal !== undefined && listenInterface !== undefined) {
|
|
190
|
+
throw new Error("You can't specify both allowNonLocal and listenInterface at the same time");
|
|
191
|
+
}
|
|
192
|
+
if (allowNonLocal || listenInterface === true) {
|
|
193
|
+
server = app.listen(port ?? 0, readyCallback);
|
|
194
|
+
}
|
|
195
|
+
else if (typeof listenInterface === "string") {
|
|
196
|
+
server = app.listen(port ?? 0, listenInterface, readyCallback);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
server = app.listen(port ?? 0, "localhost", readyCallback);
|
|
200
|
+
}
|
|
192
201
|
if (shutdownFunction) {
|
|
193
202
|
server.on("close", shutdownFunction);
|
|
194
203
|
}
|
|
@@ -27,7 +27,7 @@ export interface WebpackLoadersOptions {
|
|
|
27
27
|
* Version of core-js to use (default to 3)
|
|
28
28
|
*
|
|
29
29
|
* @param [options.babel.targets]
|
|
30
|
-
* Browser targets (default to "
|
|
30
|
+
* Browser targets (default to " > 1%, last 1 safari version")
|
|
31
31
|
*
|
|
32
32
|
* @param [options.babel.plugins]
|
|
33
33
|
* Plugins to add to babel
|
|
@@ -49,7 +49,7 @@ const defaultLoadersDefine = (options) => [
|
|
|
49
49
|
const defaultLoadersPresetEnv = (options) => [
|
|
50
50
|
"@babel/preset-env",
|
|
51
51
|
{
|
|
52
|
-
targets: (options.babel?.targets) ?? "
|
|
52
|
+
targets: (options.babel?.targets) ?? "> 1%, last 1 safari version",
|
|
53
53
|
useBuiltIns: "usage",
|
|
54
54
|
corejs: (options.babel?.corejs) ?? defaultCoreJS,
|
|
55
55
|
modules: false,
|
|
@@ -75,7 +75,7 @@ const defaultLoadersReact = (options) => [
|
|
|
75
75
|
* Version of core-js to use (default to 3)
|
|
76
76
|
*
|
|
77
77
|
* @param [options.babel.targets]
|
|
78
|
-
* Browser targets (default to "
|
|
78
|
+
* Browser targets (default to " > 1%, last 1 safari version")
|
|
79
79
|
*
|
|
80
80
|
* @param [options.babel.plugins]
|
|
81
81
|
* Plugins to add to babel
|
package/lib/grunt/reactapp.d.ts
CHANGED
|
@@ -85,7 +85,7 @@ export declare type HandlerFunction = (gruntConfig: GruntConfig, targetName: str
|
|
|
85
85
|
* @return
|
|
86
86
|
* List of tasks to build the application
|
|
87
87
|
*/
|
|
88
|
-
export declare const reactApp: (gruntConfig: GruntConfig, targetName?: string, options?: ReactAppOptions
|
|
88
|
+
export declare const reactApp: (gruntConfig: GruntConfig, targetName?: string, options?: ReactAppOptions) => Array<string>;
|
|
89
89
|
export interface HelperOptions {
|
|
90
90
|
production?: boolean;
|
|
91
91
|
watch?: boolean | number;
|
package/lib/winston.js
CHANGED
|
@@ -70,7 +70,7 @@ const logConfig = {
|
|
|
70
70
|
collapseNodeModules: true,
|
|
71
71
|
};
|
|
72
72
|
const customFormat = winston_1.default.format.printf((info) => {
|
|
73
|
-
const message = ("stack" in info) ? info.stack : info.message;
|
|
73
|
+
const message = (("stack" in info) ? info.stack : info.message);
|
|
74
74
|
const filteredMessage = logConfig.collapseNodeModules
|
|
75
75
|
? [...(0, exports.filterNodeModules)(message)].join("\n")
|
|
76
76
|
: message;
|