diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2cef168 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: Node.js CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [10.x, 12.x, 14.x] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - run: npm ci + - run: npm run build --if-present + - run: npm test diff --git a/README.md b/README.md index 1bc0764..43d3191 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,27 @@ -# 👷 `worker-template` Hello World +# 👷 `url-short-cfw` -A template for kick starting a Cloudflare worker project. +An Custom Build Link Shortener build with Cloudflare Workers -[`index.js`](https://github.com/cloudflare/worker-template/blob/master/index.js) is the content of the Workers script. +## Project Structure -#### Wrangler +``` +. +├── .github # Auto Deploy and NODE CI scripts (`GitHub Actions Scripts`) +│ └── workflows +│ ├── cfw.js.yml # CloudFlare Worker auto deploy script +│ └── test.yml # NodeJS CI scripts +├── dist # Build Directory +│ └── worker.js # Initial CFW Worker file +├── index.js # Initial CFW Worker file +├── package.json # NodeJS package configuration +├── urls.json # Custom Url Endpoints +└── wrangler.toml # CFW wrangler config +``` + +## Build your Own To generate using [wrangler](https://github.com/cloudflare/wrangler) ``` -wrangler generate projectname https://github.com/cloudflare/worker-template +wrangler generate https://github.com/BRAVO68WEB/url-short-cfw ``` - -Further documentation for Wrangler can be found [here](https://developers.cloudflare.com/workers/tooling/wrangler). diff --git a/index.js b/index.js index 126db7b..807d4b9 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const urls = require('./urls.json') -addEventListener('fetch', (event) => { +addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)) }) @@ -12,5 +12,9 @@ async function handleRequest(request) { status: 308, headers: { location: urls[path] }, }) - else return new Response('404 not found?', { status: 404 }) + else + return new Response( + '404 not found !! Check all possible at Here ', + { status: 404 }, + ) } diff --git a/package.json b/package.json index cae29bd..3f1c2e9 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "private": true, "name": "url-shorter", "version": "1.0.0", - "description": "A template for kick starting a Cloudflare Workers project", + "description": "An Custom URL Shortener build on Cloud Flare Worker Platform", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", + "test": "npm ci", "format": "prettier --write '**/*.{js,css,json,md}'" }, "author": "Jyotirmoy ", diff --git a/urls.json b/urls.json index 2989f33..41fd2d5 100644 --- a/urls.json +++ b/urls.json @@ -3,5 +3,6 @@ "df-cloud": "https://cloud.dfcommunity.win", "help": "https://github.com/bravo68web/url-short-cfw", "df-api": "https://api.dfcommunity.win", - "*": "https://github.com/" + "all-urls": "https://raw.githubusercontent.com/BRAVO68WEB/url-short-cfw/master/urls.json", + "buildby": "https://github.com/bravo68web/" }