Skip to content

feat: load TSX files in importClassesFormDirectories #629

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

Merged
merged 1 commit into from
Mar 24, 2021
Merged

feat: load TSX files in importClassesFormDirectories #629

merged 1 commit into from
Mar 24, 2021

Conversation

11joselu
Copy link
Contributor

@11joselu 11joselu commented Dec 16, 2020

Description

Right now you can not use TSX files to define routes.

We are using React with SSR (only some routes) but the .tsx are not loaded by importClassesFormDirectories because supporting files are: .ts & .js

Example:

import { Controller, Get, Render } from 'routing-controllers';
import { renderToString } from 'react-dom/server';
import React from 'react';

const Hello = () => <p>Hi!</p>

@Controller()
export class HomeController {
    constructor(private getBanners: GetBanners) {}

    @Get(`/`)
    @Render('home.njk')
    getHome(): void {
       // Render React Component
        const content = renderToString(<Hello />);
        
        return { metadata: { title: 'Home' }, content };
    }
}

That route will never appear (return 404)

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

@11joselu 11joselu changed the title Allow to use TSX files Load and read TSX files Dec 16, 2020
@NoNameProvided NoNameProvided changed the title Load and read TSX files feat: load TSX files in importClassesFormDirectories Mar 24, 2021
@NoNameProvided NoNameProvided merged commit af0cdf8 into typestack:develop Mar 24, 2021
@NoNameProvided
Copy link
Member

Thanks!

@github-actions
Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants