Skip to content

Commit

Permalink
Merge pull request #139 from Lissy93/FEAT/astroify
Browse files Browse the repository at this point in the history
FEAT - Astroify
  • Loading branch information
Lissy93 authored Jun 22, 2024
2 parents 7c0f750 + abab9f1 commit 07b6ca3
Show file tree
Hide file tree
Showing 334 changed files with 12,734 additions and 18,555 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ REACT_APP_WHO_API_KEY=''
# API_CORS_ORIGIN='*' # Enable CORS, by setting your allowed hostname(s) here
# API_ENABLE_RATE_LIMIT='true' # Enable rate limiting for the API
# REACT_APP_API_ENDPOINT='/api' # The endpoint for the API (can be local or remote)
# ENABLE_ANALYTICS='false' # Enable Plausible hit counter for the frontend
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
/build/

# ------------------------
# DEPLOYMENT
# BUILT FILES
# ------------------------
dist/
.vercel/
.netlify/
.webpack/
.serverless/
.astro/

# ------------------------
# DEPENDENCIES
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specify the Node.js version to use
ARG NODE_VERSION=16
ARG NODE_VERSION=21

# Specify the Debian version to use, the default is "bullseye"
ARG DEBIAN_VERSION=bullseye
Expand Down Expand Up @@ -30,7 +30,7 @@ COPY package.json yarn.lock ./

# Run yarn install to install dependencies and clear yarn cache
RUN apt-get update && \
yarn install --production --frozen-lockfile --network-timeout 100000 && \
yarn install --frozen-lockfile --network-timeout 100000 && \
rm -rf /app/node_modules/.cache

# Copy all files to working directory
Expand Down Expand Up @@ -59,4 +59,4 @@ EXPOSE ${PORT:-3000}
ENV CHROME_PATH='/usr/bin/chromium'

# Define the command executed when the container starts and start the server.js of the Node.js application
CMD ["yarn", "serve"]
CMD ["yarn", "start"]
6 changes: 5 additions & 1 deletion api/_common/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,8 @@ const commonMiddleware = (handler) => {
return nativeMode ? vercelHandler : netlifyHandler;
};

module.exports = commonMiddleware;
if (PLATFORM === 'NETLIFY') {
module.exports = commonMiddleware;
}

export default commonMiddleware;
10 changes: 5 additions & 5 deletions api/archives.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const axios = require('axios');
const middleware = require('./_common/middleware');
import axios from 'axios';
import middleware from './_common/middleware.js';

const convertTimestampToDate = (timestamp) => {
const [year, month, day, hour, minute, second] = [
Expand Down Expand Up @@ -46,7 +46,7 @@ const getScanFrequency = (firstScan, lastScan, totalScans, changeCount) => {
};
};

const getWaybackData = async (url) => {
const wayBackHandler = async (url) => {
const cdxUrl = `https://web.archive.org/cdx/search/cdx?url=${url}&output=json&fl=timestamp,statuscode,digest,length,offset`;

try {
Expand Down Expand Up @@ -80,5 +80,5 @@ const getWaybackData = async (url) => {
}
};

module.exports = middleware(getWaybackData);
module.exports.handler = middleware(getWaybackData);
export const handler = middleware(wayBackHandler);
export default handler;
12 changes: 6 additions & 6 deletions api/block-lists.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const dns = require('dns');
const { URL } = require('url');
const middleware = require('./_common/middleware');
import dns from 'dns';
import { URL } from 'url';
import middleware from './_common/middleware.js';

const DNS_SERVERS = [
{ name: 'AdGuard', ip: '176.103.130.130' },
Expand Down Expand Up @@ -94,12 +94,12 @@ const checkDomainAgainstDnsServers = async (domain) => {
return results;
};

const handler = async (url) => {
export const blockListHandler = async (url) => {
const domain = new URL(url).hostname;
const results = await checkDomainAgainstDnsServers(domain);
return { blocklists: results };
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(blockListHandler);
export default handler;

10 changes: 5 additions & 5 deletions api/carbon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const https = require('https');
const middleware = require('./_common/middleware');
import https from 'https';
import middleware from './_common/middleware.js';

const handler = async (url) => {
const carbonHandler = async (url) => {

// First, get the size of the website's HTML
const getHtmlSize = (url) => new Promise((resolve, reject) => {
Expand Down Expand Up @@ -48,5 +48,5 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(carbonHandler);
export default handler;
12 changes: 6 additions & 6 deletions api/cookies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const axios = require('axios');
const puppeteer = require('puppeteer');
const middleware = require('./_common/middleware');
import axios from 'axios';
import puppeteer from 'puppeteer';
import middleware from './_common/middleware.js';

const getPuppeteerCookies = async (url) => {
const browser = await puppeteer.launch({
Expand All @@ -21,7 +21,7 @@ const getPuppeteerCookies = async (url) => {
}
};

const handler = async (url) => {
const cookieHandler = async (url) => {
let headerCookies = null;
let clientCookies = null;

Expand Down Expand Up @@ -54,5 +54,5 @@ const handler = async (url) => {
return { headerCookies, clientCookies };
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(cookieHandler);
export default handler;
15 changes: 8 additions & 7 deletions api/dns-server.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const dns = require('dns');
const dnsPromises = dns.promises;
const axios = require('axios');
const middleware = require('./_common/middleware');
import { promises as dnsPromises, lookup } from 'dns';
import axios from 'axios';
import middleware from './_common/middleware.js';

const handler = async (url) => {
const dnsHandler = async (url) => {
try {
const domain = url.replace(/^(?:https?:\/\/)?/i, "");
const addresses = await dnsPromises.resolve4(domain);
Expand Down Expand Up @@ -41,5 +40,7 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);

export const handler = middleware(dnsHandler);
export default handler;

12 changes: 6 additions & 6 deletions api/dns.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const dns = require('dns');
const util = require('util');
const middleware = require('./_common/middleware');
import dns from 'dns';
import util from 'util';
import middleware from './_common/middleware.js';

const handler = async (url) => {
const dnsHandler = async (url) => {
let hostname = url;

// Handle URLs by extracting hostname
Expand Down Expand Up @@ -51,5 +51,5 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(dnsHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/dnssec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const https = require('https');
const middleware = require('./_common/middleware'); // Make sure this path is correct
import https from 'https';
import middleware from './_common/middleware.js';

const handler = async (domain) => {
const dnsSecHandler = async (domain) => {
const dnsTypes = ['DNSKEY', 'DS', 'RRSIG'];
const records = {};

Expand Down Expand Up @@ -53,5 +53,5 @@ const handler = async (domain) => {
return records;
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(dnsSecHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/features.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const https = require('https');
const middleware = require('./_common/middleware');
import https from 'https';
import middleware from './_common/middleware.js';

const handler = async (url) => {
const featuresHandler = async (url) => {
const apiKey = process.env.BUILT_WITH_API_KEY;

if (!url) {
Expand Down Expand Up @@ -45,5 +45,5 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(featuresHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/firewall.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const axios = require('axios');
const middleware = require('./_common/middleware');
import axios from 'axios';
import middleware from './_common/middleware.js';

const hasWaf = (waf) => {
return {
hasWaf: true, waf,
}
};

const handler = async (url) => {
const firewallHandler = async (url) => {
const fullUrl = url.startsWith('http') ? url : `http://${url}`;

try {
Expand Down Expand Up @@ -110,5 +110,5 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(firewallHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/get-ip.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const dns = require('dns');
const middleware = require('./_common/middleware');
import dns from 'dns';
import middleware from './_common/middleware.js';

const lookupAsync = (address) => {
return new Promise((resolve, reject) => {
Expand All @@ -13,11 +13,11 @@ const lookupAsync = (address) => {
});
};

const handler = async (url) => {
const ipHandler = async (url) => {
const address = url.replaceAll('https://', '').replaceAll('http://', '');
return await lookupAsync(address);
};


module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(ipHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/headers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios');
const middleware = require('./_common/middleware');
import axios from 'axios';
import middleware from './_common/middleware.js';

const handler = async (url, event, context) => {
const headersHandler = async (url, event, context) => {
try {
const response = await axios.get(url, {
validateStatus: function (status) {
Expand All @@ -15,5 +15,5 @@ const handler = async (url, event, context) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(headersHandler);
export default handler;
11 changes: 5 additions & 6 deletions api/hsts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const https = require('https');
const middleware = require('./_common/middleware');
import https from 'https';
import middleware from './_common/middleware.js';

const handler = async (url, event, context) => {
const hstsHandler = async (url, event, context) => {
const errorResponse = (message, statusCode = 500) => {
return {
statusCode: statusCode,
Expand Down Expand Up @@ -45,6 +45,5 @@ const handler = async (url, event, context) => {
});
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);

export const handler = middleware(hstsHandler);
export default handler;
10 changes: 5 additions & 5 deletions api/http-security.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const axios = require('axios');
const middleware = require('./_common/middleware');
import axios from 'axios';
import middleware from './_common/middleware.js';

const handler = async (url) => {
const httpsSecHandler = async (url) => {
const fullUrl = url.startsWith('http') ? url : `http://${url}`;

try {
Expand All @@ -22,5 +22,5 @@ const handler = async (url) => {
}
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);
export const handler = middleware(httpsSecHandler);
export default handler;
17 changes: 8 additions & 9 deletions api/legacy-rank.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const axios = require('axios');
const unzipper = require('unzipper');
const csv = require('csv-parser');
const fs = require('fs');
const middleware = require('./_common/middleware');
import axios from 'axios';
import unzipper from 'unzipper';
import csv from 'csv-parser';
import fs from 'fs';
import middleware from './_common/middleware.js';

// Should also work with the following sources:
// https://www.domcop.com/files/top/top10milliondomains.csv.zip
Expand All @@ -14,7 +14,7 @@ const middleware = require('./_common/middleware');
const FILE_URL = 'https://s3-us-west-1.amazonaws.com/umbrella-static/top-1m.csv.zip';
const TEMP_FILE_PATH = '/tmp/top-1m.csv';

const handler = async (url) => {
const rankHandler = async (url) => {
let domain = null;

try {
Expand Down Expand Up @@ -66,6 +66,5 @@ return new Promise((resolve, reject) => {
});
};

module.exports = middleware(handler);
module.exports.handler = middleware(handler);

export const handler = middleware(rankHandler);
export default handler;
Loading

0 comments on commit 07b6ca3

Please sign in to comment.