LoopBack project files and directories are in the application root directory. Within this directory the standard LoopBack project structure has three sub-directories:
server
- Node application scripts and configuration files.client
- Client JavaScript, HTML, and CSS files.common
- Files common to client and server. The/models
sub-directory contains all model JSON and JavaScript files.definitions
- API and product definition YAML files (IBM API Connect only).
Note:
All model JSON and JavaScript files that are shared between client and server go in the /common/models
directory. Server-only files go in /server/models
, and client-only go in/client/models
File or directory | Description | How to access in code |
---|---|---|
Top-level application directory | ||
/node-modules directory |
Contains Node packages as specified as dependencies in package.json . Update with npm install . |
N/A |
Standard npm package specification. See package.json. |
N/A | |
README.md |
Stub file for internal documentation. | N/A |
/server directory - Node application files | ||
/boot directory |
Add scripts to perform initialization and setup. See boot scripts. | Scripts are automatically executed in alphabetical order. |
component-config.json |
Specifies LoopBack components to load. | Created by Strongloop tools only. Not used in API Connect. |
config.json |
Application settings. See config.json. | app.get('setting-name') |
datasources.json |
Data source configuration file. See datasources.json. For an example, see Create new data source. | app.datasources['datasource-name'] |
middleware.json |
Middleware definition file. For more information, see Defining middleware. | N/A |
middleware.production.json |
Middleware definition file with production configuration. See Preparing for deployment. | |
model-config.json |
Model configuration file. See model-config.json. For more information, see Connecting models to data sources. | N/A |
server.js |
Main application program file. | N/A |
/client directory - Client application files | ||
README.md | LoopBack generators create empty README.md file. |
N/A |
Other | Add your HTML, CSS, client JavaScript files. | |
/common directory - shared application files | ||
/models directory |
Custom model files:
For more information, see Model definition JSON file and Customizing models. See note below. |
Node: |
Important:
The LoopBack model generator
automatically converts camel-case model names (for example MyModel) to lowercase dashed names (my-model).
For example, if you create a model named “FooBar” with the model generator, it creates files foo-bar.json
and foo-bar.js
in common/models
.
However, the model name (“FooBar”) will be preserved via the model’s name property.