Commit cd4dc7ce authored by Цой Данил's avatar Цой Данил 💬

Homework 89 #4 #5 #6 rewrote old controllers. Now call const now class directly

parent afed28db
......@@ -53,3 +53,4 @@ export class AlbumsController {
}
}
export const albumsController = new AlbumsController()
\ No newline at end of file
......@@ -50,4 +50,6 @@ export class ArtistsController {
res.send(response)
}
}
}
\ No newline at end of file
}
export const artistsController = new ArtistsController()
\ No newline at end of file
......@@ -16,3 +16,5 @@ export class HealthCheckController {
res.send('Server is OK')
}
}
export const healthCheckController = new HealthCheckController()
\ No newline at end of file
......@@ -36,4 +36,6 @@ export class TracksController {
res.send(response)
}
}
}
\ No newline at end of file
}
export const tracksController = new TracksController()
\ No newline at end of file
......@@ -27,4 +27,6 @@ export class UsersController {
const response: IResponse<IUser | null> = await this.service.loginUser(req.body)
res.status(200).send(response)
}
}
\ No newline at end of file
}
export const usersController = new UsersController()
\ No newline at end of file
import express, { Express } from "express";
import dotenv from 'dotenv';
import cors from 'cors';
import { HealthCheckController } from "./controllers/healthCheck";
import { healthCheckController, HealthCheckController } from "./controllers/healthCheck";
import { mongooseDB } from "./repository/mongooseDB";
import { ArtistsController } from "./controllers/artistsController";
import { AlbumsController } from "./controllers/albumsController";
import { TracksController } from "./controllers/tracksController";
import { artistsController, ArtistsController } from "./controllers/artistsController";
import { albumsController, AlbumsController } from "./controllers/albumsController";
import { tracksController, TracksController } from "./controllers/tracksController";
import { usersController } from "./controllers/usersController";
dotenv.config()
......@@ -20,10 +21,11 @@ class App {
public init = async(): Promise<void> => {
try{
this.app.use('/health-check', new HealthCheckController().getRouter())
this.app.use('/artists', new ArtistsController().getRouter())
this.app.use('/albums', new AlbumsController().getRouter())
this.app.use('/tracks', new TracksController().getRouter())
this.app.use('/health-check', healthCheckController.getRouter())
this.app.use('/artists', artistsController.getRouter())
this.app.use('/albums', albumsController.getRouter())
this.app.use('/tracks', tracksController.getRouter())
this.app.use('/users', usersController.getRouter())
this.app.listen(process.env.APP_PORT, () => {
console.log(`Server is running on http://localhost:${process.env.APP_PORT}`)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment