Questions tagged [routing-controllers]

See documentation at https://github.com/typestack/routing-controllers

20 questions
7
votes
1 answer

how can Export the class and define middleware in typescript

I create the class user where i just only define the get method but when i call the class in middleware and use it, it not show any error but when i run the code it show server not found. when i del this line app.use(userRoute) my server…
3
votes
0 answers

Cannot set headers after they are sent to the client error when using the routing-controllers package

I want to use routing-controllers package in my app. But when I add a middleware I get an error. Here is my code: index.ts: import "reflect-metadata"; import { createExpressServer } from "routing-controllers"; import { UserController } from…
user15721538
3
votes
1 answer

How to use routing-controllers with swagger ui?

i don't understand, how to use swagger-ui with routing-controller. i have tried: @Controller('/api-docs') @UseBefore(swagger.serve) //ERROR No overload matches this call class SwaggerController { @Get('/') …
Alex4answer
  • 485
  • 1
  • 5
  • 15
2
votes
2 answers

NodeJs routing-controllers: How can I Had dynamic parameter in middleware call

I have followed the tutorial from: https://github.com/typestack/routing-controllers#creating-your-own-express-middleware But I do not find a way to inject dynamic parameters in @UseBefore/@UseAfter middleware call Like…
mduvernon
  • 498
  • 3
  • 13
2
votes
0 answers

Download a file from Node.js using Express.js and TypeScript

I work on a REST API using Node, Express and TypeScript. I want to write a controller for downloading a file from the server. The filename is saved in a database alongside its extension, path, etc. The id is given as request parameter. Somehow I…
1
vote
0 answers

User authorization check with Express, Prisma and Postgres

How can you check user authorization with Express, Routing-controllers, Prisma and Postgres stack? e.g. check if a request is the owner of the post to delete the post Do you always need to call db twice to check if user is the author? e.g. getPost…
Nicholas Kim
  • 81
  • 1
  • 6
1
vote
0 answers

Getting typescript TS1135: Argument expression expected. with routing-controllers @Req

I am using NodeJS Express routing-controllers with TypeScript, the following code doesn't compile when I added the @Req()/@Res() decorators, if I remove them it compiles fine. @Service() @JsonController() export default class FlightsController { …
1
vote
1 answer

Node.JS: How do you validate QueryParams in routing-controllers?

lets say you have an interface like this: import { Get, QueryParam } from 'routing-controllers'; // ... @Get('/students') async getStudents( @QueryParam('count') count?: number, ): Promise { console.log(count); } How do you ensure…
Phil
  • 7,065
  • 8
  • 49
  • 91
1
vote
0 answers

routing-controllers res.sendFile() notfound error

I was try to download files from server using client.I'm using https://www.npmjs.com/package/routing-controllers for routings but unable to download file. Code import "reflect-metadata"; import { Body, Controller, Get, JsonController, Param, Post,…
Perumal Samy S
  • 265
  • 1
  • 2
  • 8
1
vote
1 answer

Integrate Auth0 as middleware in Express.js routing-controllers authorizationChecker

I'm having difficulty in translating Auth0's Node (Express) API quickstart to a middleware variant. In particular using TypeStack's routing-controllers library and want to integrate Auth0 using their @Authorized decorator. In app.ts: const app =…
Juliën
  • 9,047
  • 7
  • 49
  • 80
0
votes
1 answer

should i hace separate controller for different http requests in REST API

So we are trying to build a website and we have different routes but they have somewhat same functioning So say: for recomended products localhost:3000/products/veg/rec localhost:3000/products/fruits/rec for viewing all products…
Aditya
  • 1
  • 2
0
votes
1 answer

Why I keep getting Bad Request sending valid JSON to an express app using routing controllers?

I have an express app that is setup using routing-controllers. There is only one controller, and it looks like this: @JsonController('/auth') export class AuthController { public authService = new AuthService(); @HttpCode(201) …
Edy Bourne
  • 5,679
  • 13
  • 53
  • 101
0
votes
0 answers

POST going directly to the catch error and not saving data using mongoose, MongoDB, NodeJS, and Express

I already tried some possible solutions and even created and wrote the code again but I am still getting errors. I have created a diminute version of my whole code which connects to the database using Mongoose but after the Schema is created and I…
0
votes
1 answer

Throw error with custom message using routing-controllers with desired format

I have a Node APP using routing-controllers and into Readme there is a section called Throw HTTP errors where the example is self-explanatory. But the problem is when I try to reproduce that lines. In my code I have this example (is for testing…
J.F.
  • 13,927
  • 9
  • 27
  • 65
0
votes
0 answers

Can't add data to a specific route

I'm new in server side and maybe understand the concept of adding data to db wrong. I want to add a user that comes from axios.post to specific groupId parameter but when I do get requests on the postman I see that it adds the user to all the groups…
1
2