question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get all the base paths of `use` apps

See original GitHub issue
polka()
.use("counter", createStateApp(require("./fsm/counter.js")))
.use("search", createStateApp(require("./fsm/searchMachine.js")))

Is it possible to register a root path that has access to all the sub-apps?

like?

const app = polka()
.use("counter", createStateApp(require("./fsm/counter.js")))
.use("search", createStateApp(require("./fsm/searchMachine.js")))
.get("/", (req, res) => {
  Object.keys(app.apps).map(...)
})

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeedcommented, Nov 9, 2019

Ah, sorry, it’s here: https://discord.gg/xrRvfYV

Not recommend because you’re relying on Polka internals to do something. It’s not documented as public API because it’s not meant to be used. For example, this.apps is removed in upcoming 1.0

0reactions
pkecommented, Nov 9, 2019

I want to mount n-subapps to different root paths. Then I want have a main apps root path to respond with all the available subapps root paths. So I guess I can just keep that relation outside of polka in the first place:

const apps = {
  "counter": createCounterApp,
  "search": createSearchApp,
}
Object.keys(apps).forEach(key => polka.use(key, apps(key)())

polka.get("/", (req, res) => {
  links = Object.keys(apps).map(key => { 
    href: resolve(req.originalUrl, key) 
  })
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

App base path from a module in NodeJS - Stack Overflow
In one of my routes I'm doing some file manipulation and I need to know the base app path. if I use __dirname...
Read more >
API Host and Base Path - Swagger
REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by schemes , host and...
Read more >
Base Path - next.config.js
js application under a sub-path of a domain you can use the basePath config option. basePath allows you to set a path prefix...
Read more >
Routing - Express.js
Here are some examples of route paths based on strings. This route path will match requests to the root route, / . app.get(' ......
Read more >
Firebase Remote Config - Google
The Remote Config client library get methods provide a single access point for parameter values. Your app gets server-side values using the same...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found