chore: dry out 410 logic (#45257)
This commit is contained in:
@ -16,6 +16,7 @@ import {
|
||||
} from '../../../../config/certification-settings';
|
||||
import { reportError } from '../middlewares/sentry-error-handler.js';
|
||||
|
||||
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
|
||||
import { getChallenges } from '../utils/get-curriculum';
|
||||
import { ifNoUser401 } from '../utils/middleware';
|
||||
import { observeQuery } from '../utils/rx';
|
||||
@ -51,19 +52,10 @@ export default function bootCertificate(app) {
|
||||
|
||||
api.put('/certificate/verify', ifNoUser401, ifNoSuperBlock404, verifyCert);
|
||||
api.get('/certificate/showCert/:username/:certSlug', showCert);
|
||||
api.get('/certificate/verify-can-claim-cert', verifyCanClaimCert);
|
||||
api.get('/certificate/verify-can-claim-cert', deprecatedEndpoint);
|
||||
app.use(api);
|
||||
}
|
||||
|
||||
function verifyCanClaimCert(_req, res) {
|
||||
return res.status(410).json({
|
||||
message: {
|
||||
type: 'info',
|
||||
message: 'Please reload the app, this feature is no longer available.'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function getFallbackFullStackDate(completedChallenges, completedDate) {
|
||||
var chalIds = [
|
||||
certTypeIdMap[certTypes.respWebDesign],
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { getRedirectParams } from '../utils/redirection';
|
||||
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
|
||||
|
||||
module.exports = function (app) {
|
||||
const router = app.loopback.Router();
|
||||
const User = app.models.User;
|
||||
|
||||
router.get('/api/github', gone);
|
||||
router.get('/api/github', deprecatedEndpoint);
|
||||
router.get('/u/:email', unsubscribeDeprecated);
|
||||
router.get('/unsubscribe/:email', unsubscribeDeprecated);
|
||||
router.get('/ue/:unsubscribeId', unsubscribeById);
|
||||
@ -12,15 +13,6 @@ module.exports = function (app) {
|
||||
|
||||
app.use(router);
|
||||
|
||||
function gone(_, res) {
|
||||
return res.status(410).json({
|
||||
message: {
|
||||
type: 'info',
|
||||
message: 'Please reload the app, this feature is no longer available.'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function unsubscribeDeprecated(req, res) {
|
||||
req.flash(
|
||||
'info',
|
||||
|
@ -4,6 +4,7 @@ import isURL from 'validator/lib/isURL';
|
||||
|
||||
import { isValidUsername } from '../../../../utils/validate';
|
||||
import { alertTypes } from '../../common/utils/flash.js';
|
||||
import { deprecatedEndpoint } from '../utils/deprecatedEndpoint';
|
||||
import { ifNoUser401, createValidatorErrorHandler } from '../utils/middleware';
|
||||
|
||||
const log = debug('fcc:boot:settings');
|
||||
@ -15,7 +16,7 @@ export default function settingsController(app) {
|
||||
|
||||
api.put('/update-privacy-terms', ifNoUser401, updatePrivacyTerms);
|
||||
|
||||
api.post('/refetch-user-completed-challenges', gone);
|
||||
api.post('/refetch-user-completed-challenges', deprecatedEndpoint);
|
||||
api.post(
|
||||
'/update-my-current-challenge',
|
||||
ifNoUser401,
|
||||
@ -24,7 +25,7 @@ export default function settingsController(app) {
|
||||
updateMyCurrentChallenge
|
||||
);
|
||||
api.post('/update-my-portfolio', ifNoUser401, updateMyPortfolio);
|
||||
api.post('/update-my-theme', gone);
|
||||
api.post('/update-my-theme', deprecatedEndpoint);
|
||||
api.put('/update-my-about', ifNoUser401, updateMyAbout);
|
||||
api.put(
|
||||
'/update-my-email',
|
||||
@ -50,15 +51,6 @@ const standardSuccessMessage = {
|
||||
message: 'flash.updated-preferences'
|
||||
};
|
||||
|
||||
function gone(_, res) {
|
||||
return res.status(410).json({
|
||||
message: {
|
||||
type: 'info',
|
||||
message: 'Please reload the app, this feature is no longer available.'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const createStandardHandler = (req, res, next) => err => {
|
||||
if (err) {
|
||||
res.status(500).json(standardErrorMessage);
|
||||
|
8
api-server/src/server/utils/deprecatedEndpoint.js
Normal file
8
api-server/src/server/utils/deprecatedEndpoint.js
Normal file
@ -0,0 +1,8 @@
|
||||
export function deprecatedEndpoint(_, res) {
|
||||
return res.status(410).json({
|
||||
message: {
|
||||
type: 'info',
|
||||
message: 'Please reload the app, this feature is no longer available.'
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user