Inspect
expressots inspect prints the structure of a project in one call: its routes, controllers, services, providers, middleware and modules, and which class asks the container for which.
Everything is read from the source files. Nothing in the project is executed, so it shows what the code declares, and it works on a project that does not start. Available since 4.4.0.
expressots inspect
1 controller, 3 routes, 1 service, 0 providers, 0 middleware, 0 modules. Read from ./src; nothing was run.
Global prefix: /api
Routes
GET /api/users UserController.list
POST /api/users UserController.create (body CreateUserDto)
GET /api/users/:id UserController.findById
Dependencies (who asks the container for what)
UserController -> UserRepository
UserRepository -> AppDatabaseProvider
Options
| Option | Default | What it does |
|---|---|---|
--json | off | Print the whole report as one JSON object. |
--src <path> | ./src | The source directory to scan. |
JSON output
With --json the only thing written to standard output is the report, so it can be piped into a parser.
expressots inspect --json
{
"schemaVersion": 1,
"source": "static",
"src": "./src",
"globalPrefix": "/api",
"summary": {
"controllers": 1,
"routes": 3,
"services": 1,
"providers": 0,
"middleware": 0,
"modules": 0,
"dependencies": 2
},
"routes": [
{
"method": "POST",
"path": "/api/users",
"controller": "UserController",
"handler": "create",
"file": "src/users/user.controller.ts",
"line": 19,
"body": "CreateUserDto"
}
],
"controllers": [
{ "name": "UserController", "file": "src/users/user.controller.ts", "dependencies": ["UserRepository"], "routes": 3 }
],
"services": [
{ "name": "UserRepository", "file": "src/users/user.repository.ts", "dependencies": ["AppDatabaseProvider"] }
],
"providers": [],
"middleware": [],
"modules": [],
"dependencies": [
{ "from": "UserController", "to": "UserRepository", "fromKind": "controller" }
]
}
The example shows one route of the three and one dependency of the two.
| Member | What it holds |
|---|---|
schemaVersion | Changes when a member is renamed or removed. Members can be added without changing it. |
source | static: the facts were read from source. |
routes | Method, path with the global prefix, controller, handler, file and line; body and middleware when declared. |
controllers, services, providers | Name, file and the names of what each asks the container for. |
middleware | The same, with where each runs (scope) and the controllers it is attached to. |
modules | Each module with the classes it lists. |
dependencies | One entry for each class that asks for another: from, to and what kind of class from is. |
File paths are relative to the project, with forward slashes, and every list is sorted, so two runs over the same source print the same text on any machine.
Requirements
The scan is the one ExpressoTS Studio uses, so the project needs @expressots/studio installed. Without it the command says how to install it and exits with status 1; it does not install anything itself.
Inspect or check
inspect reads the source and tells you what is declared. check starts the application and tells you whether what is declared can be resolved. A route can be listed by inspect in a project that check refuses.