feat: set up api architecture with initial route
This commit is contained in:
parent
ac44b7857e
commit
f070678960
4 changed files with 41 additions and 0 deletions
11
src/controllers/EntriesController.js
Normal file
11
src/controllers/EntriesController.js
Normal 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
11
src/index.js
Normal 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
12
src/routes/entries.js
Normal 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
|
||||||
7
src/services/EntriesService.js
Normal file
7
src/services/EntriesService.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export class EntriesService {
|
||||||
|
// TODO add DatabaseConnectorService
|
||||||
|
|
||||||
|
getEntry = async () => {
|
||||||
|
return "API is working"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue