Skip to content

Backend development

marksvc edited this page Feb 15, 2023 · 1 revision

Normally when you run dotnet run it starts ng serve for you. This works great if you are developing on the front end as it watches for file changes and reloads your browser once it has compiled.

If you are developing on the backend this works better

cd src/SIL.XForge.Scripture/
dotnet watch run --start-ng-serve=listen

In another terminal

cd src/SIL.XForge.Scripture/ClientApp/
ng serve

When files change on the backend it will compile the changes automatically and now ng serve won't re-start every time.

See the Debugging section below for how to do this in VS Code.

Model Changes

The Angular app has a dependency on the Node backend NPM package so that it has access to the model types. If the models are changed, the Angular app will not see the changes until the backend package is rebuilt. You can rebuild the backend by executing the following commands:

cd src/RealtimeServer/
npm run build

If a model change is made, then a corresponding data migration should be implemented in the Node backend. A data migration is implemented by following these steps:

  1. Create a class that extends the Migration base class with the name <collection>Migration<version> in the appropriate collection migrations file. For example, if you are adding a user migration for schema version 10, then you would add the class UserMigration10 to the src/RealtimeServer/common/services/user-migrations.ts file.
  2. Implement the migrateDoc method. The submitMigrationOp function MUST be used to submit any migration changes to the doc.
  3. Implement the migrateOp method.
  4. Add the class to the migrations array in the migrations file.
Clone this wiki locally