-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepl.ts
34 lines (30 loc) · 886 Bytes
/
repl.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* https://xpresserjs.com/cli/repl.html
*/
import { XpresserRepl } from "xpresser";
const repl = new XpresserRepl();
// Set Config Provider
repl.setXpresserProvider(() => {
const { $ } = require("./app") as typeof import("./app");
return $;
});
/**
* Run some tasks or add context before repl starts
* repl.server is undefined.
* @param $ - Current Xpresser Instance
*/
repl.beforeStart(($) => {
// Add Example Context to repl
repl.addContextFromFolder($.path.backend('models'), null, null, context => {
return context.default ? context.default : context;
})
});
/**
* Start Repl Server.
* Function will run after repl server starts.
* @param $ - Current Xpresser Instance
*/
repl.start(($) => {
// repl.server is now defined.
// Any Customization to the repl server `repl.server` directly can be done here.
}).catch(console.error);