Push Examples (#3735)

This commit is contained in:
Louis Lam
2023-09-13 20:03:12 +08:00
committed by GitHub
parent 9c24cd3973
commit 9ef1e69ae0
13 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
Node.js (ts-node)
```bash
ts-node index.ts
```
Deno
```bash
deno run --allow-net index.ts
```
Bun.js
```bash
bun index.ts
```

View File

@@ -0,0 +1,10 @@
const pushURL : string = "https://example.com/api/push/key?status=up&msg=OK&ping=";
const interval : number = 60;
const push = async () => {
await fetch(pushURL);
console.log("Pushed!");
};
push();
setInterval(push, interval * 1000);

View File

@@ -0,0 +1,13 @@
{
"scripts": {
"ts-node": "ts-node index.ts",
"deno": "deno run --allow-net index.ts",
"bun": "bun index.ts"
},
"devDependencies": {
"@types/node": "^20.6.0",
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
}
}