~ajhalili2006/cfw-golinks

e6bf820f2e10b7911767dfbb2b3f9f7bf6c6597c — Andrei Jiroh Halili 1 year, 1 month ago ca9cafe main
chore(deps): update dependencies stuff and start from strach obviously

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.eu.org>
4 files changed, 204 insertions(+), 143 deletions(-)

A .gitignore
M package-lock.json
M package.json
D src/index.js
A .gitignore => .gitignore +132 -0
@@ 0,0 1,132 @@
# SPDX-License-Identifier: TODO
# Source: https://github.com/github/gitignore/blob/4488915eec0b3a45b5c63ead28f286819c0917de/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

M package-lock.json => package-lock.json +69 -45
@@ 1,14 1,18 @@
{
  "name": "golinks",
  "version": "0.0.0",
  "name": "@ajhalili2006/golinks",
  "version": "0.1.0",
  "lockfileVersion": 2,
  "requires": true,
  "packages": {
    "": {
      "name": "golinks",
      "version": "0.0.0",
      "name": "@ajhalili2006/golinks",
      "version": "0.1.0",
      "license": "MIT",
      "dependencies": {
        "cloudworker-router": "^4.1.4"
      },
      "devDependencies": {
        "wrangler": "2.9.1"
        "wrangler": "^2.9.1"
      }
    },
    "node_modules/@cloudflare/kv-asset-handler": {


@@ 656,18 660,18 @@
      }
    },
    "node_modules/@types/better-sqlite3": {
      "version": "7.6.3",
      "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.3.tgz",
      "integrity": "sha512-YS64N9SNDT/NAvou3QNdzAu3E2om/W/0dhORimtPGLef+zSK5l1vDzfsWb4xgXOgfhtOI5ZDTRxnvRPb22AIVQ==",
      "version": "7.6.4",
      "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.4.tgz",
      "integrity": "sha512-dzrRZCYPXIXfSR1/surNbJ/grU3scTaygS0OMzjlGf71i9sc2fGyHPXXiXmEvNIoE0cGwsanEFMVJxPXmco9Eg==",
      "dev": true,
      "dependencies": {
        "@types/node": "*"
      }
    },
    "node_modules/@types/node": {
      "version": "18.13.0",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz",
      "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==",
      "version": "20.1.4",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.4.tgz",
      "integrity": "sha512-At4pvmIOki8yuwLtd7BNHl3CiWNbtclUbNtScGx4OHfBd4/oWoJC8KRCIxXwkdndzhxOsPXihrsOoydxBjlE9Q==",
      "dev": true
    },
    "node_modules/@types/stack-trace": {


@@ 770,6 774,14 @@
        "fsevents": "~2.3.2"
      }
    },
    "node_modules/cloudworker-router": {
      "version": "4.1.4",
      "resolved": "https://registry.npmjs.org/cloudworker-router/-/cloudworker-router-4.1.4.tgz",
      "integrity": "sha512-4REHDN2l4xStGZ4MS2uGy7ANHObXS9rRA6ZfDtzt7U+/AWNrgR1ecqwxoUmqku6ODRso7iRHXP68Bjno8h8aFA==",
      "dependencies": {
        "path-to-regexp": "^6.2.1"
      }
    },
    "node_modules/cookie": {
      "version": "0.4.2",
      "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",


@@ 1138,10 1150,16 @@
      }
    },
    "node_modules/nanoid": {
      "version": "3.3.4",
      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
      "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
      "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
      "dev": true,
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/ai"
        }
      ],
      "bin": {
        "nanoid": "bin/nanoid.cjs"
      },


@@ 1239,8 1257,7 @@
    "node_modules/path-to-regexp": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
      "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==",
      "dev": true
      "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
    },
    "node_modules/picomatch": {
      "version": "2.3.1",


@@ 1318,9 1335,9 @@
      }
    },
    "node_modules/semver": {
      "version": "7.3.8",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
      "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
      "version": "7.5.1",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
      "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
      "dev": true,
      "dependencies": {
        "lru-cache": "^6.0.0"


@@ 1333,9 1350,9 @@
      }
    },
    "node_modules/set-cookie-parser": {
      "version": "2.5.1",
      "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.5.1.tgz",
      "integrity": "sha512-1jeBGaKNGdEq4FgIrORu/N570dwoPYio8lSoYLWmX7sQ//0JY08Xh9o5pBcgmHQ/MbsYp/aZnOe1s1lIsbLprQ==",
      "version": "2.6.0",
      "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz",
      "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==",
      "dev": true
    },
    "node_modules/shebang-command": {


@@ 1518,9 1535,9 @@
      }
    },
    "node_modules/ws": {
      "version": "8.12.0",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
      "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
      "version": "8.13.0",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
      "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
      "dev": true,
      "engines": {
        "node": ">=10.0.0"


@@ 1952,18 1969,18 @@
      }
    },
    "@types/better-sqlite3": {
      "version": "7.6.3",
      "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.3.tgz",
      "integrity": "sha512-YS64N9SNDT/NAvou3QNdzAu3E2om/W/0dhORimtPGLef+zSK5l1vDzfsWb4xgXOgfhtOI5ZDTRxnvRPb22AIVQ==",
      "version": "7.6.4",
      "resolved": "https://registry.npmjs.org/@types/better-sqlite3/-/better-sqlite3-7.6.4.tgz",
      "integrity": "sha512-dzrRZCYPXIXfSR1/surNbJ/grU3scTaygS0OMzjlGf71i9sc2fGyHPXXiXmEvNIoE0cGwsanEFMVJxPXmco9Eg==",
      "dev": true,
      "requires": {
        "@types/node": "*"
      }
    },
    "@types/node": {
      "version": "18.13.0",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz",
      "integrity": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==",
      "version": "20.1.4",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.4.tgz",
      "integrity": "sha512-At4pvmIOki8yuwLtd7BNHl3CiWNbtclUbNtScGx4OHfBd4/oWoJC8KRCIxXwkdndzhxOsPXihrsOoydxBjlE9Q==",
      "dev": true
    },
    "@types/stack-trace": {


@@ 2043,6 2060,14 @@
        "readdirp": "~3.6.0"
      }
    },
    "cloudworker-router": {
      "version": "4.1.4",
      "resolved": "https://registry.npmjs.org/cloudworker-router/-/cloudworker-router-4.1.4.tgz",
      "integrity": "sha512-4REHDN2l4xStGZ4MS2uGy7ANHObXS9rRA6ZfDtzt7U+/AWNrgR1ecqwxoUmqku6ODRso7iRHXP68Bjno8h8aFA==",
      "requires": {
        "path-to-regexp": "^6.2.1"
      }
    },
    "cookie": {
      "version": "0.4.2",
      "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",


@@ 2300,9 2325,9 @@
      "dev": true
    },
    "nanoid": {
      "version": "3.3.4",
      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
      "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
      "version": "3.3.6",
      "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz",
      "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==",
      "dev": true
    },
    "node-forge": {


@@ 2370,8 2395,7 @@
    "path-to-regexp": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.2.1.tgz",
      "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw==",
      "dev": true
      "integrity": "sha512-JLyh7xT1kizaEvcaXOQwOc2/Yhw6KZOvPf1S8401UyLk86CU79LN3vl7ztXGm/pZ+YjoyAJ4rxmHwbkBXJX+yw=="
    },
    "picomatch": {
      "version": "2.3.1",


@@ 2433,18 2457,18 @@
      "dev": true
    },
    "semver": {
      "version": "7.3.8",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz",
      "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==",
      "version": "7.5.1",
      "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.1.tgz",
      "integrity": "sha512-Wvss5ivl8TMRZXXESstBA4uR5iXgEN/VC5/sOcuXdVLzcdkz4HWetIoRfG5gb5X+ij/G9rw9YoGn3QoQ8OCSpw==",
      "dev": true,
      "requires": {
        "lru-cache": "^6.0.0"
      }
    },
    "set-cookie-parser": {
      "version": "2.5.1",
      "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.5.1.tgz",
      "integrity": "sha512-1jeBGaKNGdEq4FgIrORu/N570dwoPYio8lSoYLWmX7sQ//0JY08Xh9o5pBcgmHQ/MbsYp/aZnOe1s1lIsbLprQ==",
      "version": "2.6.0",
      "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz",
      "integrity": "sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==",
      "dev": true
    },
    "shebang-command": {


@@ 2580,9 2604,9 @@
      }
    },
    "ws": {
      "version": "8.12.0",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.12.0.tgz",
      "integrity": "sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==",
      "version": "8.13.0",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
      "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
      "dev": true,
      "requires": {}
    },

M package.json => package.json +3 -74
@@ 2,7 2,7 @@
  "name": "@ajhalili2006/golinks",
  "version": "0.1.0",
  "devDependencies": {
    "wrangler": "2.9.1"
    "wrangler": "^2.9.1"
  },
  "private": true,
  "scripts": {


@@ 10,80 10,9 @@
    "deploy": "wrangler publish"
  },
  "description": "~ajhalili2006's personal golinks in CF Workers",
  "main": "src/index.js",
  "main": "app.js",
  "dependencies": {
    "anymatch": "^3.1.3",
    "binary-extensions": "^2.2.0",
    "braces": "^3.0.2",
    "buffer-from": "^1.1.2",
    "builtins": "^5.0.1",
    "blake3-wasm": "^2.1.5",
    "busboy": "^1.6.0",
    "chokidar": "^3.5.3",
    "cookie": "^0.4.2",
    "cron-schedule": "^3.0.6",
    "cross-spawn": "^7.0.3",
    "esbuild": "^0.16.3",
    "dotenv": "^10.0.0",
    "escape-string-regexp": "^4.0.0",
    "estree-walker": "^0.6.1",
    "execa": "^6.1.0",
    "get-stream": "^6.0.1",
    "fill-range": "^7.0.1",
    "glob-parent": "^5.1.2",
    "html-rewriter-wasm": "^0.4.1",
    "http-cache-semantics": "^4.1.1",
    "is-binary-path": "^2.1.0",
    "human-signals": "^3.0.1",
    "is-number": "^7.0.0",
    "is-glob": "^4.0.3",
    "is-extglob": "^2.1.1",
    "is-stream": "^3.0.0",
    "isexe": "^2.0.0",
    "lru-cache": "^6.0.0",
    "kleur": "^4.1.5",
    "magic-string": "^0.25.9",
    "merge-stream": "^2.0.0",
    "mime": "^3.0.0",
    "mimic-fn": "^4.0.0",
    "mustache": "^4.2.0",
    "miniflare": "^2.11.0",
    "nanoid": "^3.3.4",
    "normalize-path": "^3.0.0",
    "node-forge": "^1.3.1",
    "npm-run-path": "^5.1.0",
    "onetime": "^6.0.0",
    "npx-import": "^1.1.4",
    "parse-package-name": "^1.0.0",
    "path-to-regexp": "^6.2.1",
    "readdirp": "^3.6.0",
    "path-key": "^3.1.1",
    "picomatch": "^2.3.1",
    "rollup-plugin-inject": "^3.0.2",
    "rollup-plugin-node-polyfills": "^0.2.1",
    "selfsigned": "^2.1.1",
    "rollup-pluginutils": "^2.8.2",
    "semiver": "^1.1.0",
    "semver": "^7.3.8",
    "shebang-regex": "^3.0.0",
    "shebang-command": "^2.0.0",
    "set-cookie-parser": "^2.5.1",
    "signal-exit": "^3.0.7",
    "source-map": "^0.7.4",
    "source-map-support": "^0.5.21",
    "sourcemap-codec": "^1.4.8",
    "streamsearch": "^1.1.0",
    "stack-trace": "^0.0.10",
    "strip-final-newline": "^3.0.0",
    "to-regex-range": "^5.0.1",
    "undici": "^5.9.1",
    "validate-npm-package-name": "^4.0.0",
    "urlpattern-polyfill": "^4.0.3",
    "which": "^2.0.2",
    "ws": "^8.12.0",
    "xxhash-wasm": "^1.0.2",
    "yallist": "^4.0.0",
    "youch": "^2.2.2"
    "cloudworker-router": "^4.1.4"
  },
  "repository": {
    "type": "git",

D src/index.js => src/index.js +0 -24
@@ 1,24 0,0 @@
export default {
 async fetch(request, env, ctx) {
    const linksDb = env.links
    const statusCode = 301;

    const url = new URL(request.url);
    const { pathname, search } = url;
    if (pathname.startsWith("/api/debug")) {
      const regex = /\/api\/debug/gm;
      const subst = ''
      const result = pathname.replace(regex, subst)
      const redirectUrl = await linksDb.get(result)
      return new Response(redirectUrl)
    } else {
      const redirectUrl = await linksDb.get(pathname)
    
      if (redirectUrl === null) {
        console.log(`golink doesn't exist for ${pathname}`)
        return Response.redirect(`https://go.recaptime.eu.org${pathname}`, statusCode)
      }
      return Response.redirect(redirectUrl, statusCode)
    }
  },
};