-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add get-works package to validate the URLs
- Loading branch information
Showing
13 changed files
with
117 additions
and
152 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "get-works", | ||
"version": "1.0.0", | ||
"description": "Check if the GET request for the given URL works", | ||
"homepage": "https://github.com/aminya/setup-cpp", | ||
"license": "Apache-2.0", | ||
"author": "Amin Yahyaabadi", | ||
"main": "./dist/index.js", | ||
"source": "./src/index.ts", | ||
"scripts": { | ||
"build": "tsc" | ||
}, | ||
"dependencies": { | ||
"root-tools": "workspace:*" | ||
}, | ||
"keywords": [ | ||
"url", | ||
"link", | ||
"uri", | ||
"working", | ||
"check", | ||
"alive", | ||
"ok", | ||
"broken" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import * as https from "https" | ||
|
||
/** | ||
* Check if the GET request for the given URL works | ||
* | ||
* @param url The given URL | ||
* @returns A promise that resolves to a boolean indicating if the URL works | ||
*/ | ||
export function getWorks(url: string): Promise<boolean> { | ||
return new Promise<boolean>((resolve) => { | ||
https.get(url, (res) => { | ||
if (res.statusCode !== undefined && res.statusCode >= 200 && res.statusCode <= 399) { | ||
resolve(true) | ||
} else { | ||
resolve(false) | ||
} | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": ["./src"] | ||
} |
Oops, something went wrong.