Creating a new application
As you saw in Getting Started > Create a simple API, the easiest way to create an application is to use slc loopback
, the application generator.
Once you create your application, you may want to configure it, for example: Turn off stack traces, disable API Explorer, and retrieve the values of environment variables. See Environment-specific configuration for more information.
Standard project layout
The application generator creates an application with the standard project layout. To summarize:
server
directoryserver.js
- Main application script; see below.config.json
- Global application settings, such as the REST API root, host name and port to use, and so on. See config.json.model-config.json
- Binds models to data sources and specifies whether a model is exposed over REST, among other things. See model-config.json.datasources.json
- Data source configuration file. See datasources.json.
client
directory (empty except for a README stub)common/models
directory - created when you create a model with the Model generator,slc loopback:model
.- A JSON file and a JavaScript file for each model (for example,
my-model.json
andmy-model.js
).
- A JSON file and a JavaScript file for each model (for example,
Main application script (server.js)
This is the main application script in the standard scaffolded application, as created by slc loopback
.