0

Is it possible to create a singleton service within a “common-components” app and reference that within another angular application? The service’s function would be for CRUD operations that are shared between all the applications.

We have five angular 8 applications hosted in a microservice fashion.

4
  • 1
    Would you be able to create an NPM module and wrap it in a service for each of your applications? I've done this before with an CRUD SDK that was used on a frontend app along with several back end services. Commented Feb 11, 2020 at 16:22
  • This would rather depend on the project structure. Are using an angular workspace? Are all the apps in the same repo? Commented Feb 11, 2020 at 16:43
  • @Keeleon that is possible to create a module. Right now it’s built like a module (doesn’t run code but the component are created into a bundle). How would we reference that within the other applications? Commented Feb 11, 2020 at 18:00
  • @C_Ogoo it’s 5 different repos. All are hosted on different url endpoints and there’s a “main” app we will use for the apps to run on but They can all run by themselves. Commented Feb 11, 2020 at 18:03

1 Answer 1

1

You can consider using Nx workspace, it will fit perfectly your need.

You will be able to organize your code in different libraries, and then share them between multiple applications.

Nx workspace permits also to build fullstack applications with for example React, Angular and backend NestJs code in the same monorepo, and some common libraries (for interfaces for example).

Perfect for a microservice architecture.

Some recommended resources :

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the info. Unfortunately for hosting the application we are singled to using cloudfoundry. As for the DDD approach, the 5 apps are separated to do specific domain tasks. To assist in this I would like to use that service application to do the data retrieval for the microservices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.