Code organized using Nx.
-
Run
npm run gen:app -- my-app
to generate new service (application). -
Add
"build:my-app": "nx build my-app --prod"
and"serve:my-app": "nx serve my-app"
topackage.json
scripts sections -
Create file
apps/my-app/src/app/service.ts
with class which extendsBaseService
orHttpService
from@cryptuoso/service
. -
Update file
apps/my-app/src/main.ts
whith service starting script:
import Service from "./app/service";
import log from "@cryptuoso/logger";
const service = new Service();
async function start() {
try {
await service.startService();
} catch (error) {
log.error(`Failed to start service ${process.env.SERVICE}`, error);
process.exit(1);
}
}
start();
- Copy
deployments/deployment-template.yaml
file todeployments/my-app.yaml
, add environment variables and change ports
Run npm run gen:lib -- my-lib
to generate a library.
Run nx build my-app
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run nx test my-app
to execute the unit tests via Jest.
Run nx affected:test
to execute the unit tests affected by a change.
Run nx dep-graph
to see a diagram of the dependencies.