Skip to content

Commit d7f9cfd

Browse files
committed
remove: classes in controllers
1 parent d140949 commit d7f9cfd

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

src/routes/api/run/controller.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ type RunPoolElement = {
1818

1919
const RunPool: { [x: number]: RunPoolElement } = {}
2020

21-
class RunController {
22-
async RunPOST(req: Request, res: Response) {
21+
export default {
22+
async runPOST(req: Request, res: Response) {
2323
const mode = req.body.mode || 'sync'
2424
const job = await DB.submissions.create({
2525
lang: req.body.lang,
@@ -49,7 +49,7 @@ class RunController {
4949
RunPool[job.id] = {
5050
res
5151
}
52-
}
52+
},
5353

5454
async onSuccess(result: RunResponse) {
5555
const job = await DB.submissions.findById(result.id)
@@ -64,5 +64,3 @@ class RunController {
6464
}
6565
}
6666
}
67-
68-
export default new RunController()

src/routes/api/run/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { successListener } from 'rabbitmq/jobqueue'
55

66
const router: Router = Router()
77

8-
router.post('/', Validator.POST, Controller.RunPOST)
8+
router.post('/', Validator.POST, Controller.runPOST)
99
successListener.on('run_result', Controller.onSuccess)
1010

1111
export default router

src/routes/api/submit/controller.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ type RunPoolElement = {
2222

2323
const RunPool: { [x: number]: RunPoolElement } = {}
2424

25-
class SubmitController {
26-
async SubmitPOST(req: Request, res: Response) {
25+
export default {
26+
async submitPOST(req: Request, res: Response) {
2727
const mode = req.body.mode || 'sync'
2828
const job = await DB.submissions.create({
2929
lang: req.body.lang,
@@ -51,7 +51,7 @@ class SubmitController {
5151
RunPool[job.id] = {
5252
res
5353
}
54-
}
54+
},
5555

5656
async onSuccess(result: SubmitResponse) {
5757
const job = await DB.submissions.findById(result.id)
@@ -68,5 +68,3 @@ class SubmitController {
6868
}
6969
}
7070
}
71-
72-
export default new SubmitController()

src/routes/api/submit/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { successListener } from 'rabbitmq/jobqueue'
55

66
const router: Router = Router()
77

8-
router.post('/', Validator.POST, Controller.SubmitPOST)
8+
router.post('/', Validator.POST, Controller.submitPOST)
99
successListener.on('submit_result', Controller.onSuccess)
1010

1111
export default router

0 commit comments

Comments
 (0)