From f5dc225eeb068cbd5afba9fc2e43b2b0b08caa97 Mon Sep 17 00:00:00 2001 From: BraCR10 Date: Fri, 20 Dec 2024 08:35:00 -0600 Subject: [PATCH] Implementation of existing routes at this time to index.ts --- src/index.ts | 10 ++++------ src/routes/index.ts | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/routes/index.ts diff --git a/src/index.ts b/src/index.ts index 4ff0de4..632c709 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,14 +1,16 @@ import 'reflect-metadata'; import express from 'express'; import AppDataSource from './config/ormconfig'; -import userRoutes from './routes/UserRoutes'; +import indexRoutes from './routes/index'; + const app = express(); const PORT = process.env.PORT || 3000; app.use(express.json()); -app.use('/users', userRoutes); +// Use the index routes +app.use('/api/v1', indexRoutes); AppDataSource.initialize() .then(() => { @@ -21,9 +23,5 @@ AppDataSource.initialize() console.error('Error during Data Source initialization:', error); }); -app.get('/', (req, res) => { - res.send('Hello, world!'); -}); - export default app; // Export the app for testing \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts new file mode 100644 index 0000000..1a0ff8f --- /dev/null +++ b/src/routes/index.ts @@ -0,0 +1,18 @@ +import { Router } from 'express'; +import userRoutes from './UserRoutes'; +// import productRoutes from './product.routes'; +// import storeRoutes from './store.routes'; + +const router = Router(); + +// Health Check Route +router.get('/health', (req, res) => { + res.status(200).json({ status: 'success', message: 'API is running!' }); +}); + +// Mount route modules +router.use('/users', userRoutes); +// router.use('/products', productRoutes); +// router.use('/stores', storeRoutes); + +export default router; \ No newline at end of file