how can I add a route to serve static files?
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- typescript
Research direction
Start with the route handler shown in the issue, the Hapi definitions at types/hapi/index.d.ts, and the referenced tests/server/decorate.ts example. Compare the Inert customized-file-response example with the available reply typings; done means the route can use the intended file response without the reported TypeScript error.
Written by the indexing model from the issue text.
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:
I tried adding a route like this:
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
- 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
.filefor 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 !
- Dominant language
- TypeScript
- Stars
- 353
- Forks
- 99
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dwyl/hapi-typescript-example
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
dwyl/hapi-typescript-example#4 · 4 comments ·
All issues in dwyl/hapi-typescript-example
Similar issues
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 75/100
lingdojo/kana-dojo#32018 · 1 comment · 5 reactions ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
paperclipai/paperclip#15751 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BuilderIO/agent-native#7275 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day