Skip to content

Commit

Permalink
feat: add siteFilterMiddleware
Browse files Browse the repository at this point in the history
  • Loading branch information
ngshiheng committed Sep 22, 2022
1 parent 0ec84a1 commit 5212e18
Show file tree
Hide file tree
Showing 4 changed files with 807 additions and 8 deletions.
9 changes: 5 additions & 4 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true
"printWidth": 160,
"semi": false,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "es5"
}
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Router } from 'itty-router'
import { createShortUrl } from './handlers/createShortUrl'
import { redirectShortUrl } from './handlers/redirectShortUrl'
import { shortUrlCacheMiddleware } from './middleware/shortUrlCache'
import { siteFilterMiddleware } from './middleware/siteFilter'
import { LANDING_PAGE_HTML } from './utils/constants'

const router = Router()
Expand All @@ -19,7 +20,7 @@ router.get('/', () => {
router.get('/:text', redirectShortUrl)

// POST creates a short URL that is associated with its an original URL.
router.post('/api/url', shortUrlCacheMiddleware, createShortUrl)
router.post('/api/url', shortUrlCacheMiddleware, siteFilterMiddleware, createShortUrl)

// 404 for everything else.
router.all('*', () => new Response('Not Found', { status: 404 }))
Expand Down
Loading

0 comments on commit 5212e18

Please sign in to comment.