https://github.com/drivly/itty-router-template
Template Cloudflare Worker using Itty Router with support for HTTP Imports
https://github.com/drivly/itty-router-template
Last synced: 5 months ago
JSON representation
Template Cloudflare Worker using Itty Router with support for HTTP Imports
- Host: GitHub
- URL: https://github.com/drivly/itty-router-template
- Owner: drivly
- License: mit
- Created: 2022-09-30T14:43:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-29T20:35:11.000Z (over 2 years ago)
- Last Synced: 2024-12-24T02:49:46.058Z (5 months ago)
- Language: JavaScript
- Homepage: https://github.com/drivly/itty-router-template/generate
- Size: 43 KB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Template Worker using Itty Router
## HTTP Imports
No need to use `npm` or have a `package.json` - just import from any URL:
```javascript
import { Router } from 'https://pkg.do/itty-router'
import { withParams, json } from 'https://pkg.do/itty-router-extras'const router = Router()
router.get('/', ({url}) => json({ url, 'Deploy in Seconds 🚀': 'https://github.com/drivly/itty-router-template/generate' }))
router.get('/:resource?/:id?', withParams, ({url, resource, id}) => json({ url, resource, id}))export default {
fetch: router.handle
}
```## Instant Deployment
Uses [drivly/deploy-worker](https://github.com/marketplace/actions/deploy-worker) GitHub Action for 5-10 second deployment times!
```yaml
name: Deploy
on: push
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- uses: drivly/deploy-worker@beta-1
```## Commit-specific URLs
And every commit gets auto-deployed instantly with it's own URL:
[
](https://c329df8.workers.do/)
## Friendly Subdomains
If you specify a name in the Actions config, you can get a custom subdomain:
```yaml
name: Deploy
on: push
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- uses: drivly/deploy-worker@beta-1
with:
name: 'itty'
```## Custom Domains
To use a custom domain, just create a CNAME record to `workers.do` and add a domain variable to the config:
```yaml
name: Deploy
on: push
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
steps:
- uses: actions/checkout@v3
- uses: drivly/deploy-worker@beta-1
with:
name: 'itty'
domain: 'itty.one'
```### Coming Soon - Wildcard Custom Domain support for Commit Hash Deploys:
This will requiring adding TXT files to your DNS for verifation, unlike specific non-wildcard domains that can be validated automatically via HTTP.
## 🏎 [Drivly Open- Accelerating Innovation through Open Source](https://driv.ly)
Our [Drivly Open](https://driv.ly) Philosophy has these key principles:
1. Build in Public, and with the Community
2. Create Amazing Developer Experiences
3. Everything Must Have an API
4. Communicate through APIs not Meetings
5. APIs Should Do One Thing, and Do It Well## 🚀 We're Hiring!
[Driv.ly](https://driv.ly) is deconstructing the monolithic physical dealership into simple APIs to buy and sell cars online, and we're funded by some of the [biggest names](https://twitter.com/TurnerNovak) in [automotive](https://fontinalis.com/team/#bill-ford) and [finance & insurance](https://www.detroit.vc)
Our entire infrastructure is built with [Cloudflare Workers](https://workers.do), [Durable Objects](https://durable.objects.do), [KV](https://kv.cf), [PubSub](https://pubsub.do), [R2](https://r2.do.cf), [Pages](https://pages.do), etc. [If you love the Cloudflare Workers ecosystem as much as we do](https://driv.ly/loves/workers), we'd love to have you [join our team](https://careers.do/apply)!