fix: back add cors
Some checks failed
Build Docker Image Front / run (pull_request) Successful in 25s
Build Docker Image Back / run (pull_request) Successful in 1m8s
JsDocs / coverage (pull_request) Successful in 40s
Test and coverage / coverage (pull_request) Failing after 1m44s

This commit is contained in:
Clement 2024-05-22 14:38:44 +02:00
parent aae4f97ff4
commit 3d9e2b1977
4 changed files with 30 additions and 3 deletions

View File

@ -8,6 +8,7 @@
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/node": "^20.12.7", "@types/node": "^20.12.7",
"axios": "^1.6.8", "axios": "^1.6.8",
"cors": "^2.8.5",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"express": "^4.19.2", "express": "^4.19.2",
"rimraf": "^5.0.5", "rimraf": "^5.0.5",
@ -15,6 +16,7 @@
"swagger-ui-express": "^5.0.0" "swagger-ui-express": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/cors": "^2.8.17",
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/rewire": "^2.5.30", "@types/rewire": "^2.5.30",
"@types/supertest": "^6.0.2", "@types/supertest": "^6.0.2",
@ -1968,6 +1970,15 @@
"integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==", "integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==",
"dev": true "dev": true
}, },
"node_modules/@types/cors": {
"version": "2.8.17",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/express": { "node_modules/@types/express": {
"version": "4.17.21", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
@ -4745,6 +4756,18 @@
"dev": true, "dev": true,
"optional": true "optional": true
}, },
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/create-jest": { "node_modules/create-jest": {
"version": "29.7.0", "version": "29.7.0",
"resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz",
@ -9248,7 +9271,6 @@
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"dev": true,
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }

View File

@ -14,6 +14,7 @@
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/node": "^20.12.7", "@types/node": "^20.12.7",
"axios": "^1.6.8", "axios": "^1.6.8",
"cors": "^2.8.5",
"dotenv": "^16.4.5", "dotenv": "^16.4.5",
"express": "^4.19.2", "express": "^4.19.2",
"rimraf": "^5.0.5", "rimraf": "^5.0.5",
@ -21,6 +22,7 @@
"swagger-ui-express": "^5.0.0" "swagger-ui-express": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/cors": "^2.8.17",
"@types/jest": "^29.5.12", "@types/jest": "^29.5.12",
"@types/rewire": "^2.5.30", "@types/rewire": "^2.5.30",
"@types/supertest": "^6.0.2", "@types/supertest": "^6.0.2",

View File

@ -1,11 +1,13 @@
import { getCity, getRadius, getPoiId, getBox } from "./openTripMaps" import { getCity, getRadius, getPoiId, getBox } from "./openTripMaps"
import express from "express" import express from "express"
import cors from "cors"
/** /**
* Initialize Express application instance. * Initialize Express application instance.
* @returns An initialized Express application object. * @returns An initialized Express application object.
*/ */
const app = express() const app = express()
app.use(cors())
/** /**

View File

@ -135,8 +135,9 @@ export async function getCity(req: express.Request, res: express.Response) {
radius = "1000" radius = "1000"
} }
const cityPose = await callCity(cityName as string) const cityPose = await callCity(cityName as string)
res.send( await callRadius(cityPose.lon,cityPose.lat, radius as string)) const poi = await callRadius(cityPose.lon,cityPose.lat, radius as string)
} res.send( {...poi, ...cityPose})
}//XXX: refaire test avec city
/** /**
* Handle GET request for radius search route ('/otm/radius'). * Handle GET request for radius search route ('/otm/radius').