Skip to content

Commit

Permalink
set up with simple auth proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
walteh committed Jun 25, 2024
1 parent 07b7a99 commit 468671c
Show file tree
Hide file tree
Showing 32 changed files with 297 additions and 293 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ jobs:
uses: oven-sh/setup-bun@v2
- name: setup pages
uses: actions/configure-pages@v5
- name: set-env
run: |
echo "VITE_UNTHREADME_THREADS_API_APP_ID=${{ secrets.UNTHREADME_THREADS_API_APP_ID }}" > .env
- name: build
run: |
bun install
bun run build
# sed -i 's/\/assets\//\/threadsole\/assets\//g' dist/index.html
echo "threadsole.net" > dist/CNAME
echo "unthread.me" > dist/CNAME
- name: upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
File renamed without changes.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/app/main.tsx"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "threadsole",
"name": "unthread.me",
"private": false,
"version": "0.0.0",
"type": "module",
"homepage": "https://threadsole.net/",
"homepage": "https://unthread.me/",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
Expand All @@ -26,6 +26,7 @@
"@types/tape": "^5.6.4",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"@vitejs/plugin-basic-ssl": "^1.1.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.19",
"ava": "^6.1.3",
Expand Down
39 changes: 39 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { FC } from "react";
import { Route, HashRouter, Routes } from "react-router-dom";
import { Outlet } from "react-router-dom";

import LayoutHeader from "./components/LayoutHeader";
import LayoutFooter from "./components/LayoutFooter";
import NotFound from "@src/pages/NotFound";
import Home from "@src/pages/Home";
import OAuthCallback from "@src/pages/OAuthCallback";

const App: FC = () => {
return (
<>
<HashRouter>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="*" element={<NotFound />} />
<Route path="oauth/callback" element={<OAuthCallback />} />
</Route>
</Routes>
</HashRouter>
</>
);
};

const Layout: FC = () => {
return (
<div className="h-screen overflow-x-hidden">
<LayoutHeader />
<main>
<Outlet />
</main>
<LayoutFooter />
</div>
);
};

export default App;
46 changes: 0 additions & 46 deletions src/app/App.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/app/Layout/index.ts

This file was deleted.

17 changes: 0 additions & 17 deletions src/app/Layout/ui/Layout.tsx

This file was deleted.

46 changes: 46 additions & 0 deletions src/components/LayoutFooter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { FC } from "react";

const LayoutFooter: FC = () => {
return (
<>
<footer className="footer bg-base-300 p-10 text-base-content">
<div>
<span className="footer-title">Services</span>
<a className="link-hover link">Branding</a>
<a className="link-hover link">Design</a>
<a className="link-hover link">Marketing</a>
<a className="link-hover link">Advertisement</a>
</div>
<div>
<span className="footer-title">Company</span>
<a className="link-hover link">About us</a>
<a className="link-hover link">Contact</a>
<a className="link-hover link">Jobs</a>
<a className="link-hover link">Press kit</a>
</div>
<div>
<span className="footer-title">Social</span>
<div className="grid grid-flow-col gap-4">
<a>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" className="fill-current">
<path d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z"></path>
</svg>
</a>
<a>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" className="fill-current">
<path d="M19.615 3.184c-3.604-.246-11.631-.245-15.23 0-3.897.266-4.356 2.62-4.385 8.816.029 6.185.484 8.549 4.385 8.816 3.6.245 11.626.246 15.23 0 3.897-.266 4.356-2.62 4.385-8.816-.029-6.185-.484-8.549-4.385-8.816zm-10.615 12.816v-8l8 3.993-8 4.007z"></path>
</svg>
</a>
<a>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" className="fill-current">
<path d="M9 8h-3v4h3v12h5v-12h3.642l.358-4h-4v-1.667c0-.955.192-1.333 1.115-1.333h2.885v-5h-3.808c-3.596 0-5.192 1.583-5.192 4.615v3.385z"></path>
</svg>
</a>
</div>
</div>
</footer>
</>
);
};

export default LayoutFooter;
61 changes: 61 additions & 0 deletions src/components/LayoutHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { FC } from "react";
import Logo from "@src/components/Logo.tsx";
import Menu from "./Menu";

const LayoutHeader: FC = () => {
return (
<>
<header>
<nav className="navbar bg-base-100">
<Menu
links={[
{ name: "Homepage", href: "/" },
{ name: "Portfolio", href: "/portfolio" },
{ name: "About", href: "/about" },
]}
/>
<Logo logoName={"daisyUI"} />
<div className="navbar-end">
<button className="btn-ghost btn-circle btn">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
/>
</svg>
</button>
<button className="btn-ghost btn-circle btn">
<div className="indicator">
<svg
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9"
/>
</svg>
<span className="badge badge-primary badge-xs indicator-item"></span>
</div>
</button>
</div>
</nav>
</header>
</>
);
};

export default LayoutHeader;
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { FC } from "react";
import { Logo as HeaderLogo } from "@/widgets/LayoutHeader/model/types";

export interface HeaderLogo {
logoName: string;
}

const Logo: FC<HeaderLogo> = ({ logoName }: HeaderLogo) => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { FC } from "react";
import { Menu as MenuType } from "../../model/types";
import { Link } from "react-router-dom";

const Menu: FC<MenuType> = ({ links }: MenuType) => {
export interface HeaderMenu {
links: { name: string; href: string }[];
}

const Menu: FC<HeaderMenu> = ({ links }: HeaderMenu) => {
return (
<>
<div className="navbar-start">
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 25 additions & 3 deletions src/pages/Home/ui/Page/Page.tsx → src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
import { FC } from "react";

import useStore from "../../../../threadsapi/store";
import useStore from "../threadsapi/store";

import { getAuthorizationStartURL } from "../threadsapi/api";

const Home: FC = () => {
const [token] = useStore((state) => [state.token]);
const [token] = useStore((state) => [state.access_token] as const);

if (token === null) {
return (
<>
<section>
<button
onClick={() => {
// open popup
const authUrl = getAuthorizationStartURL();
window.open(authUrl.toString(), "Threads OAuth", "width");
}}
className="btn-primary btn"
>
Login
</button>
</section>
</>
);
}

return (
<>
<section>
Expand All @@ -16,7 +38,7 @@ const Home: FC = () => {
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Quia minima laboriosam maxime sed dignissimos
harum provident itaque fugiat. A repellat aliquid inventore dolor tempora, omnis perferendis aspernatur quo
nisi excepturi. Ex, ullam odio iusto esse necessitatibus doloremque repudiandae!
{token}
{token.user_id}
</p>
<button className="btn-primary btn">Get Started</button>
</div>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Home/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions src/pages/NoMatch/index.ts

This file was deleted.

21 changes: 19 additions & 2 deletions src/pages/NoMatch/ui/Page/Page.tsx → src/pages/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { FC } from "react";
import { Link } from "react-router-dom";
import { useUpdateCode } from "../threadsapi/store";

const NotFound: FC = () => {
const urlParams = new URLSearchParams(location.search);
const code = urlParams.get("code");

if (!code) {
throw new Error("Token not found in the URL query parameters");
}

void useUpdateCode(code)
.then(() => {
console.log("Token updated");
window.location.href = "/";
})
.catch((err: unknown) => {
console.error(err);
});

const NoMatch: FC = () => {
return (
<section>
<div className="flex min-h-screen w-screen flex-col items-center justify-center gap-y-5">
Expand All @@ -17,4 +34,4 @@ const NoMatch: FC = () => {
);
};

export default NoMatch;
export default NotFound;
Loading

0 comments on commit 468671c

Please sign in to comment.