Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Run ApiCenter locally

Philippa Hack edited this page May 9, 2019 · 1 revision

ApiCenter consists of a RESTful backend service written in Kotlin and a SPA frontend in Angular. Both are contained in this git repo.

To run ApiCenter locally, you need gradle and angular CLI. The backend can use a relational database, for example PostgreSQL, or will provide an in-memory database otherwise. (To install angular CLI, enter npm install -g @angular/cli)

There are two ways to run ApiCenter: usually you would run the tasks of the frontend and backend together, for simplicity. The other way runs frontend and backend separately, and requires two terminal sessions. However this has advantages for a developer of the project, which are explained further down.

Combined

From the project root directory, run:

./gradlew :monoBuild

The :monoBuild task is composed of three subtasks, which can be independently invoked if needed:

  • :frontend:buildClientDev runs Angular's build command, producing the output files in the default location frontend/dist.
  • :frontend:copyFrontendFiles copies these files into a directory in backend from which Spring will serve static resources.
  • :backend:bootRun will compile and run the backend.

The service is available from localhost:8080 (Spring boot's default port).

Separate

The combined command is simpler to run, however has disadvantages to developers, who are likely to make modifications to the source files. Any change to frontend or backend requires re-running bootRun, which recompiles both projects. The in-memory database used by the backend will be reset.

For the frontend, this is unnecessary. When developing in Angular, ng serve will handily watch for changes to the source files, and the live development site will auto-update to reflect them.

Also, since the frontend build task depends on npm install, every run of :frontend:buildClientDev will do npm's somewhat time consuming and unskippable package audit. Without this task, npm i can run independently of ng serve (or ng build).

To start the backend, from the project root directory, run:

./gradlew :backend:bootRun

To start the frontend, from the project root directory, run:

cd frontend/
ng serve -c=localhost

The service is available from localhost:4200 (Angular's default port).

Clone this wiki locally