mm-ninja-turtles / turtle-express

My attempt of making Express.JS a typesafe router with Zod.
3 stars 0 forks source link

[feature]: add base path for router setup function #27

Closed wai-lin closed 2 years ago

wai-lin commented 2 years ago

Problem

router.setup() function currently doesn't have basePath to define for.

Solution

This could be solved by defining the base path in createRouter() function as options.

// as prefix
const router = createRouter(Router(), { basePath: '/api' })

// as versioning
const router_v1 = createRouter(Router(), { basePath: '/v1' })
const router_v2 = createRouter(Router(), { basePath: '/v2' })