Alex Styl
03/23/2025, 2:29 AMexternal object Express {
fun get(path: String, handler: (req: dynamic, res: dynamic) -> Unit)
}
And I would like to do
express.get("/") {
// suspend here ?
}
similar to how in normal js i would just add async into the function like this:
app.get('/', async (req, res) => {
// I can use await here
})Alex Styl
03/23/2025, 2:29 AMsuspend function but express throws saying hander is not a functionjw
03/23/2025, 3:31 AM{ suspend code here } do { GlobalScope.async { suspend code here } }jw
03/23/2025, 3:31 AMasPromise() that. been a few years since i've done anything with promisesAlex Styl
03/23/2025, 5:09 AMjw
03/23/2025, 11:41 AMjw
03/23/2025, 11:42 AMturansky
03/23/2025, 12:00 PMasync handler supported by express - then signature is invalid and it must be Promise<Void>? instead of UnitAlex Styl
03/23/2025, 1:28 PMexport type RequestParamHandler = (req: Request, res: Response, next: NextFunction, value: any, name: string) => any;
in normal js i use async so that i get to use await inside the callback, but express doesnt really use the promiseturansky
03/23/2025, 2:21 PMturansky
03/23/2025, 2:21 PMAlex Styl
03/23/2025, 2:28 PMturansky
03/23/2025, 2:32 PMexpress yourself?Alex Styl
03/23/2025, 2:51 PM