mirror of
https://github.com/tiennm99/is-amazing.git
synced 2026-10-11 00:52:26 +00:00
new
This commit is contained in:
1 parent
52414fe73d
commit
5f79584917
30 files changed
+605
-22
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
{"id":"7794ff83-856d-4aba-a760-46d0507b13d9","space":34102,"runtime":"nodejs14.x","name":"api","path":"4z2do1","project":"c08joyf8","account":"144798365827","region":"ap-southeast-1","deps":["axios@^1.1.3","express@^4.18.2","fs@^0.0.1-security","json-format@^1.0.1"],"envs":null,"public":true,"log_level":"debug","cron":""}
|
||||
{"id":"7794ff83-856d-4aba-a760-46d0507b13d9","space":34102,"runtime":"nodejs14.x","name":"api","path":"4z2do1","project":"c08joyf8","account":"144798365827","region":"ap-southeast-1","deps":["axios@^1.1.3","express@^4.18.2","fs@^0.0.1-security","json-format@^1.0.1","dotenv@^16.0.3"],"envs":["API_KEY"],"public":true,"log_level":"debug","cron":""}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"JSON_TEMPLATE.md":"abf7511641ebfa924fc03ae5ed861391e69e1cd30837f243833ae5079b169c7a","README.md":"2ac1d7b8c10f9459b1a65047490f4da51be97ff9f4619a0020566dac803e5098","domains.json":"6f3c0658c960f8f5d44a09120bba0d98bf848b2cb6ed3aef16c91ec304ab67d1","domains/joabutt.json":"7fa8908818fad8164130316f3998d083df81dad9a107defaf575baf8360f61e8","domains/john.json":"184be3d793ffd74df26b609e2f2781270aab3378f0b04c8a12a6cd02c5a83c14","domains/nico.json":"bfd57c11374c76423c7c7cf59c34503df062053c52cb01c38e177c8ab92a34dd","domains/slime.json":"3afe10a962cf73bd77cfb6f1b104479aa27d8dec78cf512804b75c71ec1b0d8a","index.js":"bd660095b8e0f90f06dacfa982daa77b7e2600270b14902975fc5ce860bfdf7c","package-lock.json":"cfb3ae51e9593b144506fb5ce782085bf9d72f2cc3a2fffcb920ab247bd2ac6e","package.json":"03a5b9cb9a33f7f9222e9bb973d864f208ceb51f29eb2c078c6538bd9d478235"}
|
||||
{"JSON_TEMPLATE.md":"abf7511641ebfa924fc03ae5ed861391e69e1cd30837f243833ae5079b169c7a","README.md":"2ac1d7b8c10f9459b1a65047490f4da51be97ff9f4619a0020566dac803e5098","domains.json":"332c71352b6b625f6d64889d9d2dc85099dbff48f38f0afd404be38254903c96","domains/joabutt.json":"7fa8908818fad8164130316f3998d083df81dad9a107defaf575baf8360f61e8","domains/john.json":"184be3d793ffd74df26b609e2f2781270aab3378f0b04c8a12a6cd02c5a83c14","domains/nico.json":"bfd57c11374c76423c7c7cf59c34503df062053c52cb01c38e177c8ab92a34dd","domains/slime.json":"3afe10a962cf73bd77cfb6f1b104479aa27d8dec78cf512804b75c71ec1b0d8a","index.js":"c92d8e4abd1d54191fb6cf5d338083165febdc0f27dca5cfd58e40f7f71f03df","package-lock.json":"06bef6d7bb7bd9e1bcbb2b61340a9f5ad35490e712a98a4ace76033c4a2c80d3","package.json":"4f7b892a40391aa1d6825f8eab43ca6d7dba1144b0e88d88ed237856730fc901"}
|
||||
@@ -1,17 +0,0 @@
|
||||
name: Deploy to Deta
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
if_merged:
|
||||
if: github.event.pull_request.merged == true
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2 #Be sure you check-out the repo first. Deta CLI needs access to the files
|
||||
- uses: BogDAAAMN/deta-deploy-action@v1.0.1
|
||||
with:
|
||||
deta-access-token: ${{ secrets.DETA_TOKEN }} #Deta access token https://docs.deta.sh/docs/cli/auth
|
||||
deta-name: 'api' #Deta Micro name https://docs.deta.sh/docs/cli/commands/#deta-clone
|
||||
deta-project-dir: './api' #Optional: directory to be deployed on Deta. Default is the root "."
|
||||
@@ -1,4 +1,3 @@
|
||||
node_modules
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
.env
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"subdomain": "john",
|
||||
"url": "joabuttisadev.pages.dev",
|
||||
"email": "john@gmail.com"
|
||||
"email": "leejoab75@gmail.com"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "semant",
|
||||
"url": "semant.is-a.dev",
|
||||
"email": "contact@semant.is-a.dev"
|
||||
}
|
||||
@@ -67,7 +67,7 @@ app.get("/addnew", async (req, res) => {
|
||||
|
||||
const finalname = filename.replaceAll(".json","");
|
||||
|
||||
const response = await axios.get(`http://localhost:3000/check/${finalname}`).then((response) => {
|
||||
const response = await axios.get(`https://api.is-really.cool/check/${finalname}`).then((response) => {
|
||||
|
||||
if (response.data == "unavailable"){
|
||||
console.log(`${finalname}.is-really.cool is already present.`)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
## Template for json file under domains folder
|
||||
|
||||
Please follow the template given here or your pull request will not be accepted or merged.
|
||||
|
||||
### IMPORTANT: Please name your JSON file the subdomain you wish to have. If your subdomain in the JSON file does not match the file name, your PR will NOT be merged. Also please do **NOT** have a comma after your email, as it will cause internal server errors. Please do not add any line breaks in your json.
|
||||
|
||||
## Template:
|
||||
```
|
||||
{
|
||||
"subdomain": "YOUR_SUBDOMAIN_HERE",
|
||||
"record": "YOUR_SITE_URL_HERE",
|
||||
"email": "YOUR_EMAIL_HERE"
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
<p align="center"><img src="https://i.ibb.co/DL4gxNX/logo-small.png" /></p>
|
||||
|
||||
<h1 align="center">is-really.cool</h1>
|
||||
|
||||
<p align="center"><strong>is-really.cool</strong> is A place for software devs to host their really cool projects and personal websites for <strong>Free</strong></p>
|
||||
|
||||
## About
|
||||
|
||||
We are a group of people who want to help developers have a platform to showcase their projects and websites, while being absolutely 100% free at the same time. Our goal is to allow developers have a place to showcase their talents and skills while also giving others a way to access and view their work. We offer a free subdomain on is-really.cool, like `foo.is-really.cool` or `bar.is-really.cool` for your sites with the [CNAME record](https://en.wikipedia.org/wiki/CNAME_record).
|
||||
|
||||
|
||||
## Registration
|
||||
|
||||
1. Create a static site with some hosting providers, some being: [Github pages](https://pages.github.com), [Surge](https://surge.sh), etc.
|
||||
2. After setting up your site, [Fork](https://github.com/is-really-cool/register/fork) this repo and under the domains folder, then read the file template [Here](https://github.com/is-really-cool/register/blob/main/JSON_TEMPLATE.md). If yourfile does not follow the required template, your pull request will **NOT** be merged. After reading the template, you can add your json file under the domains folder, and then create a pull request.
|
||||
3. Send your pull request, and your request will be reviewed and if the requirements are met, will be merged. Do keep an eye on it!~
|
||||
4. After your request has been merged, please give us up to 24 hours for the servers to propagate the changes.
|
||||
5. Enjoy your new `is-really.cool` domain!! 🥳
|
||||
|
||||
## Similar Services
|
||||
- [is-a-good.dev](https://github.com/is-a-good-dev/Register)
|
||||
- [is-not-a.dev](https://is-not-a.dev)
|
||||
- [cluster.ws & wip.la](https://github.com/Olivr/free-domain)
|
||||
- [js.org](https://github.com/js-org/js.org/tree/master) (*JavaScript projects only*)
|
||||
- [is-a.dev](https://github.com/is-a-dev/register)
|
||||
|
||||
## Donate
|
||||
|
||||
This service cannot be going on forever without your help, Thank you all!
|
||||
[](https://ko-fi.com/E1E8GE56L)
|
||||
|
||||
## Contact
|
||||
|
||||
You can contact us at help@is-really.cool
|
||||
|
||||
|
||||
## Thanks
|
||||
Thanks to is-a.dev and thedev.id for the huge help and inspiration in this project. More updates will be pushed out soon!
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
"joabutt",
|
||||
"john",
|
||||
"nico",
|
||||
"slime"
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "joabutt",
|
||||
"url": "joabuttisadev.pages.dev",
|
||||
"email": "me@joabutt.dev"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "john",
|
||||
"url": "joabuttisadev.pages.dev",
|
||||
"email": "leejoab75@gmail.com"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "nico",
|
||||
"url": "nico.is-a.dev",
|
||||
"email": "nicodreyer7@icloud.com"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "semant",
|
||||
"url": "semant.is-a.dev",
|
||||
"email": "contact@semant.is-a.dev"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "slime",
|
||||
"url": "slimeu.glitch.me",
|
||||
"email": "purpleblueslime@gmail.com"
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const PORT = 3000
|
||||
const axios = require("axios")
|
||||
const fs = require("fs")
|
||||
const jsonFormat = require("json-format");
|
||||
app.listen(PORT, () => console.log(`Coffee ready at ${PORT}, Caffeine ftw`))
|
||||
require('dotenv').config();
|
||||
|
||||
|
||||
|
||||
|
||||
app.get("/check/:subdomain", async (req, res) => {
|
||||
|
||||
|
||||
const response = await axios.get(`https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records?type=CNAME&name=${req.params.subdomain}.is-really.cool`, {
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': process.env.API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (response.data.result.length === 0) {
|
||||
res.send("available")
|
||||
|
||||
} else {
|
||||
res.send("unavailable")
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
app.get("/addnew", async (req, res) => {
|
||||
|
||||
|
||||
|
||||
fs.promises.readdir("./domains").then(filenames => {
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
})
|
||||
|
||||
|
||||
fs.promises.readdir("./domains")
|
||||
.then(async filenames => {
|
||||
|
||||
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
|
||||
fs.writeFile('./domains.json',jsonFormat(finalreal),function(err){
|
||||
if(err) console.log("error:" + err);
|
||||
|
||||
})
|
||||
|
||||
for (let filename of filenames) {
|
||||
|
||||
const finalname = filename.replaceAll(".json","");
|
||||
|
||||
const response = await axios.get(`http://localhost:3000/check/${finalname}`).then((response) => {
|
||||
|
||||
if (response.data == "unavailable"){
|
||||
console.log(`${finalname}.is-really.cool is already present.`)
|
||||
} else if (response.data == "available"){
|
||||
const prefinal = JSON.stringify(filename)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const realfinal = final.replaceAll('"', '')
|
||||
|
||||
const filedata = fs.promises.readFile(`./domains/${filename}`)
|
||||
.then(async function(result) {
|
||||
const newres = JSON.parse(result)
|
||||
|
||||
const realresult = newres.url
|
||||
const response = await axios.post(
|
||||
'https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records',
|
||||
{
|
||||
'type': 'CNAME',
|
||||
'name': realfinal,
|
||||
'content': realresult,
|
||||
'ttl': 1,
|
||||
'priority': 10,
|
||||
'proxied': true
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': process.env.API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if(response.data.success == true){
|
||||
console.log(`${finalname}.is-really.cool has been successfully added!`)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
res.sendStatus(200);
|
||||
})
|
||||
|
||||
|
||||
|
||||
// export 'app'
|
||||
module.exports = app
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.1.3",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"json-format": "^1.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
## Template for json file under domains folder
|
||||
|
||||
Please follow the template given here or your pull request will not be accepted or merged.
|
||||
|
||||
### IMPORTANT: Please name your JSON file the subdomain you wish to have. If your subdomain in the JSON file does not match the file name, your PR will NOT be merged. Also please do **NOT** have a comma after your email, as it will cause internal server errors. Please do not add any line breaks in your json.
|
||||
|
||||
## Template:
|
||||
```
|
||||
{
|
||||
"subdomain": "YOUR_SUBDOMAIN_HERE",
|
||||
"record": "YOUR_SITE_URL_HERE",
|
||||
"email": "YOUR_EMAIL_HERE"
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
<p align="center"><img src="https://i.ibb.co/DL4gxNX/logo-small.png" /></p>
|
||||
|
||||
<h1 align="center">is-really.cool</h1>
|
||||
|
||||
<p align="center"><strong>is-really.cool</strong> is A place for software devs to host their really cool projects and personal websites for <strong>Free</strong></p>
|
||||
|
||||
## About
|
||||
|
||||
We are a group of people who want to help developers have a platform to showcase their projects and websites, while being absolutely 100% free at the same time. Our goal is to allow developers have a place to showcase their talents and skills while also giving others a way to access and view their work. We offer a free subdomain on is-really.cool, like `foo.is-really.cool` or `bar.is-really.cool` for your sites with the [CNAME record](https://en.wikipedia.org/wiki/CNAME_record).
|
||||
|
||||
|
||||
## Registration
|
||||
|
||||
1. Create a static site with some hosting providers, some being: [Github pages](https://pages.github.com), [Surge](https://surge.sh), etc.
|
||||
2. After setting up your site, [Fork](https://github.com/is-really-cool/register/fork) this repo and under the domains folder, then read the file template [Here](https://github.com/is-really-cool/register/blob/main/JSON_TEMPLATE.md). If yourfile does not follow the required template, your pull request will **NOT** be merged. After reading the template, you can add your json file under the domains folder, and then create a pull request.
|
||||
3. Send your pull request, and your request will be reviewed and if the requirements are met, will be merged. Do keep an eye on it!~
|
||||
4. After your request has been merged, please give us up to 24 hours for the servers to propagate the changes.
|
||||
5. Enjoy your new `is-really.cool` domain!! 🥳
|
||||
|
||||
## Similar Services
|
||||
- [is-a-good.dev](https://github.com/is-a-good-dev/Register)
|
||||
- [is-not-a.dev](https://is-not-a.dev)
|
||||
- [cluster.ws & wip.la](https://github.com/Olivr/free-domain)
|
||||
- [js.org](https://github.com/js-org/js.org/tree/master) (*JavaScript projects only*)
|
||||
- [is-a.dev](https://github.com/is-a-dev/register)
|
||||
|
||||
## Donate
|
||||
|
||||
This service cannot be going on forever without your help, Thank you all!
|
||||
[](https://ko-fi.com/E1E8GE56L)
|
||||
|
||||
## Contact
|
||||
|
||||
You can contact us at help@is-really.cool
|
||||
|
||||
|
||||
## Thanks
|
||||
Thanks to is-a.dev and thedev.id for the huge help and inspiration in this project. More updates will be pushed out soon!
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
[
|
||||
"joabutt",
|
||||
"john",
|
||||
"nico",
|
||||
"slime"
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "joabutt",
|
||||
"url": "joabuttisadev.pages.dev",
|
||||
"email": "me@joabutt.dev"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "john",
|
||||
"url": "joabuttisadev.pages.dev",
|
||||
"email": "john@gmail.com"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "nico",
|
||||
"url": "nico.is-a.dev",
|
||||
"email": "nicodreyer7@icloud.com"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"subdomain": "slime",
|
||||
"url": "slimeu.glitch.me",
|
||||
"email": "purpleblueslime@gmail.com"
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const PORT = 3000
|
||||
const axios = require("axios")
|
||||
const fs = require("fs")
|
||||
const jsonFormat = require("json-format");
|
||||
app.listen(PORT, () => console.log(`Coffee ready at ${PORT}, Caffeine ftw`))
|
||||
require('dotenv').config();
|
||||
|
||||
|
||||
|
||||
|
||||
app.get("/check/:subdomain", async (req, res) => {
|
||||
|
||||
|
||||
const response = await axios.get(`https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records?type=CNAME&name=${req.params.subdomain}.is-really.cool`, {
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': process.env.API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (response.data.result.length === 0) {
|
||||
res.send("available")
|
||||
|
||||
} else {
|
||||
res.send("unavailable")
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
app.get("/addnew", async (req, res) => {
|
||||
|
||||
|
||||
|
||||
fs.promises.readdir("./domains").then(filenames => {
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
})
|
||||
|
||||
|
||||
fs.promises.readdir("./domains")
|
||||
.then(async filenames => {
|
||||
|
||||
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
|
||||
fs.writeFile('./domains.json',jsonFormat(finalreal),function(err){
|
||||
if(err) console.log("error:" + err);
|
||||
|
||||
})
|
||||
|
||||
for (let filename of filenames) {
|
||||
|
||||
const finalname = filename.replaceAll(".json","");
|
||||
|
||||
const response = await axios.get(`http://localhost:3000/check/${finalname}`).then((response) => {
|
||||
|
||||
if (response.data == "unavailable"){
|
||||
console.log(`${finalname}.is-really.cool is already present.`)
|
||||
} else if (response.data == "available"){
|
||||
const prefinal = JSON.stringify(filename)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const realfinal = final.replaceAll('"', '')
|
||||
|
||||
const filedata = fs.promises.readFile(`./domains/${filename}`)
|
||||
.then(async function(result) {
|
||||
const newres = JSON.parse(result)
|
||||
|
||||
const realresult = newres.url
|
||||
const response = await axios.post(
|
||||
'https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records',
|
||||
{
|
||||
'type': 'CNAME',
|
||||
'name': realfinal,
|
||||
'content': realresult,
|
||||
'ttl': 1,
|
||||
'priority': 10,
|
||||
'proxied': true
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': process.env.API_KEY,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if(response.data.success == true){
|
||||
console.log(`${finalname}.is-really.cool has been successfully added!`)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
res.sendStatus(200);
|
||||
})
|
||||
|
||||
|
||||
|
||||
// export 'app'
|
||||
module.exports = app
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.1.3",
|
||||
"dotenv": "^16.0.3",
|
||||
"express": "^4.18.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"json-format": "^1.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
[
|
||||
"joabutt",
|
||||
"nico",
|
||||
"slime"
|
||||
]
|
||||
@@ -0,0 +1,123 @@
|
||||
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const PORT = 3000
|
||||
const axios = require("axios")
|
||||
const fs = require("fs")
|
||||
const jsonFormat = require("json-format");
|
||||
app.listen(PORT, () => console.log(`Coffee ready at ${PORT}, Caffeine ftw`))
|
||||
|
||||
|
||||
|
||||
|
||||
app.get("/check/:subdomain", async (req, res) => {
|
||||
|
||||
|
||||
const response = await axios.get(`https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records?type=CNAME&name=${req.params.subdomain}.is-really.cool`, {
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': '60e5bb86dec42085c58ae1a85ede97a44f00c',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
if (response.data.result.length === 0) {
|
||||
res.send("available")
|
||||
|
||||
} else {
|
||||
res.send("unavailable")
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
app.get("/addnew", async (req, res) => {
|
||||
|
||||
|
||||
|
||||
fs.promises.readdir("../domains").then(filenames => {
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
})
|
||||
|
||||
|
||||
fs.promises.readdir("../domains")
|
||||
.then(async filenames => {
|
||||
|
||||
|
||||
|
||||
const prefinal = JSON.stringify(filenames)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const finalreal = JSON.parse(final)
|
||||
|
||||
|
||||
fs.writeFile('./domains.json',jsonFormat(finalreal),function(err){
|
||||
if(err) console.log("error:" + err);
|
||||
|
||||
})
|
||||
|
||||
for (let filename of filenames) {
|
||||
|
||||
const finalname = filename.replaceAll(".json","");
|
||||
|
||||
const response = await axios.get(`http://localhost:3000/check/${finalname}`).then((response) => {
|
||||
|
||||
if (response.data == "unavailable"){
|
||||
console.log(`${finalname}.is-really.cool is already present.`)
|
||||
} else if (response.data == "available"){
|
||||
const prefinal = JSON.stringify(filename)
|
||||
const final = prefinal.replaceAll(".json", "");
|
||||
const realfinal = final.replaceAll('"', '')
|
||||
|
||||
const filedata = fs.promises.readFile(`../domains/${filename}`)
|
||||
.then(async function(result) {
|
||||
const newres = JSON.parse(result)
|
||||
|
||||
const realresult = newres.url
|
||||
const response = await axios.post(
|
||||
'https://api.cloudflare.com/client/v4/zones/d76cdc117a7173dd501a5f212176c203/dns_records',
|
||||
{
|
||||
'type': 'CNAME',
|
||||
'name': realfinal,
|
||||
'content': realresult,
|
||||
'ttl': 1,
|
||||
'priority': 10,
|
||||
'proxied': true
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'X-Auth-Email': 'leejoab75@gmail.com',
|
||||
'X-Auth-Key': '60e5bb86dec42085c58ae1a85ede97a44f00c',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
if(response.data.success == true){
|
||||
console.log(`${finalname}.is-really.cool has been successfully added!`)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
res.sendStatus(200);
|
||||
})
|
||||
|
||||
|
||||
|
||||
// export 'app'
|
||||
module.exports = app
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"axios": "^1.1.3",
|
||||
"express": "^4.18.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"json-format": "^1.0.1"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user