admin管理员组

文章数量:1279242

I have a question regarding creating a front-end for a nest-js API:

  1. Will this front-end be an entirely different project with regards to folder structure?
  2. Will it just 'call' the services from my API?
  3. How are my controllers of the API used, if the front-end just uses the services directly?

Also, in what order does it make sense to create the front-end prior to auth? Or should it be the other way around.

Thanks

I have a question regarding creating a front-end for a nest-js API:

  1. Will this front-end be an entirely different project with regards to folder structure?
  2. Will it just 'call' the services from my API?
  3. How are my controllers of the API used, if the front-end just uses the services directly?

Also, in what order does it make sense to create the front-end prior to auth? Or should it be the other way around.

Thanks

Share Improve this question asked Dec 1, 2018 at 18:43 Alex5207Alex5207 4842 gold badges8 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7
  1. You can create separate project for frontend app, or you could return HTML directly from nest. This depends on what you want.

    https://docs.nestjs./techniques/mvc

  2. If you go for server side rendering (the MVC link above), then your code will have direct access to your nest services. If you go for SPA approach (angular, react, vue, ...), then you will have to call your nest API via http, so you will have access only via your API endpoints.

  3. I guess this one is answer already - for SSR approach, you will have endpoints that return the HTML. You could bine both approaches, having group of controllers working as REST API, and another group for SSR, that will return JSON response.

About the auth - I guess you should implement the backend first, then you can implement frontend so you can test it.

本文标签: javascriptCreating a front end for a nestjs APIStack Overflow