https://github.com/jwebcoder/mith_router
Routing system for Mith framework
https://github.com/jwebcoder/mith_router
Last synced: 12 months ago
JSON representation
Routing system for Mith framework
- Host: GitHub
- URL: https://github.com/jwebcoder/mith_router
- Owner: JWebCoder
- License: mit
- Created: 2020-05-19T21:55:57.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-12T03:21:03.000Z (almost 6 years ago)
- Last Synced: 2025-02-05T08:08:32.342Z (over 1 year ago)
- Language: TypeScript
- Homepage: https://doc.deno.land/https/deno.land/x/mith_router/mod.ts
- Size: 43.9 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Mith_router

[](https://doc.deno.land/https/deno.land/x/mith_router/mod.ts)
Routing system to be used with the [Mith framework](https://github.com/JWebCoder/mith)
## Usage
**Basic integration with routing**
```typescript
import { Mith } from 'https://deno.land/x/mith@v0.7.0/mod.ts'
import { Router } from 'https://deno.land/x/mith_router@v0.2.0/mod.ts'
const { env } = Deno
const router = new Router()
const innerRouter = new Router()
innerRouter.use(
'GET',
'/',
(req, res, next) => {
res.body.text = 'inner route'
next()
}
)
router.use(
'GET',
'/inner',
innerRouter.getRoutes()
)
router.use(
'GET',
'/',
(req, res, next) => {
res.body.text = 'something'
next()
}
)
const app = new Mith()
app.use(router.getRoutes())
const PORT = Number(env.get('PORT')) || 3000
app.listen({ port: PORT})
console.log('listening on', PORT)
```
Right now I'm still working on the documentation, so you can check the **example** folder for full usage examples