Skip to content

Commit bc78b3a

Browse files
Copilotalexanmtz
andauthored
Convert controllers to TypeScript with async/await (#1366)
* Initial plan * Convert 9 small controllers to TypeScript with async/await Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Convert 6 more controllers to TypeScript with async/await Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Complete conversion of all controllers to TypeScript with async/await Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> * Fix TypeScript compilation issues - build passing Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexanmtz <88840+alexanmtz@users.noreply.github.com>
1 parent 914e500 commit bc78b3a

33 files changed

Lines changed: 1115 additions & 1168 deletions

src/app/controllers/auth.js

Lines changed: 0 additions & 441 deletions
This file was deleted.

src/app/controllers/auth.ts

Lines changed: 403 additions & 0 deletions
Large diffs are not rendered by default.

src/app/controllers/contact.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/app/controllers/contact.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { contactRecruiters as contactRecruitersModule } from '../../modules/contact'
2+
3+
export const contactRecruiters = async (req: any, res: any) => {
4+
try {
5+
const data = await contactRecruitersModule(req.body)
6+
res.status(200).send(data)
7+
} catch (error: any) {
8+
// eslint-disable-next-line no-console
9+
console.log('error on contactRecruiters', error)
10+
res.status(401).send(error)
11+
}
12+
}

src/app/controllers/coupon.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/app/controllers/coupon.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { validateCoupon as couponValidate } from '../../modules/coupon'
2+
3+
export const validateCoupon = async (req: any, res: any) => {
4+
try {
5+
const data = await couponValidate(req.body)
6+
res.send(data)
7+
} catch (error: any) {
8+
// eslint-disable-next-line no-console
9+
console.log(error)
10+
res.status(400).send({ error: error.message })
11+
}
12+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const fetchChannelUserCount = async () => {
1111
json: true
1212
})
1313
if (data.ok) {
14-
const channel = data.channels.find((channel) => channel.id === slack.channelId)
14+
const channel = data.channels.find((channel: any) => channel.id === slack.channelId)
1515
if (!channel) {
1616
// eslint-disable-next-line no-console
1717
console.error('Invalid channel id ' + slack.channelId)
@@ -24,7 +24,7 @@ const fetchChannelUserCount = async () => {
2424
}
2525
}
2626

27-
exports.info = async (req, res) => {
27+
export const info = async (req: any, res: any) => {
2828
try {
2929
const countTasks = await models.Task.count()
3030
const tasks = await models.Task.findAll({
@@ -33,8 +33,8 @@ exports.info = async (req, res) => {
3333
const countUsers = await models.User.count()
3434
if (tasks) {
3535
const bounties = tasks
36-
.filter((t) => t.value)
37-
.reduce((accumulator, task) => accumulator + parseInt(task.value), 0)
36+
.filter((t: any) => t.value)
37+
.reduce((accumulator: number, task: any) => accumulator + parseInt(task.value), 0)
3838
const channelUserCount = await fetchChannelUserCount()
3939
res.send({
4040
tasks: countTasks,

src/app/controllers/label.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/app/controllers/label.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { labelSearch } from '../../modules/label'
2+
3+
export const labelSearchController = async (req: any, res: any) => {
4+
try {
5+
// Use query parameters for GET requests
6+
const data = await labelSearch(req.query)
7+
res.status(200).send(data)
8+
} catch (error: any) {
9+
// eslint-disable-next-line no-console
10+
console.log('error on types', error)
11+
res.status(401).send(error)
12+
}
13+
}

src/app/controllers/language.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)