lakutata 0.1.2 → 0.1.3
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/README.md +110 -0
- package/build/Lakutata.d.ts +9 -0
- package/build/Lakutata.js +16472 -16457
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,4 +14,114 @@
|
|
|
14
14
|
|
|
15
15
|
</div>
|
|
16
16
|
|
|
17
|
+
## Description
|
|
17
18
|
|
|
19
|
+
Lakutata is a generic development framework written in TypeScript and designed with IoC principles. Its main objective
|
|
20
|
+
is to provide a universal, efficient, and stable development framework. The design goals of Lakutata are not limited to
|
|
21
|
+
web application development; it aims to serve as a foundational framework for desktop applications, embedded systems
|
|
22
|
+
applications, and web applications. The framework primarily adopts an OOP (Object-Oriented Programming) approach and
|
|
23
|
+
encapsulates functionalities such as subprocesses, threads, permission management, and database ORM, enabling the
|
|
24
|
+
framework to be used out of the box.
|
|
25
|
+
|
|
26
|
+
In addition, Lakutata also supports the integration of third-party libraries into the application, allowing developers
|
|
27
|
+
to freely encapsulate and call third-party modules using Lakutata's dependency injection.
|
|
28
|
+
|
|
29
|
+
## Get Started
|
|
30
|
+
|
|
31
|
+
To check out the guide, please click [here](docs/Guide.md).
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {AccessControl, Application, Container, Logger} from 'lakutata'
|
|
35
|
+
import {MathObject} from './objects/MathObject'
|
|
36
|
+
import {UserModel} from './models/UserModel'
|
|
37
|
+
import {FibonacciThreadTask} from './threads/FibonacciThreadTask'
|
|
38
|
+
import os from 'node:os'
|
|
39
|
+
import {SayHelloInterval} from './objects/SayHelloInterval'
|
|
40
|
+
import {GreetCron} from './objects/GreetCron'
|
|
41
|
+
import {TestComponent} from './components/TestComponent'
|
|
42
|
+
import {SubModule} from './modules/subModule/SubModule'
|
|
43
|
+
import {SubProcess} from './processes/SubProcess'
|
|
44
|
+
|
|
45
|
+
(async (): Promise<void> => {
|
|
46
|
+
await Application.run({
|
|
47
|
+
id: 'example.lakutata.app',
|
|
48
|
+
name: 'LakutataExampleApplication',
|
|
49
|
+
timezone: 'Asia/Shanghai',
|
|
50
|
+
mode: 'production',
|
|
51
|
+
alias: {
|
|
52
|
+
'@data': '@app/data',
|
|
53
|
+
'@controllers': '@app/controllers',
|
|
54
|
+
'@models': '@app/models'
|
|
55
|
+
},
|
|
56
|
+
entries: {
|
|
57
|
+
sayHello: {
|
|
58
|
+
class: SayHelloInterval,
|
|
59
|
+
interval: 1000,
|
|
60
|
+
mode: 'SEQ'
|
|
61
|
+
},
|
|
62
|
+
greet: {
|
|
63
|
+
class: GreetCron,
|
|
64
|
+
expression: '1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * ? '
|
|
65
|
+
},
|
|
66
|
+
math: {
|
|
67
|
+
class: MathObject,
|
|
68
|
+
baseNumber: 32
|
|
69
|
+
},
|
|
70
|
+
fibonacci: {
|
|
71
|
+
class: FibonacciThreadTask,
|
|
72
|
+
maxThreads: os.cpus().length
|
|
73
|
+
},
|
|
74
|
+
proc: {
|
|
75
|
+
class: SubProcess,
|
|
76
|
+
text: 'Default text'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
components: {
|
|
80
|
+
access: {
|
|
81
|
+
class: AccessControl,
|
|
82
|
+
store: {type: 'file', filename: '@data/auth.csv'}
|
|
83
|
+
},
|
|
84
|
+
test: {
|
|
85
|
+
class: TestComponent
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
modules: {
|
|
89
|
+
sub: {
|
|
90
|
+
class: SubModule
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
autoload: ['@models/**/*'],
|
|
94
|
+
controllers: ['@controllers/**/*'],
|
|
95
|
+
bootstrap: [
|
|
96
|
+
'test',
|
|
97
|
+
'sub',
|
|
98
|
+
async (app: Application): Promise<void> => {
|
|
99
|
+
const logger: Logger = await app.get<Logger>('log')
|
|
100
|
+
const scope1: Container = app.createScope()
|
|
101
|
+
const scope2: Container = app.createScope()
|
|
102
|
+
await scope2.get('sayHello')
|
|
103
|
+
await scope2.get('greet')
|
|
104
|
+
const proc: SubProcess = await scope2.get<SubProcess>('proc')
|
|
105
|
+
proc.echoText()
|
|
106
|
+
proc.text = 'Oh! The text is changed'
|
|
107
|
+
proc.echoText()
|
|
108
|
+
const user: UserModel = await scope1.get(UserModel, {id: '89757', username: 'robot1'})
|
|
109
|
+
const accessControl: AccessControl = await app.get<AccessControl>('access', {user: user})
|
|
110
|
+
await accessControl.createUserPermission('add', 'execute')
|
|
111
|
+
logger.info('Math function "add" invoke result: %s', await app.dispatchToController({
|
|
112
|
+
ctrl: 'math',
|
|
113
|
+
act: 'add',
|
|
114
|
+
a: 123
|
|
115
|
+
}, {user: user}))
|
|
116
|
+
await scope2.destroy()
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
})
|
|
120
|
+
})()
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Click [Here](src/tests) for full example.
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
Lakutata is [MIT licensed](LICENSE).
|
package/build/Lakutata.d.ts
CHANGED
|
@@ -4243,6 +4243,15 @@ declare class Application extends Module {
|
|
|
4243
4243
|
* 应用程序时区
|
|
4244
4244
|
*/
|
|
4245
4245
|
get timezone(): string;
|
|
4246
|
+
/**
|
|
4247
|
+
* 程序上线时长(秒)
|
|
4248
|
+
*/
|
|
4249
|
+
get uptime(): number;
|
|
4250
|
+
/**
|
|
4251
|
+
* 内部初始化函数
|
|
4252
|
+
* @protected
|
|
4253
|
+
*/
|
|
4254
|
+
protected __init(): Promise<void>;
|
|
4246
4255
|
/**
|
|
4247
4256
|
* 退出应用程序
|
|
4248
4257
|
* @param force
|