MCPcopy Create free account
hub / github.com/thinkjs/thinkjs /

Class

lib/loader.js:17–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 * @param {Object} options
16 */
17const thinkLoader = class {
18 constructor(options = {}) {
19 this.options = options;
20 }
21 /**
22 * init path
23 */
24 initPath() {
25 think.ROOT_PATH = this.options.ROOT_PATH;
26 think.APP_PATH = this.options.APP_PATH;
27 think.RUNTIME_PATH = this.options.RUNTIME_PATH;
28
29 // set env
30 if (this.options.env) {
31 think.app.env = this.options.env;
32 }
33 // set proxy
34 if (this.options.proxy) {
35 think.app.proxy = this.options.proxy;
36 }
37 }
38 /**
39 * load app data
40 */
41 loadData() {
42 // add data to koa application
43 think.app.modules = think.loader.modules;
44 think.app.models = think.loader.loadModel();
45 think.app.services = think.loader.loadService();
46 think.app.logics = think.loader.loadLogic();
47 think.app.controllers = think.loader.loadController();
48 think.app.routers = think.loader.loadRouter();
49 think.app.validators = think.loader.loadValidator();
50 }
51 /**
52 * load middleware
53 */
54 loadMiddleware() {
55 const middlewares = think.loader.loadMiddleware(think.app);
56 middlewares.forEach(middleware => {
57 think.app.use(middleware);
58 });
59 }
60 /**
61 * load extend
62 */
63 loadExtend() {
64 const exts = think.loader.loadExtend();
65 const list = [
66 ['think', think],
67 ['application', think.app],
68 ['context', think.app.context],
69 ['request', think.app.request],
70 ['response', think.app.response],
71 ['controller', think.Controller.prototype],
72 ['logic', think.Logic.prototype],
73 ['service', think.Service.prototype]
74 ];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected