nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.37k stars 7.59k forks source link

NestJS + angular universal + GraphQL setup #1108

Closed danil-z closed 6 years ago

danil-z commented 6 years ago

I'm submitting a...


[ ] Regression 
[ ] Bug report
[ ] Feature request
[ x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Could you guys prove a basic setup documentation for NestJS + Angular universal + GraphQL.

Problem is that controller route paths set before GraphQL ones

So far the only solution I might think off is to bootstrap several separate NestFactoryStatic instances and attach them to express instance in serial order in main.ts. But testing becomes very painful then...

Expected behavior

Setup GraphQL routes before angular universal * <- capture all

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Imagine routes:

/api/graphql_user_module /api/graphql_admin_module /api/graphql_login_module *.* angular universal

Environment


Nest version: 5.3.7


For Tooling issues:
- Node version: 10  
- Platform:  
Mac

Others:

kamilmysliwiec commented 6 years ago

@nestjs/ng-universal has a property (renderPath) which allows you override * (see here https://github.com/nestjs/ng-universal) into your path (e.g. wildcard with /graphql excluded).

danil-z commented 6 years ago

pathregexp doesn't allow look behind regEx . I can't find the right way to exclude /graphql

marcus-sa commented 6 years ago

@danil-z no javascript engine supports look behind you'd have to go for a C++ binding before that would be possible.

danil-z commented 6 years ago

And? I know that javascript doesn't support it. I'm saying I can't imagine how rootStaticPath might solve path initialization issue?!

danil-z commented 6 years ago

could you guys provide an example of wildcard with /graphql excluded ???

kamilmysliwiec commented 6 years ago

See here https://stackoverflow.com/questions/31151498/run-express-middleware-for-all-routes-except-that-are-starting-with-api

You can use a regular expression to exclude /graphql path . Simply pass it as a renderPath of AngularUniversalModule https://github.com/nestjs/ng-universal/

marcus-sa commented 5 years ago

https://github.com/ForetagInc/fullstack-boilerplate Here's a boilerplate :)

lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.