Skip to content

Commit

Permalink
Merge pull request #23 from ericclemmons/23-root-wildcard
Browse files Browse the repository at this point in the history
index.*.js doesn't work as expected on the root
  • Loading branch information
ericclemmons committed Feb 12, 2019
2 parents 1ba315e + aebe985 commit 5371475
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -42,9 +42,9 @@ module.exports = function createRouterFromFiles(routesPath, files) {
case "*":
handle(router, file, [
["GET", route],
["GET", `${route}/*`],
["GET", path.join(route, "*")],
["POST", route],
["POST", `${route}/*`]
["POST", path.join(route, "*")]
])
break

Expand Down
13 changes: 12 additions & 1 deletion packages/polydev/src/middleware/router/launcher.js
Expand Up @@ -9,7 +9,9 @@ require("hot-module-replacement")({
ignore: /node_modules/ // regexp to decide if module should be ignored; also can be a function accepting string and returning true/false
})

const { spawn } = require("child_process")
const express = require("express")
const path = require("path")

const bridge = require("./bridge")

Expand Down Expand Up @@ -79,12 +81,21 @@ async function startHandler() {
app.listen(PORT, async () => {
console.log(`↩︎ ${handlerPath.replace(process.cwd(), ".")} from ${url}`)
})
} else if (typeof handler === "string") {
// Expected to have path to `package.json`
const pkg = require(handler)
const cwd = path.dirname(handler)

spawn("yarn", [pkg.scripts.dev ? "dev" : "start"], {
cwd,
stdio: "inherit"
})
} else {
console.warn(
`${handlerPath.replace(
process.cwd(),
"."
)} does not return a Function, Server, or path to package.json`
)} does not return a Function, Server, or path to a package.json`
)
// In development, at least listen on PORT so that we can 404
express().listen(PORT)
Expand Down

0 comments on commit 5371475

Please sign in to comment.