Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to get json object decribing all the routes and their respective methods in one of the server hooks? #1160

Closed
shivanshtalwar0 opened this issue Dec 27, 2020 · 5 comments
Assignees

Comments

@shivanshtalwar0
Copy link

shivanshtalwar0 commented Dec 27, 2020

Just like info regarding routes and methods are spit out of server when it is started up.

┌────────────────┬──────────────────────────┬───────────────────────────────────┐
│ Method │ Endpoint │ Class method │
│────────────────│──────────────────────────│───────────────────────────────────│
│ GET │ /rest/auth/health │ Auth.healthCheck() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/auth/login │ Auth.logIn() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/auth/resetPassword │ Auth.resetPassword() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ GET │ /rest/auth/verify/:token │ Auth.verifyAccount() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/auth/register │ Auth.register() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/auth/google │ Auth.googleAuth() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ GET │ /rest/auth/reset/:token │ Auth.validateResetPasswordToken() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/auth/reset/:token │ Auth.applyResetPasswordToken() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ GET │ /rest/rbac/role │ Auth.getRoles() │
│────────────────│──────────────────────────│───────────────────────────────────│
│ POST │ /rest/rbac/role │ Auth.createRoles()

@shivanshtalwar0 shivanshtalwar0 changed the title [Is it possible to get json object decribing all the routes and their respective methods in one of the server hooks? ] Is it possible to get json object decribing all the routes and their respective methods in one of the server hooks? Is it possible to get json object decribing all the routes and their respective methods in one of the server hooks? Dec 27, 2020
@Romakita
Copy link
Collaborator

Romakita commented Dec 29, 2020

Hello @shivanshtalwar0,

import {Platform} from "@tsed/common";

@Configuration()
export class Server { 
  @Inject()
  platform: Platform;

  $onReady(){
    const routes = this.platform.getRoutes()
  } 
}

You can also build your own json by using platform API (if you want more details). See the swagger service example:

https://github.com/TypedProject/tsed/blob/production/packages/swagger/src/services/SwaggerService.ts#L43

or https://github.com/TypedProject/tsed/blob/production/packages/common/src/platform/services/Platform.ts#L99

See you
Romain

@shivanshtalwar0
Copy link
Author

Wow thank you so much! 😄

@shivanshtalwar0
Copy link
Author

shivanshtalwar0 commented Sep 16, 2023

@Romakita is it removed in v7?

@Romakita
Copy link
Collaborator

Yes it’s replaced by this.platform.getLayers().
It’s exactly the same object.

You can find here how a layer is mapped to display logs:

protected async logRoutes(layers: PlatformLayer[]) {

see you

@github-actions
Copy link

🎉 Are you happy?

If you appreciated the support, know that it is free and is carried out on personal time ;)

A support, even a little bit makes a difference for me and continues to bring you answers!

github opencollective

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants