${req.method}: ${req.url}
${middlewarePath}
`,
75 | log: (e as Error).stack,
76 | },
77 | });
78 | }
79 |
80 | });
81 | };
82 |
83 | export = MiddlewareEngine;
84 |
--------------------------------------------------------------------------------
/src/Objects/consoleColors.obj.ts:
--------------------------------------------------------------------------------
1 | export default {
2 | reset: "\x1b[0m",
3 | bright: "\x1b[1m",
4 | dim: "\x1b[2m",
5 | underscore: "\x1b[4m",
6 | blink: "\x1b[5m",
7 | reverse: "\x1b[7m",
8 | hidden: "\x1b[8m",
9 |
10 | fgBlack: "\x1b[30m",
11 | fgRed: "\x1b[31m",
12 | fgGreen: "\x1b[32m",
13 | fgYellow: "\x1b[33m",
14 | fgBlue: "\x1b[34m",
15 | fgMagenta: "\x1b[35m",
16 | fgCyan: "\x1b[36m",
17 | fgWhite: "\x1b[37m",
18 |
19 | bgBlack: "\x1b[40m",
20 | bgRed: "\x1b[41m",
21 | bgGreen: "\x1b[42m",
22 | bgYellow: "\x1b[43m",
23 | bgBlue: "\x1b[44m",
24 | bgMagenta: "\x1b[45m",
25 | bgCyan: "\x1b[46m",
26 | bgWhite: "\x1b[47m",
27 | };
28 |
--------------------------------------------------------------------------------
/src/On.ts:
--------------------------------------------------------------------------------
1 | /* On Applications Event Engine */
2 | import {getInstance} from "../index";
3 | const $ = getInstance();
4 |
5 | const OnEvents: { [key: string]: any[] } = {
6 | start: [],
7 | boot: [],
8 | expressInit: [],
9 | bootServer: [],
10 | http: [],
11 | https: [],
12 | serverBooted: []
13 | };
14 |
15 | /**
16 | * AddToEvents - Short Hand Function
17 | * Adds an event to a given key.
18 | * @param name
19 | * @param todo
20 | * @constructor
21 | */
22 | const AddToEvents = (name: any, todo: any) => {
23 | if (Array.isArray(todo)) {
24 | for (const key in todo) {
25 | if (todo.hasOwnProperty(key)) {
26 | $.on[name](todo[key]);
27 | }
28 | }
29 | } else {
30 | OnEvents[name].push(todo);
31 | }
32 | };
33 |
34 | // Initialise $.on
35 | $.on = {
36 | events() {
37 | return OnEvents;
38 | },
39 |
40 | start(todo) {
41 | return AddToEvents("start", todo);
42 | },
43 |
44 | boot(todo) {
45 | return AddToEvents("boot", todo);
46 | },
47 |
48 | expressInit(todo) {
49 | return AddToEvents("expressInit", todo);
50 | },
51 |
52 | bootServer(todo) {
53 | return AddToEvents("bootServer", todo);
54 | },
55 |
56 | http(todo) {
57 | return AddToEvents("http", todo);
58 | },
59 |
60 | https(todo) {
61 | return AddToEvents("https", todo);
62 | },
63 |
64 | serverBooted(todo) {
65 | return AddToEvents("serverBooted", todo);
66 | },
67 | };
68 |
--------------------------------------------------------------------------------
/src/PluginEngine.ts:
--------------------------------------------------------------------------------
1 | import PathHelper from "./Helpers/Path";
2 | import hasPkg from "has-pkg";
3 | import {getInstance} from "../index";
4 | import InXpresserError from "./Errors/InXpresserError";
5 | import {compareVersion, pluginPathExistOrExit} from "./Functions/plugins.fn";
6 |
7 | const $ = getInstance();
8 |
9 | /**
10 | * PluginRoutes - holds all plugins routes.
11 | */
12 | const pluginRoutes = [] as any[];
13 |
14 | /**
15 | * PluginNamespaceToData - Holds plugin data using namespaces as keys.
16 | */
17 | const PluginNamespaceToData: Record
44 | <%- error.log %>
45 |
46 |