feat: set up api architecture with initial route

This commit is contained in:
thomasabishop 2025-02-09 18:26:53 +00:00
parent ac44b7857e
commit f070678960
4 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,11 @@
export class EntriesController {
entriesService
constructor(entriesService) {
this.entriesService = entriesService
}
getEntry = async (req, res) => {
const response = await this.entriesService.getEntry()
}
}

11
src/index.js Normal file
View file

@ -0,0 +1,11 @@
import express from "express"
import entries from "./routes/entries"
const app = express()
const port = 3000
app.use(express.json())
app.use("/entries", entries)
app.listen(port, () => {
console.info(`INFO Server running at http://localhost:${port}`)
})

12
src/routes/entries.js Normal file
View file

@ -0,0 +1,12 @@
import express from "express"
import { EntriesService } from "../services/EntriesService"
import { EntriesController } from "../controllers/EntriesController"
import { EntriesService } from "../services/EntriesService"
const router = express.Router()
const entriesService = new EntriesService()
const entriesController = new EntriesController(entriesService)
router.get("/:entry", entriesController.getEntry)
export default router

View file

@ -0,0 +1,7 @@
export class EntriesService {
// TODO add DatabaseConnectorService
getEntry = async () => {
return "API is working"
}
}