Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
refactor: add onboarding and map routes to specific router (#2341)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasCharrier authored Jan 16, 2024
1 parent c9a1972 commit c0c7d0f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
25 changes: 4 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import flash from 'connect-flash';
import express from 'express';
import { expressjwt, Request } from 'express-jwt';
import expressSanitizer from 'express-sanitizer';
import { checkSchema } from 'express-validator';
import session from 'express-session';
import path from 'path';
import cors from 'cors';
import config from '@config';
import * as githubNotificationController from '@controllers/githubNotificationController';
import * as indexController from '@controllers/indexController';
import * as onboardingController from '@controllers/onboardingController';
import * as resourceController from '@controllers/resourceController';
import * as mapController from '@controllers/mapController';
import * as hookController from '@controllers/hookController';
import * as pullRequestsController from '@controllers/pullRequestsController';
import * as sentry from './lib/sentry';
Expand All @@ -36,6 +33,8 @@ import { diagnosticRouter } from './routes/diagnostic';
import { badgeRouter } from './routes/badge';
import { newsletterRouter } from './routes/newsletter';
import setupStaticFiles from './routes/staticFiles';
import { onboardingRouter } from './routes/onboarding';
import { mapRouter } from './routes/map';

export const app = express();
app.set('trust proxy', 1);
Expand Down Expand Up @@ -158,6 +157,8 @@ app.use(authRouter);
app.use(diagnosticRouter);
app.use(badgeRouter);
app.use(newsletterRouter);
app.use(onboardingRouter);
app.use(mapRouter);

app.get(routes.PULL_REQUEST_GET_PRS, pullRequestsController.getAllPullRequests);
//
Expand All @@ -172,25 +173,7 @@ app.get(routes.API_PUBLIC_INCUBATORS_GET_ALL, getAllIncubators);
//sponsors
app.get(routes.API_PUBLIC_SPONSORS_GET_ALL, getAllSponsors);

app.get(routes.ONBOARDING, onboardingController.getForm);
app.get(routes.ONBOARDING_API, onboardingController.getFormApi);

app.post(
routes.ONBOARDING_ACTION,
checkSchema(onboardingController.postFormSchema),
onboardingController.postOnboardingForm
);
app.post(
routes.ONBOARDING_ACTION_API,
checkSchema(onboardingController.postFormSchema),
express.json({ type: '*/*' }),
onboardingController.postOnboardingFormApi
);
app.get('/onboardingSuccess/:prNumber', onboardingController.getConfirmation);

app.get('/resources', resourceController.getResources);
app.get('/api/get-users-location', mapController.getUsersLocation);
app.get('/map', mapController.getMap);
app.post(
'/hook/:hookId',
express.json({ type: '*/*' }),
Expand Down
9 changes: 9 additions & 0 deletions src/routes/map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import express from 'express';
import * as mapController from '@controllers/mapController';

const router = express.Router();

router.get('/api/get-users-location', mapController.getUsersLocation);
router.get('/map', mapController.getMap);

export { router as mapRouter };
28 changes: 28 additions & 0 deletions src/routes/onboarding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import express from 'express';
import { checkSchema } from 'express-validator';

import * as onboardingController from '@controllers/onboardingController';
import routes from './routes';

const router = express.Router();

router.get(routes.ONBOARDING, onboardingController.getForm);
router.get(routes.ONBOARDING_API, onboardingController.getFormApi);

router.post(
routes.ONBOARDING_ACTION,
checkSchema(onboardingController.postFormSchema),
onboardingController.postOnboardingForm
);
router.post(
routes.ONBOARDING_ACTION_API,
checkSchema(onboardingController.postFormSchema),
express.json({ type: '*/*' }),
onboardingController.postOnboardingFormApi
);
router.get(
'/onboardingSuccess/:prNumber',
onboardingController.getConfirmation
);

export { router as onboardingRouter };

0 comments on commit c0c7d0f

Please sign in to comment.