Skip to main content
Version: 4.x

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​

OptionDefaultWhat it does
--jsonoffPrint the whole report as one JSON object.
--src <path>./srcThe 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.

MemberWhat it holds
schemaVersionChanges when a member is renamed or removed. Members can be added without changing it.
sourcestatic: the facts were read from source.
routesMethod, path with the global prefix, controller, handler, file and line; body and middleware when declared.
controllers, services, providersName, file and the names of what each asks the container for.
middlewareThe same, with where each runs (scope) and the controllers it is attached to.
modulesEach module with the classes it lists.
dependenciesOne 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.