Uncaught (in promise): Error: Cannot match any routes. URL Segment: Angular

hice un login y lugo redirijo a otro ruoter y en este aparece el header y el footer pero no muestra lo componentes que se cargan en el
introducir la descripción de la imagen aquí

introducir la descripción de la imagen aquí

introducir la descripción de la imagen aquí

TypeScript Express: controller in controller using dependency injection or logic in routes

I am trying to give a controller an operation. However, some Controllers exist with 2 or more operations. I'm not sure what is the best way to structure this part of the application.

For example, I have 2 controller functions, each doing its own independent job.
1. intentGetUserById (check input, call database provider, return user or error)
2. I try to verify Token (check input, try to verify token, return valid / invalid)

So there is another controller "intentCheckUser"which essentially calls
-> intentVerifyToken -> if the token is valid -> intentGetUserById

This controller is called via a route.

Now, I have 3 variants that could be acceptable.

Variant1
This variant is the one described above. When the API endpoint is accessed it will call intentCheckUser, which calls the other 2 controllers. There is no logic in Endpoint.

// routes.ts
{
    path: '/api/core/users/check',
    method: 'post',
    handler: (
      async ({ headers: { authorization } }: Request, res: Response, next: NextFunction) => {
        const { error, user } = await attemptCheckUser(authorization)
        if (error) return next(error);
        return res.status(200).send(user);
      },
    ),
  },
  ...

// auth.controller.ts
export const attemptVerifyToken = (token: string) => {
  if (token) {
    const secret = "xxx";
    // only provider - no logic in verifyToken
    const { error, userId } = verifyToken(token, secret); 
    if(error) return { error };
    return { userId, token };
  }
  return { error: new HTTP400Error() };
};


// user.controller.ts
export const attemptGetUserById = async (_id: string) => {
  if (_id) {
    try {
      // only provider - no logic in getFullUserById only db operation
      const user = await getUserById(_id);
      if (user) return { user };
      return { error: new HTTP404Error() };
    } catch (e) {
      return { error: new HTTP400Error(e) };
    }
  }
  return { error: new HTTP400Error() };
};

export const attemptCheckUser = async (token: string) => {
  const { error, userId} = attemptVerifyToken(token);
  if (error) return { error };

  if (userId) {
    const { error, user } = await attemptGetUserById(userId);
    if (error) return { error };
    return { user };
  }
  return { error: new HTTP400Error() };
}

Variant2
Instead of having intentCheckUser, move logic to Endpoint / Route so that each Controller continues to have a single operation. I try VerifyToken and intentGetUserById will remain the same as in variant 1

// routes.ts
{
  path: '/api/core/users/check',
  method: 'post',
  handler: (
    async ({ headers: { authorization } }: Request, res: Response, next: NextFunction) => {
      const { error, userId } = attemptVerifyToken(authorization);
      if (error) return next(error);
      if (userId) {
        const { error, user } = await attemptGetUserById(userId);
        if (error) return next(error);
        return res.status(200).send(user);
      }
      return next();
    },
  ),
},
...

// auth.controller.ts
export const attemptVerifyToken = (token: string) => {
  if (token) {
    const secret = "xxx";
    // only provider - no logic in verifyToken
    const { error, userId } = verifyToken(token, secret); 
    if(error) return { error };
    return { userId, token };
  }
  return { error: new HTTP400Error() };
};


// user.controller.ts
export const attemptGetUserById = async (_id: string) => {
  if (_id) {
    try {
      // only provider - no logic in getFullUserById only db operation
      const user = await getUserById(_id);
      if (user) return { user };
      return { error: new HTTP404Error() };
    } catch (e) {
      return { error: new HTTP400Error(e) };
    }
  }
  return { error: new HTTP400Error() };
};

Variant 3
This variant is almost identical to Variant 1, however the path injects the dependencies (the other 2 controllers) in intentCheckUser. This controller gets a new interface.

// routes.ts
{
  path: '/api/core/users/check',
  method: 'post',
  handler: (
    async ({ headers: { authorization } }: Request, res: Response, next: NextFunction) => {
      const { error, user } = await attemptCheckUser(
        {
          attemptVerifyToken,
          attemptGetUserById,
        },
        authorization,
      );
      if (error) return next(error);
      return res.status(200).send(user);
    },
  ),
},
...

// auth.controller.ts
export const attemptVerifyToken = (token: string) => {
  if (token) {
    const secret = "xxx";
    // only provider - no logic in verifyToken
    const { error, userId } = verifyToken(token, secret); 
    if(error) return { error };
    return { userId, token };
  }
  return { error: new HTTP400Error() };
};


// user.controller.ts
export const attemptGetUserById = async (_id: string) => {
  if (_id) {
    try {
      // only provider - no logic in getFullUserById only db operation
      const user = await getUserById(_id);
      if (user) return { user };
      return { error: new HTTP404Error() };
    } catch (e) {
      return { error: new HTTP400Error(e) };
    }
  }
  return { error: new HTTP400Error() };
};



interface OptionsCheckUser {
 attemptVerifyToken: (token: string, skipToken?: boolean) => any;
 attemptGetFullUserById: (userId: string, organisationId: string) => any;
}

export const attemptCheckUser = async (dependencies: OptionsCheckUser, token: string) => {
  const { error, userId} = dependencies.attemptVerifyToken(token);
  if (error) return { error };

  if (userId) {
    const { error, user } = await dependencies.attemptGetUserById(userId);
    if (error) return { error };
    return { user };
  }
  return { error: new HTTP400Error() };

I'm creating this question here in codereview, because I came up with the idea of Variant 3. I wanted to undock those drivers that call other drivers, however it just doesn't feel right. The reason I'm not sure is that the interface needs to describe the injected functions quite accurately, which means that there are probably no other functions it can inject since those functions would theoretically be doing the same job, so they simply do not exist (since they would be duplicates).

Note: Please note this is a simplified example. The application will have multiple services, and a controller will need to call other controller functions from a different service. That's why I discovered that I need some sort of decoupling of those Controllers and how they call other Controller functions inside.

What variant would you choose (if any) and why?

Thank you very much in advance!

architecture – Proper way of structuring nested routes in SPA with reusable components?

I am building a shop module in a front-end application (angular) which is going to have multiple product categories, sub-categories, and products. Following requirements should be met:

  • HTML and CSS of each components never changes. It consist of a simple card component which has an image and a title/description (this is applicable for all categories, sub-categories, and products list)
  • Number of categories, sub-categories, and products is know for the moment, but can expand in future.

There are two ways in my mind to achieve the goal:

Have dynamic routes with only 4 components

export const routes: Routes = (
    { path: '', component: SomeProductCategoryComponent },
    { path: ':category', component: SomeProductSubCategoryComponent  },
    { path: ':category/:subCategory', component: SomeProductListComponent },
    { path: ':category/:subCategory/:id', component: SomeProductDetailComponent },
);

Have static routes (per category, sub-category, and product), and corresponding components

export const routes: Routes = (
    { path: '', component: SomeProductCategoryComponent },
    { path: 'some-category1', component: SomeProductSubCategoryComponent1  },
    { path: 'some-category2', component: SomeProductSubCategoryComponent2  },
    { path: 'some-category1/some-sub-category1', component: SomeProductListComponent1 },
    { path: 'some-category2/some-sub-category2', component: SomeProductListComponent2 },
    { path: 'some-category1/some-sub-category1/:id', component: SomeProductDetailComponent1 }
    { path: 'some-category2/some-sub-category2/:id', component: SomeProductDetailComponent2 }
);

Could you please advice if any of the ways are good enough, or if not, what others directions I should look into?

routes: 26 & # 39; U-Haul with 12 & # 39; x6 & # 39; trailer from Eugene, OR to Little Rock, AR

For a trailer of 26 & # 39; U-Haul with 12 & # 39; x6 & # 39; which goes from Eugene, OR to Little Rock, AR, I see that Google takes me on the 84 and 80 freeways, but I don't like this route. However, it may be the safest and only route to take in May 2020. Is there any other viable route with these vehicles? I wanted to go through Salt Lake City and Albuquerque, but I'm afraid it would be too hilly.

routes: routing route with entity reference field

I am working on a custom module (my_module) which provides some functionality to a specific type of paragraph (my_paragraph) created from the user interface. In my routing file I have:

my_module_controller_action:
  path: '/node/{node}/my_paragraph/{paragraph}'
  defaults:
    _controller: 'Drupalmy_moduleControllerMyModuleController::action'
    _title: 'page title'
  requirements:
    _permission: 'access content'

Now I add a new entity reference field field_paragraph for me basic page content type, using this field I can add my_paragraph along with other types of paragraphs.

With this setup, I create a basic page, add a snippet of my_paragraphand save it (/node/123) I can see that my custom controller is not called (because now the way is /node/123), but if I go to /node/123/my_paragraph/1, my custom controller is called there and I get the output I want.

So my questions are:

  1. What should I do so that my custom controller can be used in /node/123 page?
  2. If I alias /node/123 to /about using pathauto, how can i achieve the same result?

Update / Note

In fact, I am refactoring an old custom module that I wrote and trying to get away from the hook approach if possible. One of the main motivations for me when refactoring is that I can use one or more services (along with dependency injections) to separate all possible logics here. (What would you do if you were using a Symfony framework)?

Algorithms: minimum number of edges for two routes to reach their destinations with a distance from each point on their routes

Part 1: Given an undirected, unweighted and connected graph und = (𝑉, 𝐸), what is the minimum time it takes for the party 𝑋 to go from 𝑠𝑥 to 𝑡𝑥 and the party 𝑌 to go from 𝑠𝑦 to 𝑡𝑦? In each time unit, 𝑋 and 𝑌 can move to a vertex adjacent to their current position or not move at all. 𝑋 and 𝑌 are enemies to each other and if they go less than a distance of 𝑘 between them they will go to war. The distance of 𝑋 and 𝑌 is defined as the number of edges between them on the shortest path. What is an efficient algorithm to find the two optimal routes so that 𝑋 and 𝑌 do not go to war and both reach their destinations in the shortest possible time? Note that the two routes can share edges as long as 𝑋 and 𝑌 do not go less than k units each other during their journey.

Part 2: Given the two starting vertices 𝑠1 and 𝑠2 and the two ending vertices 𝑡1 and 𝑡2, is there a path from 𝑠1 to 𝑡1 and 𝑠2 to 𝑡2 so that the number of edges between the two paths is at least a distance from two points? in the path. Show this to be NP-hard without routes getting close to each other. Consider using 3-SAT.

co.combinatorics: what is the number of routes that return to 0 in the hexagonal network?

I'm looking for an estimate of the number of paths in length. $ n $ going from 0 to 0 in the hexagonal net (or honeycomb).

I can find a lot of references about self-avoiding paths, but I am looking at all paths. Is it considerably more difficult? Does anyone have a reference?

automaton: multiple routes for a chain of acceptance in NFA?

Yes, there can be many routes from the initial state to the final state. It is not too difficult to prepare many trivial examples of when this happens, for example

2 Path NFA

Clearly accept the chain $ ab $ but it can go through anyone $ s1 $ or $ s2 $.

However, in DFA this will never happen because in each state there is only one possible transition for each character, and those fixed transitions uniquely determine the path.

terminal – $ PATH only shows RVM files; Other routes are not shown on Macbook ** Requires urgent help **

when I run echo $ PATH I always get bin Ruby or RVM files and I don't get any of the paths I added in my .bash_profile; I am using a Macbook pro and I run Catalina. I am using the default terminal to check my route … I checked .bashprofile, .profile and also Bashrc., What could be wrong here? Please someone help me …

echo $ PATH results:

/Users/rr/.rvm/gems/ruby-2.7.0/bin:/Users/rr/.rvm/gems/ruby-2.7.0@global/bin:/Users/rr/.rvm/rubies/ruby- 2.7.0 / bin: / usr / local / bin: / usr / bin: / bin: / usr / sbin: / sbin: /Applications/VMwareFusion.app/Contents/Public: /Users/rr/.rvm/bin

rr @ rr-MacBook-Pro ~% echo $ CLASSPATH – returns a null value

.Bash_profile:

export JAVA_HOME = $ PATH: /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
export M2_HOME = $ PATH: /usr/local/Cellar/maven/3.6.3_1

Export PATH = $ PATH: / Library / PostgreSQL / 12 / bin
export CLASSPATH = $ CLASSPATH: / Library / PostgreSQL / 12 / bin

gateway – Docker routes packets the right way – I don't like it

I am running a dns type service inside a docker container on a host with 2+ interface addresses (different ips but same device ~ eth0: x). One of them is of course the default gw (let's give it the address a.a.a.a), the other is surplus.

I am binding the container service to the excess IP address (let's call it b.b.b.b) with docker-compose:

   ports:
     - b.b.b.b:53:53udp

The service responds, but dockerd is sending the masked packets back as if they were coming from a.a.a.a.

Is there a way to change that behavior, so the container packages are masked as if they came from b.b.b.b?