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

fix: routes from imported controllers via directory return 404 in 0.10.0 #980

Closed
dbrewer5 opened this issue Jan 4, 2023 · 11 comments
Closed
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.

Comments

@dbrewer5
Copy link

dbrewer5 commented Jan 4, 2023

Description

It seems that using the directory-based import as described in the documentation does not work after upgrading to v0.10.0. Falling back to directly registering each controller works as intended. This applies when setting both, controllers and middleware.

Minimal code-snippet showcasing the problem

import { createKoaServer } from 'routing-controllers'
import { join } from 'path'

const app = createKoaServer({
    controllers: [join(__dirname, '/controllers/*.*s')],
    middleware: [join(__dirname, '/middleware/*.*s')]
})

app.listen(3000) // all routes will return 404 and middleware will be ignored

Expected behavior

Should keep working as it did in v0.9.0.

Actual behavior

All routes associated with registered controllers return 404 and middleware is ignored.

@dbrewer5 dbrewer5 added status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature. labels Jan 4, 2023
@attilaorosz
Copy link
Member

Does not found mean it returns 404 or the modules themselves are not found when starting the app?

@dbrewer5
Copy link
Author

dbrewer5 commented Jan 4, 2023

Does not found mean it returns 404 or the modules themselves are not found when starting the app?

All routes return 404. I've updated the issue to reflect that correctly.

@dbrewer5 dbrewer5 changed the title fix: can't import controllers via directory in 0.10.0 fix: routes from imported controllers via directory return 404 in 0.10.0 Jan 4, 2023
@attilaorosz
Copy link
Member

Could you please provide a bit more info? I cannot reproduce this locally.

@attilaorosz
Copy link
Member

I'm tring with this snippet:

import {createKoaServer} from "routing-controllers";
import {join} from 'path';

const axios = require('axios');

const application = createKoaServer( {
    controllers: [join(__dirname, '/controllers/*.*s')],
    middlewares: []
});

application.listen(4200);

axios.get('http://localhost:4200/api/first').then((resp: any) => {
    console.log(resp);
});

@jcrka
Copy link

jcrka commented Jan 10, 2023

Are you on windows ?
May be this is the same ? #987

@Apperk274
Copy link

Still does not work on Windows after fix #994

@attilaorosz
Copy link
Member

Have you tried locally? This is not released yet I guess.

@Apperk274
Copy link

Oh sorry, I thought it was in 0.10.1 release. My bad

@attilaorosz
Copy link
Member

Should be released. Please close this issue if it works for you or add a comment if not.

@attilaorosz
Copy link
Member

Closing as complete, please reopen if you find an issue.

@github-actions
Copy link

This issue 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 May 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: needs triage Issues which needs to be reproduced to be verified report. type: fix Issues describing a broken feature.
Development

No branches or pull requests

4 participants