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 { jsxRenderer, useRequestContext } from 'hono/jsx-renderer';
|
||||
import { jsxRenderer } from 'hono/jsx-renderer';
|
||||
import { Page } from '@blog/templates/Page';
|
||||
import home from '@blog/routes/home';
|
||||
import posts from '@blog/routes/posts';
|
||||
import type { SiteMeta } from '@blog/model/SiteMeta';
|
||||
import { setupDb, readPostsToDatabase } from '@blog/db/init';
|
||||
import home from '@blog/handlers/home';
|
||||
import posts from '@blog/handlers/posts';
|
||||
import type { SiteMeta } from '@blog/models/SiteMeta';
|
||||
|
||||
declare module 'hono' {
|
||||
interface ContextRenderer {
|
||||
@ -12,38 +11,23 @@ declare module 'hono' {
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log({ message: "Starting the Blog application..." });
|
||||
const app = new Hono();
|
||||
const app = new Hono();
|
||||
|
||||
// Render the JSX views
|
||||
console.log({ message: "Bootstrapping the view layer..." });
|
||||
app.get(
|
||||
'*',
|
||||
jsxRenderer(
|
||||
({ children, meta }) => {
|
||||
return (<Page meta={meta}>{children}</Page>);
|
||||
},
|
||||
{
|
||||
docType: true
|
||||
}
|
||||
)
|
||||
);
|
||||
// Render the JSX views
|
||||
app.get(
|
||||
'*',
|
||||
jsxRenderer(
|
||||
({ children, meta }) => <Page meta={meta}>{children}</Page>,
|
||||
{ docType: true }
|
||||
)
|
||||
);
|
||||
|
||||
// Bootstrap the Database
|
||||
console.log({ message: "Bootstrapping the database..." });
|
||||
setupDb();
|
||||
await readPostsToDatabase(__dirname + "/../posts");
|
||||
console.log({ message: "Bootstrapping the routes..." });
|
||||
app.route('/', home);
|
||||
app.route('/posts', posts);
|
||||
|
||||
// read all posts
|
||||
// create listing of posts
|
||||
|
||||
console.log({ message: "Bootstrapping the routes..." });
|
||||
app.route('/', home);
|
||||
app.route('/posts', posts);
|
||||
|
||||
return app;
|
||||
export default {
|
||||
port: process.env.APP_PORT || 3000,
|
||||
fetch: app.fetch
|
||||
}
|
||||
|
||||
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