import { Context, Hono } from 'hono'; import { Connection, createPool } from 'mariadb'; import User from './models/User'; const app = new Hono(); // // bootstrap resources // // mariadb const databasePool = createPool({ host: process.env.DATABASE_HOST, user: process.env.DATABASE_USER, password: process.env.DATABASE_PASSWORD, database: process.env.DATABASE_SCHEMA }); app.onError((err: Error, c: Context) => { console.log(err.message); c.status(500); if (process.env.MODE == 'development') { return c.json({ err }); } return c.json({ message: "An error occurred." }); }); // // set routes // // Welcome message app.get('/', async (c: Context) => { return c.json({ message: "Hello from Slovocast" }); }); // User actions import users from './routes/user'; app.route("/users", users); // Channel Actions // add episode // edit episode // regenerate feed app.get('/:channel', (c: Context) => { return c.json({ channel: { name: "Name", } }); }); // feed actions export default app;