From a9a75b9280f35d8fc28ce2a06f01073e6fd1a0c5 Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Tue, 20 Feb 2024 10:06:46 -0600 Subject: [PATCH] Add /search endpoint, working on impl. --- index.js | 22 +++++-- package-lock.json | 121 +++++++++-------------------------- package.json | 2 +- src/pages/404.astro | 7 ++ src/pages/[lang]/index.astro | 34 +++++++++- tsconfig.json | 1 + 6 files changed, 90 insertions(+), 97 deletions(-) diff --git a/index.js b/index.js index 401f739..db577c2 100644 --- a/index.js +++ b/index.js @@ -14,7 +14,6 @@ dotenv.config(); if (!existsSync("./dist")) build(); const PORT = process.env.PORT || 3000; -const SITE_URL = process.env.URL || "http://0.0.0.0"; const bare = createBareServer("/bare/"); console.log(chalk.gray("Starting Bare...")); @@ -41,10 +40,9 @@ const rammerheadScopes = [ ]; const rammerheadSession = /^\/[a-z0-9]{32}/; -const rh_path = "node_modules/rammerhead/src/client"; function shouldRouteRh(req) { - const url = new URL(req.url, SITE_URL); + const url = new URL(req.url, 'http://0.0.0.0'); return rammerheadScopes.includes(url.pathname) || rammerheadSession.test(url.pathname); } @@ -82,7 +80,6 @@ app.use(compression()); app.use(express.static(path.join(process.cwd(), "static"))); app.use(express.static(path.join(process.cwd(), "build"))); app.use("/uv/", express.static(uvPath)); -app.use("/", express.static(rh_path)); app.use(express.json()); app.use( express.urlencoded({ @@ -90,6 +87,23 @@ app.use( }) ); app.use("/", express.static("dist/client/")); +app.get("/search", async (req, res) => { + try { + const { query } = req.query; + + const response = await fetch( + `http://api.duckduckgo.com/ac?q=${query}&format=json` + ).then((apiRes) => apiRes.json()); + + res.send(response); + } catch (err) { + res.redirect(302, "/404.html"); + } +}); +app.get('*', function(req, res){ + res.redirect(302, '/404.html'); +}); + console.log(chalk.gray("Starting Alu...")); console.log(chalk.green("Alu started successfully!")); diff --git a/package-lock.json b/package-lock.json index 4bd7d02..e526d36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,9 +10,9 @@ "dependencies": { "@astrojs/check": "^0.4.0", "@astrojs/node": "^7.0.4", - "@nebula-services/ultraviolet": "^1.0.1-1.patch.5", + "@nebula-services/ultraviolet": "^1.0.1-1.patch.7", "@tomphttp/bare-server-node": "^2.0.1", - "astro": "^4.3.3", + "astro": "^4.4.1", "astro-i18n": "^2.2.4", "astro-i18next": "^1.0.0-beta.21", "chalk": "^5.3.0", @@ -973,14 +973,25 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@medv/finder": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@medv/finder/-/finder-3.1.0.tgz", + "integrity": "sha512-ojkXjR3K0Zz3jnCR80tqPL+0yvbZk/lEodb6RIVjLz7W8RVA2wrw8ym/CzCpXO9SYVUIKHFUpc7jvf8UKfIM3w==" + }, + "node_modules/@nebula-services/bare-client": { + "version": "1.1.2-beta.3-patch.1", + "resolved": "https://registry.npmjs.org/@nebula-services/bare-client/-/bare-client-1.1.2-beta.3-patch.1.tgz", + "integrity": "sha512-SgXCJruqgFg9ulgKd/S+6IAL3G5lP08Ey+pLLv768pwvgV5WgXdoWxytV1jJ8kd0vpQcnrq3ropTn2buT+8r5Q==" + }, "node_modules/@nebula-services/ultraviolet": { - "version": "1.0.1-1.patch.5", - "resolved": "https://registry.npmjs.org/@nebula-services/ultraviolet/-/ultraviolet-1.0.1-1.patch.5.tgz", - "integrity": "sha512-EDwbh+AXPg+JxPcPhRHJh6crLh1AHSodcAgfO47ug4paoLkWXE0ELU5Tm0Um38kguTBHzTOPFSzNULpaFbhFLw==", + "version": "1.0.1-1.patch.7", + "resolved": "https://registry.npmjs.org/@nebula-services/ultraviolet/-/ultraviolet-1.0.1-1.patch.7.tgz", + "integrity": "sha512-9xe7BR1DbxtK+TeAlsllbuDE6j+eA9rMFQp4M05vkHjO5CuQYUFfC48m/y4vWhbna6Uf2xdlZLJr6gYGDJStBA==", "dependencies": { - "@tomphttp/bare-client": "^1.1.2-beta.3", + "@nebula-services/bare-client": "^1.1.2-beta.3-patch.1", "crypto-js": "^4.2.0", "css-tree": "^2.0.4", + "esbuild": "^0.19.11", "esotope-hammerhead": "^0.6.1", "events": "^3.3.0", "idb": "^7.1.1", @@ -990,11 +1001,6 @@ "set-cookie-parser": "^2.4.8" } }, - "node_modules/@nebula-services/ultraviolet/node_modules/@tomphttp/bare-client": { - "version": "1.1.2-beta.3", - "resolved": "https://registry.npmjs.org/@tomphttp/bare-client/-/bare-client-1.1.2-beta.3.tgz", - "integrity": "sha512-WyIVnSAqzfrLejmOhh/l/LtDOeK+SHnBGi/z+QyliVP1T1JxoNE5eecwxlV+osM9J6FTAYVGNHr8/5bubaIj6Q==" - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1727,9 +1733,9 @@ } }, "node_modules/astro": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/astro/-/astro-4.3.3.tgz", - "integrity": "sha512-8Vfcv8LuCfzkLj+NMk7i7pu5o0MPyDkYqUYWELSwKxWf85zJSNU4oLg4DlEZWbVpm5LeTfVrpSGrZGy5n4grBg==", + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/astro/-/astro-4.4.1.tgz", + "integrity": "sha512-nJLgNg8UXKBJYXjWtekgv1TYZES++LAdShgyKL8L5yJMeiqlDSO+/Laq5VfRKoL9hzBdyolJMB0WDE/+bRZytg==", "dependencies": { "@astrojs/compiler": "^2.5.3", "@astrojs/internal-helpers": "0.2.1", @@ -1741,6 +1747,7 @@ "@babel/plugin-transform-react-jsx": "^7.22.5", "@babel/traverse": "^7.23.3", "@babel/types": "^7.23.3", + "@medv/finder": "^3.1.0", "@types/babel__core": "^7.20.4", "acorn": "^8.11.2", "aria-query": "^5.3.0", @@ -1778,19 +1785,18 @@ "p-queue": "^8.0.1", "path-to-regexp": "^6.2.1", "preferred-pm": "^3.1.2", - "probe-image-size": "^7.2.3", "prompts": "^2.4.2", "rehype": "^13.0.1", "resolve": "^1.22.4", "semver": "^7.5.4", - "server-destroy": "^1.0.1", - "shikiji": "^0.9.18", + "shikiji": "^0.9.19", + "shikiji-core": "^0.9.19", "string-width": "^7.0.0", "strip-ansi": "^7.1.0", "tsconfck": "^3.0.0", "unist-util-visit": "^5.0.0", "vfile": "^6.0.1", - "vite": "^5.0.12", + "vite": "^5.1.2", "vitefu": "^0.2.5", "which-pm": "^2.1.1", "yargs-parser": "^21.1.1", @@ -4715,11 +4721,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, - "node_modules/lodash.merge": { - "version": "4.6.2", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", - "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==" - }, "node_modules/log-symbols": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-5.1.0.tgz", @@ -5868,30 +5869,6 @@ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, - "node_modules/needle": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/needle/-/needle-2.9.1.tgz", - "integrity": "sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==", - "dependencies": { - "debug": "^3.2.6", - "iconv-lite": "^0.4.4", - "sax": "^1.2.4" - }, - "bin": { - "needle": "bin/needle" - }, - "engines": { - "node": ">= 4.4.x" - } - }, - "node_modules/needle/node_modules/debug": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", - "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "dependencies": { - "ms": "^2.1.1" - } - }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -9143,9 +9120,9 @@ } }, "node_modules/postcss": { - "version": "8.4.33", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", - "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", + "version": "8.4.35", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", + "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==", "funding": [ { "type": "opencollective", @@ -9322,16 +9299,6 @@ "node": ">=6" } }, - "node_modules/probe-image-size": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/probe-image-size/-/probe-image-size-7.2.3.tgz", - "integrity": "sha512-HubhG4Rb2UH8YtV4ba0Vp5bQ7L78RTONYu/ujmCu5nBI8wGv24s4E9xSKBi0N1MowRpxk76pFCpJtW0KPzOK0w==", - "dependencies": { - "lodash.merge": "^4.6.2", - "needle": "^2.5.2", - "stream-parser": "~0.3.1" - } - }, "node_modules/process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", @@ -10257,11 +10224,6 @@ "suf-log": "^2.5.3" } }, - "node_modules/sax": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.3.0.tgz", - "integrity": "sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==" - }, "node_modules/section-matter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", @@ -10707,27 +10669,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/stream-parser": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/stream-parser/-/stream-parser-0.3.1.tgz", - "integrity": "sha512-bJ/HgKq41nlKvlhccD5kaCr/P+Hu0wPNKPJOH7en+YrJu/9EgqUF+88w5Jb6KNcjOFMhfX4B2asfeAtIGuHObQ==", - "dependencies": { - "debug": "2" - } - }, - "node_modules/stream-parser/node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/stream-parser/node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" - }, "node_modules/streamx": { "version": "2.15.7", "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.15.7.tgz", @@ -11595,12 +11536,12 @@ } }, "node_modules/vite": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz", - "integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==", + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.1.3.tgz", + "integrity": "sha512-UfmUD36DKkqhi/F75RrxvPpry+9+tTkrXfMNZD+SboZqBCMsxKtO52XeGzzuh7ioz+Eo/SYDBbdb0Z7vgcDJew==", "dependencies": { "esbuild": "^0.19.3", - "postcss": "^8.4.32", + "postcss": "^8.4.35", "rollup": "^4.2.0" }, "bin": { diff --git a/package.json b/package.json index 1cb372b..c9bfab0 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "@astrojs/node": "^7.0.4", "@nebula-services/ultraviolet": "^1.0.1-1.patch.7", "@tomphttp/bare-server-node": "^2.0.1", - "astro": "^4.3.3", + "astro": "^4.4.1", "astro-i18n": "^2.2.4", "astro-i18next": "^1.0.0-beta.21", "chalk": "^5.3.0", diff --git a/src/pages/404.astro b/src/pages/404.astro index 9105150..deef65f 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -13,4 +13,11 @@ import Layout from "../layouts/Layout.astro"; .error-page { color: white; } + .main-content { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + height: 100%; + } diff --git a/src/pages/[lang]/index.astro b/src/pages/[lang]/index.astro index fc3fd95..bfb2b3a 100644 --- a/src/pages/[lang]/index.astro +++ b/src/pages/[lang]/index.astro @@ -16,7 +16,7 @@ export function getStaticPaths() {

{t("menu.welcome")}

- +
Loading...
@@ -36,7 +36,8 @@ export function getStaticPaths() {

How can I contribute to the development of Alu?

Spreading the word of Alu is a great start, but if you really enjoy Alu, and want private - links, consider supporting me through Patreon! You can support me + +