-
-
Notifications
You must be signed in to change notification settings - Fork 185
Convert remaining JavaScript files in src/app to TypeScript #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import express from 'express' | ||
| import * as controllers from '../controllers/contact' | ||
|
|
||
| const router = express.Router() | ||
|
|
||
| router.post('/recruiters', controllers.contactRecruiters) | ||
|
|
||
| export default router |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import express from 'express' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/coupon' | ||
| import secure from './secure' | ||
|
|
||
| const router = express.Router() | ||
|
|
||
| router.use(secure) | ||
|
|
||
| router.post('/validate', controllers.validateCoupon) | ||
|
|
||
| export default router | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import express from 'express' | ||
| import '../../models' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/info' | ||
|
|
||
| const router = express.Router() | ||
|
|
||
| router.get('/all', controllers.info) | ||
|
|
||
| export default router |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import express from 'express' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/label' | ||
|
|
||
| const router = express.Router() | ||
|
|
||
| router.get('/search', controllers.labelSearchController) | ||
|
|
||
| export default router |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| const express = require('express') | ||
| import express from 'express' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/language' | ||
|
|
||
| const router = express.Router() | ||
| require('../../modules/authenticationHelpers') | ||
| const controllers = require('../controllers/language') | ||
|
|
||
| router.get('/search', controllers.languageSearchController) | ||
| router.get('/task/search', controllers.projectLanguageSearchController) | ||
|
|
||
| module.exports = router | ||
| export default router |
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import express from 'express' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import '../../modules/authenticationHelpers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import * as controllers from '../controllers/offer' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import secure from './secure' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const router = express.Router() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.use(secure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Check failureCode scanning / CodeQL Missing rate limiting High
This route handler performs
authorization Error loading related location Loading
Copilot AutofixAI 6 months ago In general, the problem is fixed by introducing a rate-limiting middleware and applying it to routes that perform authorization and/or expensive operations. A common approach in Express applications is to use a well-known library such as For this specific file, the best minimal change is to import
Suggested changeset
2
src/app/routes/offer.ts
package.json
Outside changed files
This fix introduces these dependencies
Copilot is powered by AI and may make mistakes. Always verify output.
Refresh and try again.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| router.put('/:id', controllers.updateOffer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default router | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| const express = require('express') | ||
| import express from 'express' | ||
| import 'passport' | ||
| import '../../modules/authenticationHelpers' | ||
| import '../../models' | ||
| import * as controllers from '../controllers/organization' | ||
| import secure from './secure' | ||
|
|
||
| const router = express.Router() | ||
| require('passport') | ||
| require('../../modules/authenticationHelpers') | ||
| require('../../models') | ||
| const controllers = require('../controllers/organization') | ||
|
|
||
| router.get('/list', controllers.listOrganizations) | ||
| router.get('/fetch/:id', controllers.fetchOrganization) | ||
| const secure = require('./secure') | ||
|
|
||
| router.use(secure) | ||
Check failureCode scanning / CodeQL Missing rate limiting High
This route handler performs
authorization Error loading related location Loading |
||
| router.post('/create', controllers.createOrganization) | ||
| router.put('/update', controllers.updateOrganization) | ||
|
|
||
| module.exports = router | ||
| export default router | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| const express = require('express') | ||
| import express from 'express' | ||
| import '../../modules/authenticationHelpers' | ||
| import secure from './secure' | ||
| import * as controllers from '../controllers/payment-request' | ||
|
|
||
| const router = express.Router() | ||
| require('../../modules/authenticationHelpers') | ||
| const secure = require('./secure') | ||
| const controllers = require('../controllers/payment-request') | ||
|
|
||
| router.use(secure) | ||
Check failureCode scanning / CodeQL Missing rate limiting High
This route handler performs
authorization Error loading related location Loading |
||
| router.post('/', controllers.createPaymentRequest) | ||
| router.get('/', controllers.listPaymentRequests) | ||
| router.put('/:id', controllers.updatePaymentRequest) | ||
|
|
||
| module.exports = router | ||
| export default router | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,15 @@ | ||
| const express = require('express') | ||
| import express from 'express' | ||
| import secure from './secure' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/payment-request-transfer' | ||
|
|
||
| const router = express.Router() | ||
| const secure = require('./secure') | ||
| require('../../modules/authenticationHelpers') | ||
| const controllers = require('../controllers/payment-request-transfer') | ||
|
|
||
| router.use(secure) | ||
Check failureCode scanning / CodeQL Missing rate limiting High
This route handler performs
authorization Error loading related location Loading |
||
| router.post('/', controllers.createPaymentRequestTransfer) | ||
| router.get('/', controllers.listPaymentRequestTransfers) | ||
| router.put('/:id', controllers.updatePaymentRequestTransfer) | ||
| //router.get('/search', controllers.searchPaymentRequestTransfer) | ||
| //router.get('/:id', controllers.fetchPaymentRequestTransfer) | ||
|
|
||
| module.exports = router | ||
| export default router | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| const express = require('express') | ||
| import express from 'express' | ||
| import secure from './secure' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/payout' | ||
|
|
||
| const router = express.Router() | ||
| const secure = require('./secure') | ||
| require('../../modules/authenticationHelpers') | ||
| const controllers = require('../controllers/payout') | ||
|
|
||
| router.use(secure) | ||
Check failureCode scanning / CodeQL Missing rate limiting High
This route handler performs
authorization Error loading related location Loading |
||
| router.post('/create', controllers.createPayout) | ||
| router.post('/request', controllers.requestPayout) | ||
| router.get('/search', controllers.searchPayout) | ||
|
|
||
| module.exports = router | ||
| export default router | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import express from 'express' | ||
| import '../../modules/authenticationHelpers' | ||
| import * as controllers from '../controllers/project' | ||
|
|
||
| const router = express.Router() | ||
|
|
||
| router.get('/fetch/:id', controllers.fetchProject) | ||
| router.get('/list', controllers.listProjects) | ||
|
|
||
| export default router |
Check failure
Code scanning / CodeQL
Missing rate limiting High
Copilot Autofix
AI 6 months ago
In general, you should ensure that any routes that trigger potentially expensive operations (such as authentication, authorization, or database-backed coupon validation) are protected by rate limiting. In an Express-based app, this is commonly done by using a middleware from a well-known library like
express-rate-limitand attaching it either globally (to the main app) or locally (to specific routers/routes).For this specific router, the best way to fix the issue without changing existing functionality is to apply a rate-limiting middleware to the coupon router. We can import
express-rate-limit, configure a limiter suited to this endpoint (e.g., a reasonable number of requests per 15-minute window), and install it before thesecuremiddleware so that abusive traffic is rejected before invoking potentially expensive authorization logic. Concretely, insrc/app/routes/coupon.tswe should: (1) add an import forexpress-rate-limit, (2) define acouponRateLimiterconfigured for a sane default (e.g., 100 requests per 15 minutes from the same IP), and (3) insertrouter.use(couponRateLimiter)beforerouter.use(secure). This will ensure that all routes on this router, including/validate, are rate-limited.