Re-organize the repository.
This commit is contained in:
parent
eeca7eaece
commit
db3e79fd8f
2
src/config.ts
Normal file
2
src/config.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export const POST_PATH: string = __dirname + '/../posts';
|
||||||
|
export const STATIC_PATH: string = __dirname + '/../static';
|
@ -1,10 +1,9 @@
|
|||||||
import { Hono } from 'hono';
|
import { Hono } from 'hono';
|
||||||
import { jsxRenderer, useRequestContext } from 'hono/jsx-renderer';
|
import { jsxRenderer } from 'hono/jsx-renderer';
|
||||||
import { Page } from '@blog/templates/Page';
|
import { Page } from '@blog/templates/Page';
|
||||||
import home from '@blog/routes/home';
|
import home from '@blog/handlers/home';
|
||||||
import posts from '@blog/routes/posts';
|
import posts from '@blog/handlers/posts';
|
||||||
import type { SiteMeta } from '@blog/model/SiteMeta';
|
import type { SiteMeta } from '@blog/models/SiteMeta';
|
||||||
import { setupDb, readPostsToDatabase } from '@blog/db/init';
|
|
||||||
|
|
||||||
declare module 'hono' {
|
declare module 'hono' {
|
||||||
interface ContextRenderer {
|
interface ContextRenderer {
|
||||||
@ -12,38 +11,23 @@ declare module 'hono' {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
const app = new Hono();
|
||||||
console.log({ message: "Starting the Blog application..." });
|
|
||||||
const app = new Hono();
|
|
||||||
|
|
||||||
// Render the JSX views
|
// Render the JSX views
|
||||||
console.log({ message: "Bootstrapping the view layer..." });
|
app.get(
|
||||||
app.get(
|
'*',
|
||||||
'*',
|
jsxRenderer(
|
||||||
jsxRenderer(
|
({ children, meta }) => <Page meta={meta}>{children}</Page>,
|
||||||
({ children, meta }) => {
|
{ docType: true }
|
||||||
return (<Page meta={meta}>{children}</Page>);
|
)
|
||||||
},
|
);
|
||||||
{
|
|
||||||
docType: true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Bootstrap the Database
|
console.log({ message: "Bootstrapping the routes..." });
|
||||||
console.log({ message: "Bootstrapping the database..." });
|
app.route('/', home);
|
||||||
setupDb();
|
app.route('/posts', posts);
|
||||||
await readPostsToDatabase(__dirname + "/../posts");
|
|
||||||
|
|
||||||
// read all posts
|
export default {
|
||||||
// create listing of posts
|
port: process.env.APP_PORT || 3000,
|
||||||
|
fetch: app.fetch
|
||||||
console.log({ message: "Bootstrapping the routes..." });
|
|
||||||
app.route('/', home);
|
|
||||||
app.route('/posts', posts);
|
|
||||||
|
|
||||||
return app;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default main();
|
|
||||||
|
|
||||||
|
7
src/services/database.ts
Normal file
7
src/services/database.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export type ConnectionConfig = {
|
||||||
|
host: string,
|
||||||
|
username: string,
|
||||||
|
password: string,
|
||||||
|
database: string,
|
||||||
|
port: number
|
||||||
|
};
|
5
src/services/post-file.ts
Normal file
5
src/services/post-file.ts
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import { POST_PATH } from '@blog/config';
|
||||||
|
|
||||||
|
export class PostFileService {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user