dwyl / dwyl/hapi-typescript-example
how can I add a route to serve static files?
- Dominant language
- TypeScript
- Stars
- 354
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Description
Hello, thank you for the great example!
I'm trying to add a route to serve static files using inert,
but I'm not able to use the "h" method like in the [inert examples](https://github.com/hapijs/inert#customized-file-response):
I tried adding a route like this:
```javascript
server.route({
method: 'GET',
path: '/staticpath', //or public..
config: {
handler: function(request, h){
//here i can't get the h, just the reply
return h.file("public/index.html");
},
tags: ['api', 'virtual'],
description: 'Virtual Get user info'
}
}
});
```
I keep getting the error
**Property 'file' does not exist on type 'ReplyWithContinue'.**
[I found this on type definition](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/04dca3a08177dbcba2afc53323d38316698b360a/types/hapi/index.d.ts#L189)
* NOTE: it's not possible to type the result of this action.
* It's advised that in a custom definition file, you extend the ReplyNoContinue
* and ReplyWithContinue functions. See Inert `.file` for an example.
* Or if it is not part of a library / plugin then you use a namespace within
* your code to type the request, server and or reply. See
* [tests/server/decorate.ts]
But I don't know how to extend the ReplyWithContinue definitions
hope I explained my problem,
and sorry for my english !
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.