-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
60 lines (56 loc) · 2.14 KB
/
index.js
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
'use strict'
const ekso = require('../../lib')
const App = ekso({
rootDir: __dirname, // set root directory to this scripts directory
pathTransforms: ['capitalize'], // capitalize all paths
globalRequire: { // globally require the following modules
_: 'lodash' // lodash as _
}
}, [
{
path: 'config', // require whole config directory
global: true // make it global - Config
},
{
path: 'helpers', // require whole helpers directory
global: true // make it global - Helpers
},
{
path: 'views', // require whole views directory
global: true // make it global - Views
},
{
path: 'models', // require whole models directory
nameTransforms: ['camelCase', 'capitalize'], // transform the name - ie User
globalLast: true, // make last part of the path global - ie User
executeFuncs: true, // execute exported functions
funcContext: 'Model Context', // with 'this' when calling the function
funcArgs: ['Model db Variable'] // pass arguments to the function when calling
},
{
path: 'controllers', // require whole controllers directory
nameTransforms: ['camelCase', 'capitalize'], // transform the name - ie Users
namePostfix: 'Controller' // append string to name - ie UsersController
}
])
App.Controllers.UsersController.index()
console.log('==========')
console.log(App)
/*
User Model Initialized
db: Model db Variable
this: [String: 'Model Context']
db url config: some db url
Users Controller Index Function
Invoke Helper: Ekso example
User Model: User Model Schema
User Index View: Users Index Template: User Model Schema
==========
{ Config:
{ app: { name: 'ekso example' },
database: { url: 'some db url' } },
Helpers: { capitalize: [Function] },
Views: { Users: { index: [Function], read: [Function] } },
Models: { User: 'User Model Schema' },
Controllers: { UsersController: { index: [Function], create: [Function] } } }
*/