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 49cb566..68b9299 100755
Binary files a/app/bun.lockb and b/app/bun.lockb differ
diff --git a/app/package.json b/app/package.json
index 0de78ec..0b8f5b6 100644
--- a/app/package.json
+++ b/app/package.json
@@ -1,11 +1,15 @@
{
- "scripts": {
- "dev": "bun run --hot src/index.ts"
- },
- "dependencies": {
- "hono": "^4.0.8"
- },
+ "name": "slovocast-api",
+ "module": "server.ts",
+ "type": "module",
"devDependencies": {
"@types/bun": "latest"
+ },
+ "peerDependencies": {
+ "typescript": "^5.0.0"
+ },
+ "dependencies": {
+ "@types/express": "^4.17.21",
+ "express": "^4.19.2"
}
-}
+}
\ No newline at end of file
diff --git a/app/src/frontend/components/flash-message.tsx b/app/src/frontend/components/flash-message.tsx
deleted file mode 100644
index 3e7fad5..0000000
--- a/app/src/frontend/components/flash-message.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-const FlashMessage = (props: { message: string, severity?: string }) => {
- 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}
-
-
-
- ${props.children}
-
-
- `;
-}
-
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 (
-
- );
-};
-
-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 (
-
- );
-};
-
-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,