@avleon/cli 0.0.46 → 0.4.0
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/LICENSE +21 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +10 -0
- package/dist/commands/build.d.ts +11 -0
- package/dist/commands/build.js +65 -0
- package/dist/commands/doctor.d.ts +10 -0
- package/dist/commands/doctor.js +96 -0
- package/dist/commands/new.d.ts +19 -0
- package/dist/commands/new.js +306 -0
- package/dist/commands/route-list.d.ts +19 -0
- package/dist/commands/route-list.js +160 -0
- package/dist/commands/serve.d.ts +17 -0
- package/dist/commands/serve.js +238 -0
- package/dist/commands/start.d.ts +10 -0
- package/dist/commands/start.js +43 -0
- package/dist/compiler.d.ts +24 -0
- package/dist/compiler.js +83 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +16 -0
- package/dist/generators/make.d.ts +24 -0
- package/dist/generators/make.js +157 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +40 -15
- package/dist/program.d.ts +22 -0
- package/dist/program.js +178 -0
- package/dist/utils/entry.d.ts +15 -0
- package/dist/utils/entry.js +55 -0
- package/dist/utils/env-types.d.ts +8 -0
- package/dist/utils/env-types.js +19 -0
- package/dist/utils/log.d.ts +25 -0
- package/dist/utils/log.js +39 -0
- package/dist/utils/names.d.ts +27 -0
- package/dist/utils/names.js +58 -0
- package/dist/utils/process.d.ts +18 -0
- package/dist/utils/process.js +84 -0
- package/dist/utils/project.d.ts +17 -0
- package/dist/utils/project.js +91 -0
- package/dist/utils/stubs.d.ts +15 -0
- package/dist/utils/stubs.js +52 -0
- package/dist/utils/tsconfig.d.ts +13 -0
- package/dist/utils/tsconfig.js +102 -0
- package/package.json +63 -62
- package/readme.md +155 -66
- package/stubs/config/config.stub +9 -0
- package/stubs/controllers/basic-controller.stub +9 -12
- package/stubs/controllers/resource-controller.stub +45 -0
- package/stubs/controllers/rest-controller.stub +29 -34
- package/stubs/dtos/dto.stub +11 -0
- package/stubs/middlewares/middleware.stub +9 -0
- package/stubs/models/basic-model.stub +4 -6
- package/stubs/models/entity-model.stub +16 -23
- package/stubs/project/app-minimal.stub +7 -0
- package/stubs/project/app.stub +8 -0
- package/stubs/project/env.stub +3 -0
- package/stubs/project/gitignore.stub +5 -0
- package/stubs/project/home.controller.spec.stub +19 -0
- package/stubs/project/home.controller.stub +12 -0
- package/stubs/project/home.service.stub +8 -0
- package/stubs/project/openapi.config.stub +15 -0
- package/stubs/project/readme.stub +26 -0
- package/stubs/project/serve.stub +10 -0
- package/stubs/project/tsconfig.build.stub +4 -0
- package/stubs/project/tsconfig.stub +18 -0
- package/stubs/project/vitest-e2e.config.stub +10 -0
- package/stubs/project/vitest.config.stub +17 -0
- package/stubs/services/basic-service.stub +8 -9
- package/stubs/services/orm-rest-service.stub +61 -73
- package/stubs/services/rest-service.stub +34 -71
- package/dist/av-cli.js +0 -60
- package/dist/avcli.js +0 -26
- package/dist/cli.interface.js +0 -2
- package/dist/cli.js +0 -358
- package/dist/commands.js +0 -55
- package/dist/controller.js +0 -92
- package/dist/create.js +0 -498
- package/dist/helpers/file-helper.js +0 -30
- package/dist/helpers/path-helper.js +0 -21
- package/dist/paths.js +0 -32
- package/dist/scripts/serve.js +0 -290
- package/dist/serve.js +0 -311
- package/dist/service.js +0 -73
- package/stubs/app/app-controller.stub +0 -11
- package/stubs/app/app-minimal.stub +0 -17
- package/stubs/app/app-withdb.stub +0 -0
- package/stubs/basic-controller.stub +0 -7
- package/stubs/config.stub +0 -11
- package/stubs/controllers/orm-rest-controller.stub +0 -52
- package/stubs/model.stub +0 -0
- package/stubs/serve.stub +0 -10
package/readme.md
CHANGED
|
@@ -1,66 +1,155 @@
|
|
|
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
|
-
|
|
1
|
+
### ⚠️ WARNING: NOT FOR PRODUCTION USE
|
|
2
|
+
|
|
3
|
+
> **🚧 This project is in active development.**
|
|
4
|
+
>
|
|
5
|
+
> It is **not stable** and **not ready** for live environments.
|
|
6
|
+
> Use **only for testing, experimentation, or internal evaluation**.
|
|
7
|
+
>
|
|
8
|
+
> #### ❗ Risks of using this in production:
|
|
9
|
+
>
|
|
10
|
+
> - 🔄 Breaking changes may be introduced at any time
|
|
11
|
+
> - 🧪 Features are experimental and may be unstable
|
|
12
|
+
> - 🔐 Security has not been audited
|
|
13
|
+
> - 💥 Potential for data loss or critical errors
|
|
14
|
+
>
|
|
15
|
+
> **Please do not deploy this in production environments.**
|
|
16
|
+
|
|
17
|
+
# Avleon CLI
|
|
18
|
+
|
|
19
|
+
Scaffold and run [Avleon](https://github.com/avleonjs/avleon-core) applications.
|
|
20
|
+
|
|
21
|
+
## Create an Application
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx @avleon/cli new my_api
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
You are prompted for a package manager and for optional features (OpenAPI,
|
|
28
|
+
CORS, TypeORM, Knex, Scalar UI). The generated project uses `@avleon/core`'s
|
|
29
|
+
`Avleon.createApplication()` and is ready to run:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
cd my_api
|
|
33
|
+
npm run start:dev
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Commands
|
|
37
|
+
|
|
38
|
+
| Command | Alias | Options | Description |
|
|
39
|
+
|---------|-------|---------|-------------|
|
|
40
|
+
| `new <name>` | | `-m`, `-f`, `-y`, `--pm <npm\|yarn\|pnpm>`, `--features <list>`, `--skip-install` | Create a new application |
|
|
41
|
+
| `serve` | | `--entry <file>`, `--no-type-check`, `--debounce <ms>` | Dev server: SWC compile, run, reload on change |
|
|
42
|
+
| `build` | | `-p <tsconfig>` | Compile with `tsconfig.build.json` and copy assets |
|
|
43
|
+
| `start` | | `--entry <file>` | Run the compiled app with `NODE_ENV=production` |
|
|
44
|
+
| `doctor` | | | Check Node.js, `@avleon/core`, `reflect-metadata` and decorator settings |
|
|
45
|
+
| `route:list` | `routes` | `--json`, `--static` | List the app's routes |
|
|
46
|
+
| `make:model` | `m:m` | `-f`, `--orm`, `--root <dir>` | Create a model / TypeORM entity |
|
|
47
|
+
| `make:controller` | `m:c` | `-f`, `-r`, `-m <model>`, `--orm`, `--root <dir>`, `--base-path` | Create a controller |
|
|
48
|
+
| `make:service` | `m:s` | `-f`, `-r`, `-m <model>`, `--orm`, `--root <dir>` | Create a service |
|
|
49
|
+
| `make:config` | `m:cnf` | `-f`, `--root <dir>` | Create an `@AppConfig` class |
|
|
50
|
+
| `make:middleware` | `m:mlwr` | `-f`, `--root <dir>` | Create a middleware |
|
|
51
|
+
| `make:dto` | `m:dto` | `-f`, `--root <dir>` | Create a class-validator DTO |
|
|
52
|
+
|
|
53
|
+
`-f` / `--force` overwrites an existing file. `-r` / `--resource` generates a
|
|
54
|
+
full REST skeleton. `--root <dir>` (also `-rt`) writes under `src/<dir>`
|
|
55
|
+
instead of the default folder. Names may be nested, e.g. `admin/User`.
|
|
56
|
+
Run `avleon <command> --help` for details.
|
|
57
|
+
|
|
58
|
+
Generated controllers must be registered in your app with
|
|
59
|
+
`app.useControllers([...])`.
|
|
60
|
+
|
|
61
|
+
### Controller
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npx avleon make:controller product
|
|
65
|
+
# shorthand
|
|
66
|
+
npx avleon m:c product
|
|
67
|
+
|
|
68
|
+
# REST controller — also generates the matching service
|
|
69
|
+
npx avleon m:c product -m product -r
|
|
70
|
+
|
|
71
|
+
# REST controller backed by a TypeORM repository
|
|
72
|
+
npx avleon m:c product -m product -r --orm
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
With `-m`, the generated controller delegates to `src/services/<model>.service.ts`,
|
|
76
|
+
which is created alongside it.
|
|
77
|
+
|
|
78
|
+
### Model / Entity
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
# plain class
|
|
82
|
+
npx avleon make:model product
|
|
83
|
+
|
|
84
|
+
# TypeORM entity
|
|
85
|
+
npx avleon m:m product --orm
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Service
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
# basic service
|
|
92
|
+
npx avleon make:service product
|
|
93
|
+
|
|
94
|
+
# resource service backed by an in-memory Collection
|
|
95
|
+
npx avleon make:service product -m product -r
|
|
96
|
+
|
|
97
|
+
# resource service backed by a TypeORM repository
|
|
98
|
+
npx avleon make:service product -m product -r --orm
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Middleware
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
npx avleon make:middleware auth
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Generates a class extending `AvleonMiddleware` with an `invoke(req, res)` method.
|
|
108
|
+
|
|
109
|
+
### Config
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
npx avleon make:config jwt
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Generates a class extending `AvleonConfig`, registered via `@AppConfig`.
|
|
116
|
+
|
|
117
|
+
## Development Server
|
|
118
|
+
|
|
119
|
+
```sh
|
|
120
|
+
npx avleon serve
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Compiles `src/` with SWC into `dist/`, starts the entry point, and restarts on
|
|
124
|
+
change to sources, assets or `.env*` files. The entry file is taken from
|
|
125
|
+
`--entry`, `avleon.entry` in `package.json`, `main`, then `dist/serve.js`,
|
|
126
|
+
`server.js`, `main.js` or `index.js`.
|
|
127
|
+
|
|
128
|
+
Type errors are reported by a parallel `tsc --noEmit --watch` (disable with
|
|
129
|
+
`--no-type-check`) and never block a reload. Syntax errors stop the app until
|
|
130
|
+
they are fixed, so stale code never keeps serving.
|
|
131
|
+
|
|
132
|
+
## Build and Run
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
npx avleon build # tsc with tsconfig.build.json, then copy non-TS assets
|
|
136
|
+
npx avleon start # node dist/serve.js with NODE_ENV=production
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Routes
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
npx avleon route:list # compile and read Avleon's route metadata
|
|
143
|
+
npx avleon route:list --static # scan decorators in the source, no dependencies
|
|
144
|
+
npx avleon routes --json
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Doctor
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
npx avleon doctor
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Checks the Node.js version, that `@avleon/core` matches the CLI's version,
|
|
154
|
+
that `reflect-metadata` is installed, and that `experimentalDecorators` and
|
|
155
|
+
`emitDecoratorMetadata` are enabled. Exits non-zero if a check fails.
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { ApiController, Get
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import { ApiController, Get } from '@avleon/core';
|
|
2
|
+
|
|
3
|
+
@ApiController('/{route}')
|
|
4
|
+
export class {ClassName} {
|
|
5
|
+
@Get()
|
|
6
|
+
index() {
|
|
7
|
+
return { message: '{ClassName} works' };
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ApiController, Get, Post, Put, Delete, Param, Query, Body, HttpExceptions } from '@avleon/core';
|
|
2
|
+
import { {ServiceClass} } from '{serviceImport}';
|
|
3
|
+
|
|
4
|
+
@ApiController('/{route}')
|
|
5
|
+
export class {ClassName} {
|
|
6
|
+
constructor(private readonly {serviceVar}: {ServiceClass}) {}
|
|
7
|
+
|
|
8
|
+
@Get()
|
|
9
|
+
async index(@Query() query?: any) {
|
|
10
|
+
if (query && query.page) {
|
|
11
|
+
return this.{serviceVar}.paginate(Number(query.page));
|
|
12
|
+
}
|
|
13
|
+
return this.{serviceVar}.findAll();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Get('/:id')
|
|
17
|
+
async findOne(@Param('id') id: number) {
|
|
18
|
+
const {modelVar} = await this.{serviceVar}.findByPk(Number(id));
|
|
19
|
+
if (!{modelVar}) throw HttpExceptions.notFound('{Model} not found.');
|
|
20
|
+
return {modelVar};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@Post()
|
|
24
|
+
async create(@Body() body: any) {
|
|
25
|
+
return this.{serviceVar}.create(body);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Put('/:id')
|
|
29
|
+
async update(@Param('id') id: number, @Body() updateBody: any) {
|
|
30
|
+
const {modelVar} = await this.{serviceVar}.findByPk(Number(id));
|
|
31
|
+
if (!{modelVar}) throw HttpExceptions.notFound('{Model} not found.');
|
|
32
|
+
const isUpdated = await this.{serviceVar}.update(Number(id), updateBody);
|
|
33
|
+
if (!isUpdated) throw HttpExceptions.internalError("Can't update {Model}");
|
|
34
|
+
return { message: 'Updated successfully' };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Delete('/:id')
|
|
38
|
+
async delete(@Param('id') id: number) {
|
|
39
|
+
const {modelVar} = await this.{serviceVar}.findByPk(Number(id));
|
|
40
|
+
if (!{modelVar}) throw HttpExceptions.notFound('{Model} not found.');
|
|
41
|
+
const isDeleted = await this.{serviceVar}.delete(Number(id));
|
|
42
|
+
if (!isDeleted) throw HttpExceptions.internalError("Can't delete {Model}");
|
|
43
|
+
return { message: 'Deleted successfully' };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
import { ApiController, Get, Post, Delete, Param, Query, Body
|
|
2
|
-
|
|
3
|
-
@ApiController('/{
|
|
4
|
-
export class {
|
|
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
|
-
async delete(@Param('id') id:number){
|
|
31
|
-
throw new Error("Method not implemented.");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
}
|
|
1
|
+
import { ApiController, Get, Post, Put, Delete, Param, Query, Body } from '@avleon/core';
|
|
2
|
+
|
|
3
|
+
@ApiController('/{route}')
|
|
4
|
+
export class {ClassName} {
|
|
5
|
+
@Get()
|
|
6
|
+
async index(@Query() query?: any) {
|
|
7
|
+
throw new Error('Method not implemented.');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@Get('/:id')
|
|
11
|
+
async findOne(@Param('id') id: number) {
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Post()
|
|
16
|
+
async create(@Body() body: any) {
|
|
17
|
+
throw new Error('Method not implemented.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@Put('/:id')
|
|
21
|
+
async update(@Param('id') id: number, @Body() updateBody: any) {
|
|
22
|
+
throw new Error('Method not implemented.');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Delete('/:id')
|
|
26
|
+
async delete(@Param('id') id: number) {
|
|
27
|
+
throw new Error('Method not implemented.');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
@CreateDateColumn()
|
|
18
|
-
createdAt: Date;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
@UpdateDateColumn()
|
|
22
|
-
updatedAt: Date;
|
|
23
|
-
}
|
|
1
|
+
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';
|
|
2
|
+
|
|
3
|
+
@Entity({ name: '{table}' })
|
|
4
|
+
export class {Model} {
|
|
5
|
+
@PrimaryGeneratedColumn()
|
|
6
|
+
id!: number;
|
|
7
|
+
|
|
8
|
+
@Column()
|
|
9
|
+
name!: string;
|
|
10
|
+
|
|
11
|
+
@CreateDateColumn()
|
|
12
|
+
createdAt!: Date;
|
|
13
|
+
|
|
14
|
+
@UpdateDateColumn()
|
|
15
|
+
updatedAt!: Date;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { beforeAll, describe, expect, it } from 'vitest';
|
|
2
|
+
import { AvleonTest } from '@avleon/core';
|
|
3
|
+
import { HomeController } from './home.controller';
|
|
4
|
+
|
|
5
|
+
describe('HomeController', () => {
|
|
6
|
+
let controller!: HomeController;
|
|
7
|
+
|
|
8
|
+
beforeAll(() => {
|
|
9
|
+
controller = AvleonTest.getController(HomeController);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should be defined', () => {
|
|
13
|
+
expect(controller).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should return hello message', () => {
|
|
17
|
+
expect(controller.sayHello()).toEqual({ message: 'Hello World!' });
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiController, Get } from '@avleon/core';
|
|
2
|
+
import { HomeService } from '../services/home.service';
|
|
3
|
+
|
|
4
|
+
@ApiController('/')
|
|
5
|
+
export class HomeController {
|
|
6
|
+
constructor(private readonly homeService: HomeService) {}
|
|
7
|
+
|
|
8
|
+
@Get()
|
|
9
|
+
sayHello() {
|
|
10
|
+
return this.homeService.sayHello();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppConfig, AvleonConfig, Environment, OpenApiUiOptions } from '@avleon/core';
|
|
2
|
+
|
|
3
|
+
@AppConfig
|
|
4
|
+
export class OpenApiConfig extends AvleonConfig<OpenApiUiOptions> {
|
|
5
|
+
config(env: Environment): OpenApiUiOptions {
|
|
6
|
+
return {
|
|
7
|
+
info: {
|
|
8
|
+
title: '{AppTitle} API',
|
|
9
|
+
version: '0.0.1',
|
|
10
|
+
description: 'API documentation for {AppTitle}',
|
|
11
|
+
},{Provider}
|
|
12
|
+
routePrefix: '/docs',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# {AppTitle}
|
|
2
|
+
|
|
3
|
+
Built with [Avleon](https://github.com/avleonjs/avleon-core).
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
{InstallCmd}
|
|
9
|
+
{DevCmd}
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Scripts
|
|
13
|
+
|
|
14
|
+
| Script | Description |
|
|
15
|
+
|--------|-------------|
|
|
16
|
+
| `start:dev` | Start the development server with reload (`avleon serve`) |
|
|
17
|
+
| `build` | Compile TypeScript to `dist/` (`avleon build`) |
|
|
18
|
+
| `start` | Run the compiled app in production (`avleon start`) |
|
|
19
|
+
{TestRow}
|
|
20
|
+
## Project Structure
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
src/
|
|
24
|
+
{Tree}├── app.ts # App setup
|
|
25
|
+
└── serve.ts # Entry point
|
|
26
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"experimentalDecorators": true,
|
|
7
|
+
"emitDecoratorMetadata": true,
|
|
8
|
+
"outDir": "./dist",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
"strict": false
|
|
15
|
+
},
|
|
16
|
+
"include": ["avleon-env.d.ts", "src/**/*"],
|
|
17
|
+
"exclude": ["node_modules", "dist"]
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import swc from 'unplugin-swc';
|
|
2
|
+
import { defineConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
// SWC emits the decorator metadata that Avleon's dependency injection
|
|
6
|
+
// and validation rely on; Vitest's default transform (esbuild) does not.
|
|
7
|
+
plugins: [swc.vite()],
|
|
8
|
+
test: {
|
|
9
|
+
environment: 'node',
|
|
10
|
+
include: ['src/**/*.spec.ts'],
|
|
11
|
+
coverage: {
|
|
12
|
+
include: ['src/**/*.ts'],
|
|
13
|
+
exclude: ['src/**/*.spec.ts'],
|
|
14
|
+
reportsDirectory: 'coverage',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { AppService } from '@avleon/core';
|
|
2
|
-
|
|
3
|
-
@AppService
|
|
4
|
-
export class {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
1
|
+
import { AppService } from '@avleon/core';
|
|
2
|
+
|
|
3
|
+
@AppService
|
|
4
|
+
export class {ClassName} {
|
|
5
|
+
sayHello() {
|
|
6
|
+
return 'Hello World!';
|
|
7
|
+
}
|
|
8
|
+
}
|