This application is generated using LoopBack 4 CLI with the initial project layout.
By default, dependencies were installed when this application was generated.
Whenever dependencies in package.json are changed, run the following command:
npm installTo only install resolved dependencies in package-lock.json:
npm ci- Create
User&UserCredentialsfor integrating JWT
$ lb4 model User
? Please select the model base class Entity (A persisted model with an ID)
? Allow additional (free-form) properties? No
Model User will be created in src/models/user.model.ts
Let's add a property to User
Enter an empty property name when done
? Enter the property name:
create src/models/user.model.ts
update src/models/index.ts
Model User was/were created in src/models$ lb4 model UserCredentials
? Please select the model base class Entity (A persisted model with an ID)
? Allow additional (free-form) properties? No
Model UserCredentials will be created in src/models/user-credentials.model.ts
Let's add a property to UserCredentials
Enter an empty property name when done
? Enter the property name:
create src/models/user-credentials.model.ts
update src/models/index.ts
Model UserCredentials was/were created in src/models-
Replace
models/user.model.ts&models/user-credentials.model.tsby user.model.ts & user-credentials.model.ts -
Create repositories for
UserandUserCredentials
$ lb4 repository
? Please select the datasource PostgresqlDatasource
? Select the model(s) you want to generate a repository for UserCredentials, User
? Please select the repository base class DefaultCrudRepository (Juggler bridge)
? Please enter the name of the ID property for UserCredentials: id
? Please enter the name of the ID property for User: id
create src/repositories/user-credentials.repository.ts
create src/repositories/user.repository.ts
update src/repositories/index.ts
update src/repositories/index.ts
Repositories UserCredentialsRepository, UserRepository was/were created in src/repositories-
Run
npm run build -
Modify
datasources/postgresql.datasource.tsto meet the proper PostgreSQL configurations then create a new PostgreSQL database depending on your configurations. -
Run
npm run migrate -
Delete the following files:
models/user.model.tsmodels/user-credentials.model.tsrepositories/user.repository.tsrepositories/user-credentials.repository.ts
- Modify
models/index.tsby deleting the following lines:
export * from './user.model';
export * from './user-credentials.model';- Modify
repositories/index.tsby deleting the following lines:
export * from './user-credentials.repository';
export * from './user.repository';npm startYou can also run node . to skip the build step.
Open http://127.0.0.1:3000 in your browser.
To incrementally build the project:
npm run buildTo force a full build by cleaning up cached artifacts:
npm run rebuildnpm run lintTo automatically fix such issues:
npm run lint:fixnpm run migrate: Migrate database schemas for modelsnpm run openapi-spec: Generate OpenAPI spec into a filenpm run docker:build: Build a Docker image for this applicationnpm run docker:run: Run this application inside a Docker container
npm testPlease check out LoopBack 4 documentation to understand how you can continue to add features to this application.
-@2x.png)