bajo 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +13 -0
- package/.github/workflows/repo-lockdown.yml +24 -0
- package/.jsdoc.conf.json +7 -6
- package/LICENSE +1 -1
- package/README.md +50 -18
- package/class/app.js +376 -54
- package/class/bajo.js +228 -149
- package/class/base.js +106 -0
- package/class/helper/bajo.js +135 -84
- package/class/helper/{plugin.js → base.js} +96 -22
- package/class/{base → misc}/err.js +44 -14
- package/class/misc/log.js +212 -0
- package/class/misc/print.js +264 -0
- package/class/plugin.js +120 -68
- package/docs/App.html +23 -1
- package/docs/Bajo.html +2 -9
- package/docs/Base.html +3 -0
- package/docs/Err.html +3 -1
- package/docs/Log.html +5 -1
- package/docs/Plugin.html +1 -1
- package/docs/Print.html +1 -1
- package/docs/class_app.js.html +378 -56
- package/docs/class_bajo.js.html +230 -151
- package/docs/class_base.js.html +109 -0
- package/docs/class_helper_bajo.js.html +138 -87
- package/docs/class_helper_base.js.html +246 -0
- package/docs/class_misc_err.js.html +129 -0
- package/docs/class_misc_log.js.html +210 -0
- package/docs/class_misc_print.js.html +267 -0
- package/docs/class_plugin.js.html +122 -70
- package/docs/data/search.json +1 -1
- package/docs/global.html +4 -1
- package/docs/index.html +2 -2
- package/docs/index.js.html +35 -0
- package/docs/lib_current-loc.js.html +36 -0
- package/docs/lib_formats.js.html +8 -8
- package/docs/lib_import-module.js.html +59 -0
- package/docs/lib_log-levels.js.html +17 -7
- package/docs/lib_parse-args-argv.js.html +83 -0
- package/docs/lib_parse-env.js.html +53 -0
- package/docs/lib_resolve-path.js.html +3 -6
- package/docs/lib_shim.js.html +8 -3
- package/docs/module-Helper_Bajo.html +3 -0
- package/docs/module-Helper_Base.html +3 -0
- package/docs/module-Lib.html +15 -0
- package/docs/static/home.md +32 -0
- package/docs/static/logo-ecosystem.png +0 -0
- package/docs/static/logo.png +0 -0
- package/extend/bajo/intl/en-US.json +8 -2
- package/extend/bajo/intl/id.json +8 -2
- package/index.js +22 -2
- package/lib/current-loc.js +24 -2
- package/lib/formats.js +6 -6
- package/lib/import-module.js +29 -0
- package/lib/log-levels.js +15 -5
- package/lib/parse-args-argv.js +20 -12
- package/lib/parse-env.js +18 -7
- package/lib/resolve-path.js +1 -4
- package/lib/shim.js +6 -1
- package/package.json +4 -7
- package/wiki/CONFIG.md +30 -0
- package/wiki/CONTRIBUTING.md +5 -0
- package/wiki/DEV_GUIDE.md +3 -0
- package/wiki/ECOSYSTEM.md +93 -0
- package/wiki/GETTING-STARTED.md +356 -0
- package/wiki/USER-GUIDE.md +256 -0
- package/class/base/log.js +0 -205
- package/class/base/plugin.js +0 -168
- package/class/base/print.js +0 -272
- package/docs/BasePlugin.html +0 -5
- package/docs/class_base_err.js.html +0 -99
- package/docs/class_base_log.js.html +0 -208
- package/docs/class_base_plugin.js.html +0 -180
- package/docs/class_base_print.js.html +0 -275
- package/docs/class_helper_plugin.js.html +0 -172
- package/docs/lib_create-method.js.html +0 -42
- package/docs/module-class_helper_bajo.html +0 -3
- package/docs/module-class_helper_plugin.html +0 -3
- package/docs/module-lib_create-method.html +0 -3
- package/docs/module-lib_formats.html +0 -3
- package/docs/module-lib_log-levels.html +0 -3
- package/docs/module-lib_resolve-path.html +0 -3
- package/docs/module-lib_shim.html +0 -3
- package/docs/tutorial-contribution.html +0 -3
- package/docs/tutorial-ecosystem.html +0 -3
- package/docs/tutorial-getting-started.html +0 -13
- package/docs/tutorial-plugin-dev.html +0 -3
- package/docs/tutorial-user-guide.html +0 -3
- package/lib/create-method.js +0 -39
- package/lib/dayjs.js +0 -8
- package/lib/omitted-plugin-keys.js +0 -3
- package/lib/read-all-configs.js +0 -19
- package/misc-docs/.hook.md +0 -11
- package/misc-docs/bitcoin.jpeg +0 -0
- package/misc-docs/contribution.md +0 -20
- package/misc-docs/ecosystem.md +0 -94
- package/misc-docs/getting-started.md +0 -142
- package/misc-docs/plugin-dev.md +0 -0
- package/misc-docs/toc.json +0 -17
- package/misc-docs/user-guide.md +0 -1
- /package/docs/{bitcoin.jpeg → static/bitcoin.jpeg} +0 -0
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# Getting Started
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
Before we go any further, below are some terminologies I use throughout these documentations:
|
|
6
|
-
|
|
7
|
-
- ```<bajo-base-dir>```: project directory is where you write all your codes
|
|
8
|
-
- ```<bajo-data-dir>```: data directory, defaults to ```<bajo-base-dir>/data``` if not specifically stated
|
|
9
|
-
- ```<bajo-tmp-dir>```: temp directory, defaults to OS temporary directory
|
|
10
|
-
- ```<package>```: plugin package name as normally showed on npm listing
|
|
11
|
-
- ```<plugin>```: plugin name, which is camel cased version of package name
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Open your terminal and type:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
$ npm install bajo
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Fire up!
|
|
22
|
-
|
|
23
|
-
Create a new empty directory, this will be your project directory or your ```<bajo-base-dir>```. Now goto your newly created directory, and type:
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
$ npm init
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
You'll be asked to name your project etc. **IMPORTANT**: don't forget to mark your project as ES6 project by setting ```type``` key in your ```package.json``` to ```module```.
|
|
30
|
-
|
|
31
|
-
After completing those steps, move on the the next one: crating bajo bootstrap.
|
|
32
|
-
|
|
33
|
-
Inside your ```<bajo-base-dir>```, create the ```index.js``` file and put these lines below:
|
|
34
|
-
|
|
35
|
-
```js
|
|
36
|
-
import bajo from 'bajo'
|
|
37
|
-
await bajo()
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
A bajo app **ALWAYS** needs a data directory to put configuration files, etc. This
|
|
41
|
-
could be located inside or outside your ```<bajo-base-dir>```.
|
|
42
|
-
|
|
43
|
-
Lets assume you're going to put your data directory inside your ```<bajo-base-dir>```. So please
|
|
44
|
-
create a new directory called ```data``` first. After that, just type in your terminal:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
$ node index.js --dir-data=data
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
Or you could utilize ```dotenv``` by creating ```.env``` file in the same directory as ```index.js```, and put this inside:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
DIR_DATA = ./data
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Now you can omit calling node with arguments, you just need to type:
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
$ node index.js
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
## Configuration
|
|
63
|
-
|
|
64
|
-
### General rules
|
|
65
|
-
|
|
66
|
-
- All configuration files must be placed in ```<bajo-data-dir>/config/``` subfolder
|
|
67
|
-
- Config files should be named after its plugin name
|
|
68
|
-
- File format should be in ```.json``` or ```.js``` format
|
|
69
|
-
- If ```.js``` file is used, it should be in ES6 format and should export either plain javascript object or a function (sync or async both supported)
|
|
70
|
-
- If it returns a function, this function will be called within its plugin scope and should return a plain js object
|
|
71
|
-
- Other formats (```.yml```, ```.yaml``` and ```.toml```) can also be used by installing [bajoConfig](https://github.com/ardhi/bajo-config) plugin
|
|
72
|
-
- Order of importance: ```.js``` > ```.json``` > ```.yml``` > ```.yaml``` > ```.toml```
|
|
73
|
-
|
|
74
|
-
### Main configuration File
|
|
75
|
-
|
|
76
|
-
It should be named ```bajo.json``` with following keys:
|
|
77
|
-
|
|
78
|
-
| Key | Type | Required | Default | Description |
|
|
79
|
-
| --- | ---- | -------- | ------- | ----------- |
|
|
80
|
-
| ```env``` | ```string``` | no | ```dev``` | App environment: ```dev``` or ```prod``` |
|
|
81
|
-
| ```log``` | ```object``` | no || Logger setting |
|
|
82
|
-
| ```dateFormat``` | ```string``` | no | ```YYYY-MM-DDTHH:MM:ss.SSS[Z]```| Date format accoding to [dayjs](https://github.com/iamkun/dayjs) |
|
|
83
|
-
| ```applet``` | ```boolean``` | no | ```false``` | Set to ```true``` if you want to show log even in [applet mode](#applet-mode) |
|
|
84
|
-
| ```level``` | ```string``` | no || Set one of these: ```trace```, ```debug```, ```info```, ```warn```, ```error```, ```fatal``` and ```silent```. If it isn't set, it will auto selected based on environment |
|
|
85
|
-
| ```lang``` | ```string``` | no || Language to use. If not set, it will be auto detected |
|
|
86
|
-
| ```exitHandler``` | ```boolean``` | no | ```true``` | Set to ```false``` if you want your app **NOT** to exit gracefully |
|
|
87
|
-
|
|
88
|
-
### Installed Plugins
|
|
89
|
-
|
|
90
|
-
Plugins are what make Bajo Framework so great and flexible: they extends app features!
|
|
91
|
-
|
|
92
|
-
To use plugins:
|
|
93
|
-
|
|
94
|
-
1. Install with ```npm install <package>```
|
|
95
|
-
2. Optionally create ```<bajo-data-dir>/config/<plugin>.json``` to customize plugin settings
|
|
96
|
-
3. Open/create ```<bajo-data-dir>/config/.plugins``` and put ```<package>``` in it, line by line
|
|
97
|
-
|
|
98
|
-
Example below will load ```bajoConfig```, ```bajoExtra``` and ```bajoTemplate```:
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
bajo-config
|
|
102
|
-
bajo-extra
|
|
103
|
-
bajo-template
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
If you later decide to NOT load one or more plugins from your app, you just need to remove those from ```.plugins``` file or put ```#``` hash mark in front of package name and restart your app.
|
|
107
|
-
|
|
108
|
-
> **Warning**: please do not confuse between ```<package>``` and ```<plugin>```. Plugin package is the name of JS package listed on npm, while plugin name is the name of a plugin - a camel cased version of plugin package
|
|
109
|
-
|
|
110
|
-
### Configuration Overrides
|
|
111
|
-
|
|
112
|
-
You can override ANY settings on ANY configuration files with dotenv variables and program's argument switches easily.
|
|
113
|
-
|
|
114
|
-
Order of importance: dotenv variable > args switches > config files
|
|
115
|
-
|
|
116
|
-
#### dotenv
|
|
117
|
-
|
|
118
|
-
- Create/open ```<bajo-base-dir>/.env```
|
|
119
|
-
- Use ```__``` (double underscores) as the replacement of the dot in object
|
|
120
|
-
- ```DIR__DATA```: Set ```<bajo-data-dir>``` data directory
|
|
121
|
-
- ```DIR__TMP```: Set ```<bajo-tmp-dir>``` temp directory
|
|
122
|
-
- For every key in ```bajo.json```, use its snake cased, upper cased version, e.g:
|
|
123
|
-
- ```env``` => ```ENV```
|
|
124
|
-
- ```log.dateFormat``` => ```LOG__DATE_FORMAT```
|
|
125
|
-
- ```exitHandler``` => ```EXIT_HANDLER```
|
|
126
|
-
- To override plugins config, prepend every key in plugin config with snake cased, upper cased version of the plugin name followed by a dot, e.g:
|
|
127
|
-
- ```key``` in ```myPlugin``` => ```MY_PLUGIN.KEY```
|
|
128
|
-
- ```key.subKey.subSubKey``` in ```myPlugin``` => ```MY_PLUGIN.KEY__SUB_KEY__SUB_SUB_KEY```
|
|
129
|
-
|
|
130
|
-
#### Program argument switches
|
|
131
|
-
- Use switches, e.g: ```node index.js --xxx=one --yyy=two```
|
|
132
|
-
- Every switches must be prefixed with ```--```
|
|
133
|
-
- Use ```-``` as the replacement of the dot in object
|
|
134
|
-
- ```--dir-data```: Set ```<bajo-data-dir>``` data directory
|
|
135
|
-
- ```--dir-tmp```: Set ```<bajo-tmp-dir>``` temp directory
|
|
136
|
-
- For every key in ```bajo.json```, add prefix ```--``` e.g:
|
|
137
|
-
- ```env``` => ```--env=prod```
|
|
138
|
-
- ```log.dateFormat``` => ```--log-dateFormat=xxx```
|
|
139
|
-
- ```exitHandler``` => ```--exitHandler```
|
|
140
|
-
- To override plugins config, prepend every key in plugin config with the plugin name followed by a ```:```, e.g:
|
|
141
|
-
- ```key``` in ```myPlugin``` => ```--myPlugin:key```
|
|
142
|
-
- ```key.subKey.subSubKey``` in ```myPlugin``` => ```--myPlugin:key-subKey-subSubKey```
|
package/misc-docs/plugin-dev.md
DELETED
|
File without changes
|
package/misc-docs/toc.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"getting-started": {
|
|
3
|
-
"title": "Getting Started"
|
|
4
|
-
},
|
|
5
|
-
"user-guide": {
|
|
6
|
-
"title": "User Guide"
|
|
7
|
-
},
|
|
8
|
-
"plugin-dev": {
|
|
9
|
-
"title": "Plugin Development"
|
|
10
|
-
},
|
|
11
|
-
"ecosystem": {
|
|
12
|
-
"title": "Ecosystem"
|
|
13
|
-
},
|
|
14
|
-
"contribution": {
|
|
15
|
-
"title": "Contribution"
|
|
16
|
-
}
|
|
17
|
-
}
|
package/misc-docs/user-guide.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# User Guide
|
|
File without changes
|