From 0d2cfd3002850a1d14e18d8b404d07aabdec1b45 Mon Sep 17 00:00:00 2001 From: Dave Smith-Hayes Date: Mon, 1 Apr 2024 20:48:57 -0400 Subject: [PATCH] Update the application to be express with types, run with bun --- app/README.md | 12 +++-- app/bun.lockb | Bin 3026 -> 31675 bytes app/package.json | 18 ++++--- app/src/frontend/components/flash-message.tsx | 7 --- .../components/form/error-message.tsx | 9 ---- .../frontend/components/form/login-form.tsx | 24 ---------- .../components/form/register-form.tsx | 29 ----------- app/src/frontend/layout.tsx | 23 --------- app/src/frontend/layout/footer.tsx | 13 ----- app/src/frontend/layout/header.tsx | 11 ----- app/src/frontend/pages/home.tsx | 9 ---- app/src/frontend/pages/login.tsx | 11 ----- app/src/frontend/pages/register.tsx | 10 ---- app/src/handlers/user.tsx | 35 -------------- app/src/index.tsx | 16 ------- app/src/middleware/session.ts | 45 ------------------ app/src/middleware/siteData.ts | 18 ------- app/src/model/Category.ts | 6 --- app/src/model/Channel.ts | 19 -------- app/src/model/Episode.ts | 13 ----- app/src/model/SiteData.ts | 8 ---- app/src/model/User.ts | 6 --- app/src/models/channel.ts | 11 +++++ app/src/models/episode.ts | 9 ++++ app/src/{model/Image.ts => models/image.ts} | 6 +-- app/src/server.ts | 12 +++++ app/tsconfig.json | 27 +++++++++-- sql/04-episodes.sql | 1 + 28 files changed, 77 insertions(+), 331 deletions(-) delete mode 100644 app/src/frontend/components/flash-message.tsx delete mode 100644 app/src/frontend/components/form/error-message.tsx delete mode 100644 app/src/frontend/components/form/login-form.tsx delete mode 100644 app/src/frontend/components/form/register-form.tsx delete mode 100644 app/src/frontend/layout.tsx delete mode 100644 app/src/frontend/layout/footer.tsx delete mode 100644 app/src/frontend/layout/header.tsx delete mode 100644 app/src/frontend/pages/home.tsx delete mode 100644 app/src/frontend/pages/login.tsx delete mode 100644 app/src/frontend/pages/register.tsx delete mode 100644 app/src/handlers/user.tsx delete mode 100644 app/src/index.tsx delete mode 100644 app/src/middleware/session.ts delete mode 100644 app/src/middleware/siteData.ts delete mode 100644 app/src/model/Category.ts delete mode 100644 app/src/model/Channel.ts delete mode 100644 app/src/model/Episode.ts delete mode 100644 app/src/model/SiteData.ts delete mode 100644 app/src/model/User.ts create mode 100644 app/src/models/channel.ts create mode 100644 app/src/models/episode.ts rename app/src/{model/Image.ts => models/image.ts} (66%) create mode 100644 app/src/server.ts diff --git a/app/README.md b/app/README.md index 6dd13e7..8033691 100644 --- a/app/README.md +++ b/app/README.md @@ -1,11 +1,15 @@ +# slovocast-api + To install dependencies: -```sh + +```bash bun install ``` To run: -```sh -bun run dev + +```bash +bun run server.ts ``` -open http://localhost:3000 +This project was created using `bun init` in bun v1.0.35. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. diff --git a/app/bun.lockb b/app/bun.lockb index 49cb5666fa2ecd446c537c7ccb64cca395b96693..68b9299c11a65afeff5482dc5c2ccbdea9d2ec96 100755 GIT binary patch literal 31675 zcmeHw2{@I_8~353P*PfGCrb;*o=}#Q5|zDuvm6|8aL%EWilmUVsYqH-q(y~@c2bHK z)!Rm^q^MNdOW%Dz&hYeqUyk1Y|GK{KyRODHX6Bjs-E+@9_slah&vWiaSxGC9&(m_{ zaJAUnAVt?et~7X-kDuED4~`F;<>ANkbrGy7}6{e%@g%K){VK743i~M=~v zu>3&?r2yy7<_ma!!3=k{YakXN^!;6Ue0CtuM?uJMfUw@&PEGX;1`#3Oy&yz6c)9TX z7IGPkTw%HlLgcFmLae8YFzg@;{eVfj1|0@9aYQd)VTHp^yK!GjglX&-Y6z@a*GuS?u`m60>`yry>)xv(uj} zmK}MhA(p%0N>T9B5wYP6{l|ST6%+crZl`nKeVM&p>Au$7A#;_U%P$J|@J)JOCe!=# z%=(x|OD%&fwiTSUl&Q-!+1)e8d8n1y8mTDjN7oV)F7*xY&FkE0`-W2G@ap6N{eLXq zkny}kb+Xc~BD0DfW^>;KeI2{=Kz(lH`UJ^mhRI#yj|Z+TFjv^QBw=m3lkN{Q`;t7b ztqHgKpQ&)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{6gSwlEngxVJTGrrj(`qM%Xv#1BgS`)Iw3^qXSNfD%3hSnC?1h)`>9pv6 z!%|Qe26(?4De|^2r2gx+Td%$SL+2B!r6+O96nVQ9)=rygfeI~!x^47}Zo}-$ZF^TD zq$w;2^n@{(x%4&ls3}CW9N`=kIe`yHQ(J#(io_J&nA%$RG?x*gsqz#JJ?i!;WNu+w vG@8o*jfH$x(|I(`Sxra7ly0>(_fd6Hhq^$ZB>@8u+K+Ua4vPQZ`~QCcf@p*^ delta 1090 zcmdn}o$-?R1U=1Pi)Qhh_;JZFp1G#qN=f60^sI-?i`V{UvR%KSMe5ljeJ5@PFkqh; zE+3T54&flkjQqTO7>|pAp#j9<1k(GU^kyIpG@-$ik%55+NCUZGP@b#0UvsTj$m9lA z34w|FQN3zgZ7n(TZH~PPoV9!M0#*+}plJ*SKpiYl9UPMvvZ_yhz{(+L1r#v_$^eZ7 z1Bgrl8>aw}YmFo!3(+FU$;dEym86~EZ=gI-bAt$w26;;YW+am%w;tns)XubpKK`~6A9-0i5}szMoY~#j@q2VtbNq?lZ7gurcraIqU&ht+Un2 zqxCiikb@;clJD>2E*v7Y1g_vP@g{yK#k$ z&-Z5xljkXjPrhp9fE)mzu!I2?ZL=MB-w558;%-pXblNTaTO{L;Q(S+{mWg3(9UEP) zT;$^|-0b^DiFySWOK%0e~C~ zQU;4M!hd19{oWcw;nMvKW|RZfCN nmU<=WRZvZN`6;QB=T+HGo|Y~>*}hzo$;f1KRC(ZJ { - return ( -
- {props.message} -
- ) -}; diff --git a/app/src/frontend/components/form/error-message.tsx b/app/src/frontend/components/form/error-message.tsx deleted file mode 100644 index e6fd2ea..0000000 --- a/app/src/frontend/components/form/error-message.tsx +++ /dev/null @@ -1,9 +0,0 @@ -const ErrorMessage = (props: { message: string }) => { - return ( -
- {props.message} -
- ); -}; - -export default ErrorMessage; diff --git a/app/src/frontend/components/form/login-form.tsx b/app/src/frontend/components/form/login-form.tsx deleted file mode 100644 index 2f29126..0000000 --- a/app/src/frontend/components/form/login-form.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FC } from "hono/jsx" -import ErrorMessage from "@slovo/frontend/components/form/error-message"; - -export const LoginForm: FC = (props) => { - return ( - <> - {props.error ? : null} -
- - -
- -
-
- - ); -}; - diff --git a/app/src/frontend/components/form/register-form.tsx b/app/src/frontend/components/form/register-form.tsx deleted file mode 100644 index 356f321..0000000 --- a/app/src/frontend/components/form/register-form.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { FC } from 'hono/jsx'; -import ErrorMessage from '@slovo/frontend/components/form/error-message'; - - -export const RegisterForm: FC = (props) => { - return ( - <> - {props.error ? : null} -
- - - -
- -
-
- - ); -}; - diff --git a/app/src/frontend/layout.tsx b/app/src/frontend/layout.tsx deleted file mode 100644 index 973e9f5..0000000 --- a/app/src/frontend/layout.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { html } from 'hono/html'; - -export const Layout = (props: { title: string, children?: any }) => { - return html` - - - - - - ${props.title} - - -
-

Slovocast

-
-
${props.children}
-
-

© 2024, Slovocast

-
- - `; -} - diff --git a/app/src/frontend/layout/footer.tsx b/app/src/frontend/layout/footer.tsx deleted file mode 100644 index 9c37f4e..0000000 --- a/app/src/frontend/layout/footer.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { FC } from 'hono/jsx'; - -// const currentYear = new Date().getFullYear(); - -const Footer: FC = (props) => { - return ( -
-
{props.copyright}
-
- ); -}; - -export default Footer; diff --git a/app/src/frontend/layout/header.tsx b/app/src/frontend/layout/header.tsx deleted file mode 100644 index c284e6f..0000000 --- a/app/src/frontend/layout/header.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { FC } from 'hono/jsx'; - -const Header: FC = (props) => { - return ( -
-
{props.title}
-
- ); -}; - -export default Header; diff --git a/app/src/frontend/pages/home.tsx b/app/src/frontend/pages/home.tsx deleted file mode 100644 index 5be23a4..0000000 --- a/app/src/frontend/pages/home.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { Layout } from "@slovo/frontend/layout"; - -export const HomePage = () => { - return ( - -
Welcome to Slovocast
-
- ); -}; diff --git a/app/src/frontend/pages/login.tsx b/app/src/frontend/pages/login.tsx deleted file mode 100644 index ea40f39..0000000 --- a/app/src/frontend/pages/login.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import { Layout } from '@slovo/frontend/layout'; -import { LoginForm } from '@slovo/frontend/components/form/login-form'; - -export const LoginPage = (props: { error?: any }) => { - return ( - - - - ); -}; - diff --git a/app/src/frontend/pages/register.tsx b/app/src/frontend/pages/register.tsx deleted file mode 100644 index 6fbed4c..0000000 --- a/app/src/frontend/pages/register.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { RegisterForm } from '@slovo/frontend/components/form/register-form'; -import { Layout } from '@slovo/frontend/layout'; - -export const RegisterPage = (props: { error?: any }) => { - return ( - - - - ); -}; diff --git a/app/src/handlers/user.tsx b/app/src/handlers/user.tsx deleted file mode 100644 index 353a435..0000000 --- a/app/src/handlers/user.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Hono } from 'hono'; -import { Context } from 'hono'; -import { LoginPage } from '@slovo/frontend/pages/login'; -import { RegisterPage } from '@slovo/frontend/pages/register'; - -const UserHandler = new Hono(); - -UserHandler.get('/login', async (c: Context) => { - const errors = c.get('login-errors'); - return c.html(); -}); - -UserHandler.post('/login', async (c: Context) => { - const form = await c.req.formData(); - - // validate form - if (form.has('login')) { - if (form.get('email') == 'me@davesmithhayes.com') { - if (form.get('password') == 'test') { - c.set('auth', true); - return c.redirect('/'); - } - } - } - - c.set('login-errors', { error: { message: "Bad credentials" }}); - return c.redirect('/login'); -}); - -UserHandler.get('/register', async (c: Context) => { - const errors = c.get('register-errors'); - return c.html(); -}) - -export default UserHandler; diff --git a/app/src/index.tsx b/app/src/index.tsx deleted file mode 100644 index 2d2ce60..0000000 --- a/app/src/index.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { Hono } from 'hono'; -import { siteDataMiddleware } from './middleware/siteData'; -import { HomePage } from './frontend/pages/home'; -import UserHandler from './handlers/user'; - -const app = new Hono(); -app.use(siteDataMiddleware); - -app.get('/', async (c) => { - return c.html(); -}); - -// Handlers -app.route('', UserHandler); - -export default app; diff --git a/app/src/middleware/session.ts b/app/src/middleware/session.ts deleted file mode 100644 index 20cbe42..0000000 --- a/app/src/middleware/session.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { Context } from 'hono'; - -class Session { - private readonly id: string; - private data: Record; - - public constructor(id: string, data?: Record) { - this.id = id; - this.data = data ?? {}; - } - - public getId(): string { - return this.id; - } - - public getData(key: string): any { - return this.data[key]; - } - - public setData(key: string, data: any): void { - this.data[key] = data; - } -} - -class SessionHandler { - private static instance: SessionHandler; - - private constructor() { } - - public static getInstance(): SessionHandler { - if (!SessionHandler.instance) { - SessionHandler.instance = new SessionHandler(); - } - - return SessionHandler.instance; - } -} - -const sessionMiddleware = async (c: Context, next: CallableFunction) => { - c.set('session', SessionHandler.getInstance()); - await next(); -}; - -export { sessionMiddleware, SessionHandler, Session }; - diff --git a/app/src/middleware/siteData.ts b/app/src/middleware/siteData.ts deleted file mode 100644 index ea5d944..0000000 --- a/app/src/middleware/siteData.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Context } from 'hono'; -import SiteData from '@slovo/model/SiteData'; - -const currentYear = new Date().getFullYear(); - -const config: SiteData = { - name: "Slovocast", - description: "A no-nonesense Podcast hosting platform.", - baseUrl: "dev.slovocast.com", - copyright: `Copyright ${currentYear} Slovocast`, -}; - -const siteDataMiddleware = async function(c: Context, next: CallableFunction) { - c.set('config', config); - await next(); -}; - -export { siteDataMiddleware }; diff --git a/app/src/model/Category.ts b/app/src/model/Category.ts deleted file mode 100644 index 20cb743..0000000 --- a/app/src/model/Category.ts +++ /dev/null @@ -1,6 +0,0 @@ -type Category = { - name: string, - categories?: Category[] -}; - -export default Category; diff --git a/app/src/model/Channel.ts b/app/src/model/Channel.ts deleted file mode 100644 index 1bb4f56..0000000 --- a/app/src/model/Channel.ts +++ /dev/null @@ -1,19 +0,0 @@ -import Category from '@slovo/model/Category'; -import Image from '@slovo/model/Image'; -import Episode from '@slovo/model/Episode'; - -type Channel = { - name: string, - description: string, - link: URL, - language: string, - copyright: string, - explicit: boolean, - category: Category, - - image: Image, - - episodes: Episode[], -}; - -export default Channel; diff --git a/app/src/model/Episode.ts b/app/src/model/Episode.ts deleted file mode 100644 index 9a6f59a..0000000 --- a/app/src/model/Episode.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Image from '@slovo/model/Image'; - -type Episode = { - title: string, - link: URL, - duration: string, - description: string, - explicit: boolean, - - image: Image, -}; - -export default Episode; diff --git a/app/src/model/SiteData.ts b/app/src/model/SiteData.ts deleted file mode 100644 index e9040a8..0000000 --- a/app/src/model/SiteData.ts +++ /dev/null @@ -1,8 +0,0 @@ -type SiteData = { - name: string, - description: string, - baseUrl: string - copyright: string, -}; - -export default SiteData; diff --git a/app/src/model/User.ts b/app/src/model/User.ts deleted file mode 100644 index 3fc5596..0000000 --- a/app/src/model/User.ts +++ /dev/null @@ -1,6 +0,0 @@ -type User = { - name: string, - email: string, -}; - -export default User; diff --git a/app/src/models/channel.ts b/app/src/models/channel.ts new file mode 100644 index 0000000..ef9416a --- /dev/null +++ b/app/src/models/channel.ts @@ -0,0 +1,11 @@ +type Channel = { + name: string, + description: string, + link: URL, + language: string, + copyright: string, + explicit: boolean, + category: string, +}; + +export default Channel; diff --git a/app/src/models/episode.ts b/app/src/models/episode.ts new file mode 100644 index 0000000..dafcadd --- /dev/null +++ b/app/src/models/episode.ts @@ -0,0 +1,9 @@ +type Episode = { + title: string, + link: URL, + duration: string, + description: string, + explicit: boolean +}; + +export default Episode; diff --git a/app/src/model/Image.ts b/app/src/models/image.ts similarity index 66% rename from app/src/model/Image.ts rename to app/src/models/image.ts index 2d61d22..a8faa3c 100644 --- a/app/src/model/Image.ts +++ b/app/src/models/image.ts @@ -1,8 +1,8 @@ type Image = { - title: string, url: URL, - width?: number, - height?: number + title: string, + width: number, + height: number, }; export default Image; diff --git a/app/src/server.ts b/app/src/server.ts new file mode 100644 index 0000000..6c55812 --- /dev/null +++ b/app/src/server.ts @@ -0,0 +1,12 @@ +import express, { Express, type Request, type Response } from "express"; + +const server: Express = express(); + +server.get("/", async (req: Request, res: Response) => { + console.log(req); + return res.json({ message: "Hello!" }); +}); + +server.listen(3000, () => { + console.log("Running on 3000"); +}); diff --git a/app/tsconfig.json b/app/tsconfig.json index eb6af7d..0fef23a 100644 --- a/app/tsconfig.json +++ b/app/tsconfig.json @@ -1,10 +1,27 @@ { "compilerOptions": { - "strict": true, + // Enable latest features + "lib": ["ESNext"], + "target": "ESNext", + "module": "ESNext", + "moduleDetection": "force", "jsx": "react-jsx", - "jsxImportSource": "hono/jsx", - "paths": { - "@slovo/*": [ "src/*" ] - } + "allowJs": true, + + // Bundler mode + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, + "noEmit": true, + + // Best practices + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + + // Some stricter flags (disabled by default) + "noUnusedLocals": false, + "noUnusedParameters": false, + "noPropertyAccessFromIndexSignature": false } } diff --git a/sql/04-episodes.sql b/sql/04-episodes.sql index be34bba..eaacf3b 100644 --- a/sql/04-episodes.sql +++ b/sql/04-episodes.sql @@ -3,6 +3,7 @@ CREATE TABLE episodes ( title VARCHAR(255) NOT NULL, link VARCHAR(255) NOT NULL, duration VARCHAR(127) NOT NULL, + length INT(11) UNSIGNED NOT NULL, description TEXT NOT NULL, explicit BOOLEAN NOT NULL DEFAULT true,