generated from coldbox-modules/module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModuleConfig.cfc
108 lines (91 loc) · 2.67 KB
/
ModuleConfig.cfc
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
*/
component {
// Module Properties
this.title = "cbmeilisearch";
this.author = "Michael Born";
this.webURL = "https://www.ortussolutions.com";
this.description = "An API wrapper for Meilisearch written in CFML for the ColdBox platform";
this.version = "@build.version@[email protected]@";
// Model Namespace
this.modelNamespace = "cbmeilisearch";
// CF Mapping
this.cfmapping = "cbmeilisearch";
// Dependencies
this.dependencies = [];
/**
* Configure Module
*/
function configure(){
settings = {
// What HTTP host is the Meilisearch server listening on?
MEILISEARCH_HOST : getSystemSetting( "MEILISEARCH_HOST", "http://127.0.0.1" ),
// What port is the Meilisearch server listening on?
MEILISEARCH_PORT : getSystemSetting( "MEILISEARCH_PORT", "7700" ),
// Master key or API key for authenticating to a protected Meilisearch instance
MEILISEARCH_MASTER_KEY : getSystemSetting( "MEILISEARCH_MASTER_KEY", "change_me" )
};
}
/**
* Fired when the module is registered and activated.
*/
function onLoad(){
// Binder Mappings
var apiHeaders = {};
if ( len( settings.MEILISEARCH_MASTER_KEY ) ){
apiHeaders[ "Authorization" ] = "Bearer #settings.MEILISEARCH_MASTER_KEY#";
}
binder
.map( "HyperClient@cbmeilisearch" )
.to( "hyper.models.HyperBuilder" )
.asSingleton()
.initWith(
baseURL: "#settings.MEILISEARCH_HOST#:#settings.MEILISEARCH_PORT#",
headers: apiHeaders
);
binder
.map( "Documents@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Documents" );
binder
.map( "Dumps@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Dumps" );
binder
.map( "Indexes@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Indexes" );
binder
.map( "Keys@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Keys" );
binder
.map( "Search@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Search" );
binder
.map( "Settings@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Settings" );
binder
.map( "Stats@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Stats" );
binder
.map( "Tasks@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Tasks" );
binder
.map( "Version@cbmeilisearch" )
.asSingleton()
.to( "#moduleMapping#.models.endpoints.Version" );
}
/**
* Fired when the module is unregistered and unloaded
*/
function onUnload(){
}
}