import { Router } from '8track'
const router = new Router()
const usersRouter = new Router()
usersRouter.get`/`.handle(async ctx => {
// List users
})
usersRouter.post`/`.handle(async ctx => {
// Create user
})
usersRouter.get`/${'userId'}`.handle(async ctx => {
// Get user by ID
})
usersRouter.put`/${'userId'}`.handle(async ctx => {
// Update user by ID
})
usersRouter.del`/${'userId'}`.handle(async ctx => {
// Delete user by ID
})
router.all`/organization/${'organizationId'}/users`.use(usersRouter)
.url property on Context
Middlewares frequently need to parse the URL and we end up with a ton of new URL(event.request.url) calls littered throughout the application. No more! Now you can use ctx.url to access a pre-parsed URL instance
Sub Router Mounting
.url
property on ContextMiddlewares frequently need to parse the
URL
and we end up with a ton ofnew URL(event.request.url)
calls littered throughout the application. No more! Now you can usectx.url
to access a pre-parsedURL
instance