diff --git a/docs/site/Loopback-application-layout-reference.md b/docs/site/Loopback-application-layout-reference.md new file mode 100644 index 000000000000..864f7547229e --- /dev/null +++ b/docs/site/Loopback-application-layout-reference.md @@ -0,0 +1,129 @@ +--- +lang: en +title: 'LoopBack 4 Application Layout' +keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript +sidebar: lb4_sidebar +permalink: /doc/en/lb4/Loopback-application-layout.html +--- + +A LoopBack 4 application that was created by the command +[`lb4 application`](Application-generator.md) 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. + +{% include tip.html content="By LoopBack naming conventions, artifacts such as models are grouped under their sub-directories. Also, with LoopBack artifact generators, they create class names in CamelCase and file names are in snake-case. For example, if you create a model named `MyUserModel` with the model generator, it creates the file `my-user.model.ts` under `src/models` directory. See [Naming Convention](Command-line-interface.md#naming-convention) for more information. +" %} + +The following table uses files in the +[`Todo` example](https://github.com/strongloop/loopback-next/tree/master/examples/todo) +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. | ++ |