Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

how can I add a route to serve static files?

Open
#15 0 comments 0 reactions 0 assignees View on GitHub

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
Domain
api, backend

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 .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 !

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dwyl/hapi-typescript-example

All issues in dwyl/hapi-typescript-example

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.