@@ -2,26 +2,26 @@ import health from "@cloudnative/health-connect";
22import cors from "cors" ;
33import express from "express" ;
44import "express-async-errors" ;
5- import path from "path" ;
65import * as OAV from "express-openapi-validator" ;
76import multer from "multer" ;
7+ import path from "path" ;
88import YAML from "yamljs" ;
9- import { authenticate } from "./commons/middlewares/authenticate.middlewares" ;
10- import { handleErrors } from "./commons/middlewares/handle-errors.middlewares" ;
11-
129import annuaireRoutes from "./annuaire/annuaire.routes" ;
1310import apiKeysRoutes from "./apikeys/apikeys.routes" ;
1411import assetsRoutes from "./assets/assets.routes" ;
1512import authRoutes from "./auth/auth.routes" ;
1613import categoriesRoutes from "./categories/categories.routes" ;
14+ import { authenticate } from "./commons/middlewares/authenticate.middlewares" ;
15+ import { handleErrors } from "./commons/middlewares/handle-errors.middlewares" ;
1716import {
18- forbidReadersToWrite ,
19- requireAuth ,
17+ forbidReadersToWrite ,
18+ requireAuth ,
2019} from "./commons/middlewares/rbac.middlewares" ;
2120import contactRoutes from "./contacts/contacts.routes" ;
2221import curiexploreRoutes from "./curiexplore/curiexplore.routes" ;
2322import documentTypesRoutes from "./document-types/document-types.routes" ;
2423import documentsRoutes from "./documents/documents.routes" ;
24+ import domainsRoutes from "./domains/domains.routes" ;
2525import emailTypesRoutes from "./email-types/email-types.routes" ;
2626import followUpsRoutes from "./followups/followups.routes" ;
2727import geographicalcategoriesRoutes from "./geographicalcategories/geographicalcategories.routes" ;
@@ -38,17 +38,17 @@ import personsRoutes from "./persons/persons.routes";
3838import pressRoutes from "./press/press.routes" ;
3939import prizesRoutes from "./prizes/prizes.routes" ;
4040import projectsRoutes from "./projects/projects.routes" ;
41- import relationsGroupsRoutes from "./relations-groups/relations-groups.routes" ;
4241import relationsRoutes from "./relations/relations.routes" ;
42+ import relationsGroupsRoutes from "./relations-groups/relations-groups.routes" ;
4343import relationTypesRoutes from "./relationtypes/relationtypes.routes" ;
4444import searchRoutes from "./search/search.routes" ;
4545import sireneRoutes from "./sirene/sirene.routes" ;
4646import structuresRoutes from "./structures/structures.routes" ;
4747import supervisingMinistersRoutes from "./supervising-ministers/supervising-ministers.routes" ;
4848import termsRoutes from "./terms/terms.routes" ;
4949import usersRoutes from "./users/users.routes" ;
50- import weblinksRoutes from "./weblinks/weblinks.routes" ;
5150import utilitiesRoutes from "./utilities.routes" ;
51+ import weblinksRoutes from "./weblinks/weblinks.routes" ;
5252
5353// Load API specifications
5454const apiSpec = path . join ( path . resolve ( ) , "docs/reference/api.yml" ) ;
@@ -60,26 +60,26 @@ app.use(express.json());
6060app . use ( express . urlencoded ( { extended : false } ) ) ;
6161app . disable ( "x-powered-by" ) ;
6262if ( process . env . NODE_ENV === "development" ) {
63- app . use (
64- cors ( {
65- origin : "*" ,
66- methods : [ "GET" , "POST" , "PUT" , "PATCH" , "DELETE" , "OPTIONS" ] ,
67- } ) ,
68- ) ;
63+ app . use (
64+ cors ( {
65+ origin : "*" ,
66+ methods : [ "GET" , "POST" , "PUT" , "PATCH" , "DELETE" , "OPTIONS" ] ,
67+ } ) ,
68+ ) ;
6969}
7070app . set ( "trust proxy" , [ "loopback" , "linklocal" , "uniquelocal" ] ) ;
7171
7272// Health checker
7373const healthcheck = new health . HealthChecker ( ) ;
7474const isReady = async ( expressApp ) => {
75- if ( ! expressApp . isReady ) {
76- throw new Error ( "App in not running yet." ) ;
77- }
78- return "Listening to requests" ;
75+ if ( ! expressApp . isReady ) {
76+ throw new Error ( "App in not running yet." ) ;
77+ }
78+ return "Listening to requests" ;
7979} ;
8080const liveCheck = new health . LivenessCheck ( "LivenessCheck" , ( ) => isReady ( app ) ) ;
8181const readyCheck = new health . ReadinessCheck ( "ReadinessCheck" , ( ) =>
82- isReady ( app ) ,
82+ isReady ( app ) ,
8383) ;
8484healthcheck . registerLivenessCheck ( liveCheck ) ;
8585healthcheck . registerReadinessCheck ( readyCheck ) ;
@@ -89,29 +89,29 @@ app.use("/readyz", health.ReadinessEndpoint(healthcheck));
8989// Expose swagger API documentation
9090const { schemas } = apiDocument . components ;
9191app . get ( "/docs/specs" , ( req , res ) => {
92- res . status ( 200 ) . json ( apiDocument ) ;
92+ res . status ( 200 ) . json ( apiDocument ) ;
9393} ) ;
9494app . get ( "/docs/enums" , ( req , res ) => {
95- res
96- . status ( 200 )
97- . json (
98- Object . fromEntries (
99- Object . entries ( schemas ) . filter ( ( [ key ] ) => key . match ( / E n u m $ / ) ) ,
100- ) ,
101- ) ;
95+ res
96+ . status ( 200 )
97+ . json (
98+ Object . fromEntries (
99+ Object . entries ( schemas ) . filter ( ( [ key ] ) => key . match ( / E n u m $ / ) ) ,
100+ ) ,
101+ ) ;
102102} ) ;
103103
104104// express-openapi-validator setup to validate requests
105105app . use (
106- OAV . middleware ( {
107- apiSpec,
108- validateRequests : {
109- removeAdditional : true ,
110- } ,
111- validateResponses : true ,
112- fileUploader : { storage : multer . memoryStorage ( ) } ,
113- ignoreUndocumented : true ,
114- } ) ,
106+ OAV . middleware ( {
107+ apiSpec,
108+ validateRequests : {
109+ removeAdditional : true ,
110+ } ,
111+ validateResponses : true ,
112+ fileUploader : { storage : multer . memoryStorage ( ) } ,
113+ ignoreUndocumented : true ,
114+ } ) ,
115115) ;
116116
117117// Authenticate currentUser
@@ -131,6 +131,7 @@ app.use(contactRoutes);
131131app . use ( curiexploreRoutes ) ;
132132app . use ( documentsRoutes ) ;
133133app . use ( documentTypesRoutes ) ;
134+ app . use ( domainsRoutes ) ;
134135app . use ( emailTypesRoutes ) ;
135136app . use ( followUpsRoutes ) ;
136137app . use ( geographicalcategoriesRoutes ) ;
0 commit comments