Add API router, index
This commit is contained in:
1 parent
fea861f042
commit
223ab79d21
4 files changed
+94
-2
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import express from 'express';
|
||||
import { Pool } from 'pg';
|
||||
import { CategoryRepository } from './category.repository.ts';
|
||||
import { createCategoryRouter } from './category.router.ts';
|
||||
|
||||
const app = express();
|
||||
const port = process.env.API_PORT || 8300;
|
||||
|
||||
// Initialize your database pool
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL
|
||||
});
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
// Inject the database pool into the repository layer
|
||||
const categoryRepository = new CategoryRepository(pool);
|
||||
|
||||
// Attach your category endpoints to the Express app
|
||||
app.use('/api/categories', createCategoryRouter(categoryRepository));
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`🚀 API workspace server running smoothly on http://localhost:${port}`);
|
||||
});
|
||||
Reference in new issue
Block a user