From 91d90738e7102f0eb07fbf9f10225edd4e6e0c34 Mon Sep 17 00:00:00 2001 From: Lucas Charrier Date: Mon, 15 Jan 2024 16:41:13 +0100 Subject: [PATCH] refacto(startups.ts): add startups router --- src/index.ts | 35 ++--------------------------------- src/routes/startups.ts | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 src/routes/startups.ts diff --git a/src/index.ts b/src/index.ts index b4a7625bd..509e508c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,7 +18,6 @@ import * as logoutController from '@controllers/logoutController'; import * as newsletterController from '@controllers/newsletterController'; import * as onboardingController from '@controllers/onboardingController'; import * as resourceController from '@controllers/resourceController'; -import * as startupController from '@controllers/startupController'; import * as mapController from '@controllers/mapController'; import * as hookController from '@controllers/hookController'; import * as pullRequestsController from '@controllers/pullRequestsController'; @@ -29,11 +28,6 @@ import { MARRAINAGE_EVENTS_VALUES } from '@models/marrainage'; import routes from './routes/routes'; import permit, { MemberRole } from './middlewares/authorization'; import { rateLimiter } from './middlewares/rateLimiter'; -import { - getStartupInfoUpdate, - getStartupInfoUpdateApi, - postStartupInfoUpdate, -} from './controllers/startupController'; import { postBadgeRequest } from './controllers/badgeRequestsController/postBadgeRequest'; import { updateBadgeRenewalRequestStatus, @@ -43,14 +37,11 @@ import makeSessionStore from './infra/sessionStore/sessionStore'; import { getJwtTokenForUser, getToken } from '@/helpers/session'; import getAllIncubators from './controllers/incubatorController/api/getAllIncubators'; import getAllSponsors from './controllers/sponsorController/api/getAllSponsors'; -import { - getStartupInfoCreate, - getStartupInfoCreateApi, -} from './controllers/startupController/getStartupInfoCreate'; import { postBadgeRenewalRequest } from './controllers/badgeRequestsController/postBadgeRenewalRequest'; import { userRouter, userApiRouter, userPublicApiRouter } from './routes/users'; import { marrainageRouter } from './routes/marrainage'; import { accountRouter } from './routes/account'; +import { startupRouter } from './routes/startups'; export const app = express(); app.set('trust proxy', 1); @@ -244,6 +235,7 @@ app.use(userApiRouter); app.use(userPublicApiRouter); app.use(marrainageRouter); app.use(accountRouter); +app.use(startupRouter); // que ce passe-t-il app.get( @@ -299,29 +291,6 @@ app.get(routes.API_PUBLIC_INCUBATORS_GET_ALL, getAllIncubators); //sponsors app.get(routes.API_PUBLIC_SPONSORS_GET_ALL, getAllSponsors); -// STARTUP -app.get(routes.STARTUP_GET_INFO_CREATE_FORM, getStartupInfoCreate); -app.get(routes.STARTUP_GET_INFO_CREATE_FORM_API, getStartupInfoCreateApi); - -app.get(routes.STARTUP_GET_ALL, startupController.getStartupList); -app.get(routes.STARTUP_GET_ALL_API, startupController.getStartupListApi); - -app.get(routes.STARTUP_GET_DETAIL, startupController.getStartup); -app.get(routes.STARTUP_GET_DETAIL_API, startupController.getStartupApi); -app.get(routes.STARTUP_GET_INFO_UPDATE_FORM, getStartupInfoUpdate); -app.get(routes.STARTUP_GET_INFO_UPDATE_FORM_API, getStartupInfoUpdateApi); - -app.post( - routes.STARTUP_POST_INFO_UPDATE_FORM, - express.json({ type: '*/*' }), - postStartupInfoUpdate -); -app.post( - routes.STARTUP_POST_INFO_CREATE_FORM, - express.json({ type: '*/*' }), - postStartupInfoUpdate -); - // ONLY FOR ADMIN app.get( routes.ADMIN_MATTERMOST, diff --git a/src/routes/startups.ts b/src/routes/startups.ts new file mode 100644 index 000000000..38317349f --- /dev/null +++ b/src/routes/startups.ts @@ -0,0 +1,37 @@ +import express from 'express'; +import routes from './routes'; +import { + getStartupInfoCreate, + getStartupInfoCreateApi, +} from '@/controllers/startupController/getStartupInfoCreate'; +import * as startupController from '@controllers/startupController'; +import { + getStartupInfoUpdate, + getStartupInfoUpdateApi, +} from '@controllers/startupController'; + +const router = express.Router(); +// STARTUP +router.get(routes.STARTUP_GET_INFO_CREATE_FORM, getStartupInfoCreate); +router.get(routes.STARTUP_GET_INFO_CREATE_FORM_API, getStartupInfoCreateApi); + +router.get(routes.STARTUP_GET_ALL, startupController.getStartupList); +router.get(routes.STARTUP_GET_ALL_API, startupController.getStartupListApi); + +router.get(routes.STARTUP_GET_DETAIL, startupController.getStartup); +router.get(routes.STARTUP_GET_DETAIL_API, startupController.getStartupApi); +router.get(routes.STARTUP_GET_INFO_UPDATE_FORM, getStartupInfoUpdate); +router.get(routes.STARTUP_GET_INFO_UPDATE_FORM_API, getStartupInfoUpdateApi); + +router.post( + routes.STARTUP_POST_INFO_UPDATE_FORM, + express.json({ type: '*/*' }), + startupController.postStartupInfoUpdate +); +router.post( + routes.STARTUP_POST_INFO_CREATE_FORM, + express.json({ type: '*/*' }), + startupController.postStartupInfoUpdate +); + +export { router as startupRouter };