Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/cloudworker-router…
Browse files Browse the repository at this point in the history
…-4.1.5
  • Loading branch information
milankomaj authored Oct 6, 2024
2 parents 8b3f30d + 5758823 commit 90cf0ad
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
open-pull-requests-limit: 10
versioning-strategy: increase
schedule:
interval: "weekly"
day: "friday"
time: "11:00"
versioning-strategy: increase

# Set update schedule for GitHub Actions
- package-ecosystem: "github-actions"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-extended
Expand All @@ -55,7 +55,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -69,4 +69,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Dependency Review
uses: actions/dependency-review-action@main
7 changes: 4 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'latest'
- run: npm install --save

- name: Publish
uses: cloudflare/wrangler-action@2.0.0
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ on:
pull_request_target:
branches: '**'
types: [opened]
push:
branches: [ master ]
paths:
- '**.js'


jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 'latest'
- run: npm install --save
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
---

> #### Build`s on Github.
> [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/milankomaj/dev-badge)
[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/milankomaj/dev-badge)

```mermaid
%%{init: {'theme': 'neutral', 'themeVariables': { 'fontSize': '18px'}}}%%
Expand Down Expand Up @@ -44,24 +44,24 @@ click G "https://github.com/codespaces"
---

> #### Build localy.
> - [ ] **Start** [^note]
> - :one: clone/download [repository](https://github.com/milankomaj/dev-badge)
> - :two: ``` npm run NpmInstall ``` [:link:](/package.json#L11)
> - or ``` npm install ```
> - :three: [**development:**](/package.json#L6)
> - complete your secrets/keys in [*.dev.vars*](/.dev.vars) file [^1]
> - ``` npm run dev ``` [:link:](/package.json#L7)
> - or ``` wrangler dev ```
> - [*localhost:8787*](//localhost:8787)
> - :four: [**production:**](/package.json#L8)
> - complete your secrets/keys in [*example.secrets.json*](/example.secrets.json) file [^1]
> - ``` npm run pro ``` [:link:](/package.json#L8)
> - or ``` wrangler dev --remote ```
> - [*localhost:8787*](//localhost:8787)
> - :five: [**publish:**](/package.json)
> - ``` npm run publish ``` [:link:](/package.json#L10)
> - or ``` wrangler deploy ```
> - [x] **Done**
- [ ] **Start** [^note]
- :one: clone/download [repository](https://github.com/milankomaj/dev-badge)
- :two: ``` npm run NpmInstall ``` [:link:](/package.json#L11)
- or ``` npm install ```
- :three: [**development:**](/package.json#L6)
- complete your secrets/keys in [*.dev.vars*](/.dev.vars) file [^1]
- ``` npm run dev ``` [:link:](/package.json#L7)
- or ``` wrangler dev ```
- [*localhost:8787*](//localhost:8787)
- :four: [**production:**](/package.json#L8)
- complete your secrets/keys in [*example.secrets.json*](/example.secrets.json) file [^1]
- ``` npm run pro ``` [:link:](/package.json#L8)
- or ``` wrangler dev --remote ```
- [*localhost:8787*](//localhost:8787)
- :five: [**publish:**](/package.json)
- ``` npm run publish ``` [:link:](/package.json#L10)
- or ``` wrangler deploy ```
- [x] **Done**

[^1]: some services/[*mods*](dev-badge/tree/master/mods) need secrets/keys :key:
[^note]:
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function routeHandler(ctx, handler) {
'CDN-Cache-Control': `max-age=${_hh ? _hh : config.defaultCacheDurationSecond}, stale-if-error=60`,
'Cache-Control': `max-age=${_hh ? _hh : config.defaultCacheDurationSecond},immutable, s-max-age=${_hh ? _hh : config.defaultCacheDurationSecond}, stale-if-error=60`,
'Access-Control-Allow-Methods': 'POST, GET, OPTIONS, HEAD',
'dev-badge': `v.2.0-${country}-${ip}-${colo}-${http}-${tls}-${region}-${asn}-${method}`,
'dev-badge': `v.2.0-${country}-${ip}-${colo}-${http}-${tls}-${asn}-${method}`,
'Access-Control-Allow-Origin': '*',
'X-Content-Type-Options': 'nosniff'
};
Expand Down Expand Up @@ -73,6 +73,7 @@ const handlerMap = {

'/amo/:topic/:pkgName': handlers.amo,

'/mozilla/:topic/:domain/:method': handlers.mozilla,
'/mozilla/:topic/:domain': handlers.mozilla,

'/jsdelivr/:topic/:period/:type/:name': handlers.jsdelivr,
Expand Down
4 changes: 2 additions & 2 deletions mods/calendar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// http://localhost:8787/calendar/today
// http://localhost:8787/calendar/12-oktober
async function handleCalendar({ topic }) {
const endpoint = 'https://raw.githubusercontent.com/milankomaj/data/main/namedays/names_days_min.json'
const endpoint = 'https://raw.githubusercontent.com/milankomaj/site-dev-badge/master/names_days/names_days_min.json'
const resp = await fetch(endpoint, {
method: "GET",
cf: {
Expand Down Expand Up @@ -47,4 +47,4 @@ async function handleCalendar({ topic }) {
}
} catch (e) { console.log("👉 e.message:", e.message); return { subject: "Response " + resp.status, status: resp.statusText, labelColor: "grey" } }
}
export default handleCalendar;
export default handleCalendar;
63 changes: 33 additions & 30 deletions mods/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,35 +149,38 @@ async function getLatestRelease({ owner, repo, channel }) {
}

async function handleGitHub({ topic, owner, repo }, options) {
switch (topic) {
case "releases":
case "tags":
case "stars":
case "PR":
case "open-PR":
case "closed-PR":
case "merged-PR":
case "issues":
case "open-issues":
case "closed-issues":
case "forks":
case "watchers":
const info = await queryRepoStats({ topic, owner, repo });
return {
subject: topic,
status: String(info[topicMap[topic]].totalCount),
color: "blue",
};
case "release":
const opts = await getLatestRelease({ owner, repo, channel: "stable" });
return opts;
default:
return {
subject: topic,
status: "unknown",
color: "grey",
};
}
try {
switch (topic) {
case "releases":
case "tags":
case "stars":
case "PR":
case "open-PR":
case "closed-PR":
case "merged-PR":
case "issues":
case "open-issues":
case "closed-issues":
case "forks":
case "watchers":
const info = await queryRepoStats({ topic, owner, repo });
return {
subject: topic,
status: String(info[topicMap[topic]].totalCount),
color: "blue",
};
case "release":
const opts = await getLatestRelease({ owner, repo, channel: "stable" });
return opts;
default:
return {
subject: topic,
status: "unknown",
color: "grey",
};
}
} catch (e) { console.log("👉 e.message:", e.message); return { subject: topic, status: e.message, labelColor: "grey" } }

}

export default handleGitHub;
export default handleGitHub;
8 changes: 4 additions & 4 deletions mods/jsdelivr.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ async function handelJsdelivr({
rank
} = await resp.json();


//console.log("👉:",resp.status,rank,total,":👈")


switch (topic) {

Expand All @@ -41,8 +41,8 @@ async function handelJsdelivr({
color: 'ff5627'
}
}
} else {return errBadge;}

} else { return { subject: "Response " + resp.status, status: resp.statusText, labelColor: "grey" } }

}

Expand Down
2 changes: 1 addition & 1 deletion mods/lastfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function handleLastfm({
const endpoint2 = `https://ws.audioscrobbler.com/2.0/?method=artist.gettoptags&artist=${encodeURIComponent(lastPartist)}&api_key=${LASTFM_KEY}&format=json`
const resp2 = await fetch(endpoint2, { method: "get", headers: { "Cache-Control": "no-store" } });
const { toptags } = await resp2.json();
const lastPgenre = (toptags.tag['0'].name);
const lastPgenre = (toptags.tag['0']) ? (toptags.tag['0'].name) : "";
// console.log("👉 log:",lastPgenre)
const lastPnow = (recenttracks.track['0']['@attr'])

Expand Down
Loading

0 comments on commit 90cf0ad

Please sign in to comment.