Page Contents

A LoopBack 4 application that was created by the command lb4 application has files and directories in the application root directory. Within this directory, the standard LB4 application structure has these sub-directories:

  • src - TypeScript source code and configuration files.
  • public - Client side assets (JavaScript, HTML, and CSS files) for the home page.

The following table uses files in the Todo example as code references.

File or directory Description How to create/access
Top-level application directory
package.json Standard npm package specification. Use it to set up package dependencies, among other things. This file must be in the application root directory. See npm-package.json for information. N/A
README.md Stub file for internal documentation. N/A
tsconfig.json A file specifies the root files and the compiler options required to compile the project. See tsconfig.json for information. N/A
dist/ Contains transpiled JavaScript code generated by npm run build. Notice that npm run build does incremental build. A full build can be achieved using npm run clean && npm run build. npm run build
/src directory - Node application files
controllers/ A sub-directory for all controller files. See Controller. lb4 controller
datasources/ A sub-directory for all dataSource files. See DataSource. lb4 datasource
models/ A sub-directory for all model files. See Model. lb4 model
repositories/ A sub-directory for all repository files. See Repository. lb4 repository
__test__/ A directory for all tests.  
application.ts Main application program file. A central registry file for inversion of control and dependency injection. See Application. N/A
index.ts A script that initializes and runs the application. N/A
migrate.ts A script to run database migration. See Database Migrations. npm run build && npm run migrate
openapi-spec.ts A script that exports the OpenAPI spec from the application. npm run build && npm run openapi-spec
sequence.ts A file where to define a series of steps to control how a specific type of `Server` responds to incoming requests. See Sequence. N/A
/public directory - Client application files
index.html An example LoopBack front page. N/A
Others Add your HTML, CSS, client JavaScript files.