very-express 0.5.25 → 0.5.26
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/copilot-instructions.md +84 -0
- package/README.md +14 -1
- package/dist/index.js +704 -810
- package/dist/templates/_projectSettings/env +2 -0
- package/dist/templates/_projectSettings/package.json +53 -49
- package/dist/templates/_services/VexDbConnector.ts +159 -19
- package/dist/templates/_services/VexSystem.ts +34 -18
- package/dist/templates/_types/VexResponsePayloadError.ts +20 -0
- package/dist/templates/_utils/logger.ts +2 -2
- package/dist/templates/root/tsconfig.json +8 -2
- package/docs/roadMap/futurePlan.md +9 -0
- package/package.json +9 -2
- package/scripts/bump-version.js +87 -0
- package/docs/roadMap/v0-7-0.md +0 -5
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Project Guidelines — VeryExpress
|
|
2
|
+
|
|
3
|
+
VeryExpress is a **code generator** that reads JSON Schema files and produces a complete Express.js REST API (with Mongoose, RBAC, OAuth2, Swagger). The CLI entry is `src/cli.ts`; the orchestrator is `src/index.ts` → `generate()`.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
jsonSchema/*.json → preprocess → generators → templates → output/
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
| Directory | Role |
|
|
12
|
+
|-----------|------|
|
|
13
|
+
| `src/generators/` | Async `compile()` functions that call templates and write files |
|
|
14
|
+
| `src/templates/` | Static base files copied verbatim (with `.gen.ts` suffix) to output |
|
|
15
|
+
| `src/preprocess/` | Schema validation & normalisation before generation |
|
|
16
|
+
| `src/types/types.ts` | Core interfaces: `compilerOptions`, `jsonSchema`, `jsonSchemaPropsItem` |
|
|
17
|
+
| `src/utils/` | File I/O, logging, JSON-schema helpers, template formatter |
|
|
18
|
+
| `output/` | Generated Express app — **do not hand-edit `*.gen.ts` files** |
|
|
19
|
+
|
|
20
|
+
## Build and Test
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm run dev # compile (esbuild → dist/index.js) + run CLI
|
|
24
|
+
npm run build # lint + compile (production)
|
|
25
|
+
npm run lint # eslint --fix
|
|
26
|
+
npm run v <type> # bump version (major | minor | patch)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- Build bundles everything into a single `dist/index.js` via esbuild (platform: node, target: es2016).
|
|
30
|
+
- `scripts/copyTsTemplates.js` copies static templates into `output/` after compilation.
|
|
31
|
+
- No test suite exists yet; validate changes by running `npm run dev` and inspecting `output/`.
|
|
32
|
+
|
|
33
|
+
## Conventions
|
|
34
|
+
|
|
35
|
+
### Generator pattern
|
|
36
|
+
|
|
37
|
+
Every generator exports an async `compile(options)` that:
|
|
38
|
+
1. Validates / extracts data from options
|
|
39
|
+
2. Calls a `*Template()` function returning a string
|
|
40
|
+
3. Writes the result with `utils.common.writeFile()`
|
|
41
|
+
|
|
42
|
+
### Template pattern
|
|
43
|
+
|
|
44
|
+
- Template functions live in `*.template.ts` beside their generator.
|
|
45
|
+
- Use `{{placeholder}}` syntax replaced via `.replace(/{{placeholder}}/g, value)`.
|
|
46
|
+
- `FUNC{{ <code> }}` embeds runnable JS in generated output (processed by `utils/template.ts → format()`).
|
|
47
|
+
|
|
48
|
+
### Naming
|
|
49
|
+
|
|
50
|
+
| Artifact | Convention | Example |
|
|
51
|
+
|----------|-----------|---------|
|
|
52
|
+
| Generated files | `{DocName}{Type}.gen.ts` | `UserController.gen.ts` |
|
|
53
|
+
| Controller class | PascalCase | `UserController` |
|
|
54
|
+
| REST endpoint | lowercase `documentName` | `/user`, `/userContact` |
|
|
55
|
+
| Template function | camelCase default export | `controllerTemplate()` |
|
|
56
|
+
| Role class | `Role{Name}` | `RoleAdmin` |
|
|
57
|
+
|
|
58
|
+
### JSON Schema extensions
|
|
59
|
+
|
|
60
|
+
Custom `x-*` properties drive generation — see [docs/vexJsonSchema.md](../docs/vexJsonSchema.md):
|
|
61
|
+
|
|
62
|
+
- `x-documentConfig` — REST methods, document name
|
|
63
|
+
- `x-foreignKey` / `x-foreignValue` — relationships ([docs/ForeignKey.md](../docs/ForeignKey.md))
|
|
64
|
+
- `x-vexData: "role"` — marks role field for RBAC
|
|
65
|
+
- `x-format: "ObjectId"` — MongoDB ObjectId handling
|
|
66
|
+
|
|
67
|
+
### Path aliases
|
|
68
|
+
|
|
69
|
+
`tsconfig.json` maps `~/*` → `src/*`. Use `~/generators/...` style imports.
|
|
70
|
+
|
|
71
|
+
## Key docs (link, don't duplicate)
|
|
72
|
+
|
|
73
|
+
- [docs/vexJsonSchema.md](../docs/vexJsonSchema.md) — full schema definition guide
|
|
74
|
+
- [docs/ForeignKey.md](../docs/ForeignKey.md) — foreign-key joins and `_join`/`_select` params
|
|
75
|
+
- [docs/appGenerated/auth.md](../docs/appGenerated/auth.md) — JWT rolling keys, OAuth2 setup
|
|
76
|
+
- [docs/developmentNote.md](../docs/developmentNote.md) — dev conventions, `FUNC{{ }}` syntax
|
|
77
|
+
- [docs/roadMap/](../docs/roadMap/) — released features and upcoming plans
|
|
78
|
+
|
|
79
|
+
## Pitfalls
|
|
80
|
+
|
|
81
|
+
- **`output/` is regenerated** — never edit `*.gen.ts` files by hand; changes will be overwritten on next `vex` run.
|
|
82
|
+
- **Schema ↔ filename mismatch** — `x-documentConfig.documentName` must match the JSON schema filename (e.g. `User.json` → `"documentName": "User"`).
|
|
83
|
+
- **`required` field format** — the preprocessor normalises `required: true` on individual properties into a root-level `required: string[]`, but source schemas should use the array form.
|
|
84
|
+
- **No test runner** — confirm changes by running `npm run dev` and inspecting `output/`.
|
package/README.md
CHANGED
|
@@ -54,7 +54,20 @@ eventually lead to a usefull and powerful framework.
|
|
|
54
54
|
npm run start
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
## Project Versioning
|
|
58
|
+
This project use versioning based on (Semantic Versioning)[https://semver.org/]
|
|
59
|
+
|
|
60
|
+
Use this instead :
|
|
61
|
+
```cmd
|
|
62
|
+
npm run v <version-type>
|
|
63
|
+
```
|
|
64
|
+
Version Types :
|
|
65
|
+
- `major` version when you make incompatible API changes
|
|
66
|
+
- `minor` version when you add functionality in a backward compatible manner
|
|
67
|
+
- `patch` version when you make backward compatible bug fixes
|
|
68
|
+
- `dev` simply mark for development, you should not publish under this versions
|
|
69
|
+
|
|
70
|
+
# Resources
|
|
58
71
|
- [Documents](./docs/)
|
|
59
72
|
- [Road Map](./docs/roadMap/)
|
|
60
73
|
- [ReleaseNote](./docs/releaseNote)
|