add cors to API
Unit Tests with docker compose / unit-test (push) Successful in 26s Details

This commit is contained in:
Alie 2024-04-21 13:27:58 +02:00
parent 54cc8c106d
commit 75a02051fa
4 changed files with 28 additions and 4 deletions

BIN
bun.lockb

Binary file not shown.

View File

@ -4,6 +4,8 @@
"type": "module", "type": "module",
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^8.3.1", "@faker-js/faker": "^8.3.1",
"@types/compression": "^1.7.5",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/express-list-endpoints": "^6.0.3", "@types/express-list-endpoints": "^6.0.3",
"@types/jest": "^29.5.11", "@types/jest": "^29.5.11",
@ -13,7 +15,6 @@
"enforce-unique": "^1.2.0", "enforce-unique": "^1.2.0",
"jest": "^29.7.0", "jest": "^29.7.0",
"supertest": "^6.3.3", "supertest": "^6.3.3",
"@types/compression": "^1.7.5",
"ts-jest": "^29.1.1" "ts-jest": "^29.1.1"
}, },
"peerDependencies": { "peerDependencies": {
@ -25,6 +26,7 @@
}, },
"dependencies": { "dependencies": {
"compression": "^1.7.4", "compression": "^1.7.4",
"cors": "^2.8.5",
"express": "^4.18.2", "express": "^4.18.2",
"express-list-endpoints": "^6.0.0", "express-list-endpoints": "^6.0.0",
"jsonwebtoken": "^9.0.2", "jsonwebtoken": "^9.0.2",

View File

@ -5,11 +5,13 @@ import authControler from "./controllers/AuthControler";
import mongoose from "mongoose"; import mongoose from "mongoose";
import compression from "compression"; import compression from "compression";
import logger from "./logger"; import logger from "./logger";
import cors from "cors";
export const app = express(); export const app = express();
app.use(express.json()); app.use(express.json());
app.use(compression()); app.use(compression());
app.use(cors());
app.get("/", (_, res) => { app.get("/", (_, res) => {
const endpoints = listEndpoints(app); const endpoints = listEndpoints(app);
@ -40,7 +42,7 @@ export const startApp = async () => {
); );
process.on("SIGTERM", () => { process.on("SIGTERM", () => {
server.close(() => { server.close(() => {
logger.info('Server closed'); logger.info("Server closed");
process.exit(0); process.exit(0);
}); });
}); });

View File

@ -1,6 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1 # yarn lockfile v1
# bun ./bun.lockb --hash: 0566846CEF9BC37B-67668f8ef100cf47-BD54633F277319ED-f974ac5408e619f6 # bun ./bun.lockb --hash: 187C900AA2FDC0D7-cda284a65763ca6b-2E28784E3E5940CD-f3773b98a4f59cda
"@ampproject/remapping@^2.2.0": "@ampproject/remapping@^2.2.0":
@ -643,6 +643,13 @@
resolved "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz" resolved "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.5.tgz"
integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q== integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==
"@types/cors@^2.8.17":
version "2.8.17"
resolved "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz"
integrity sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==
dependencies:
"@types/node" "*"
"@types/express@*", "@types/express@^4.17.21": "@types/express@*", "@types/express@^4.17.21":
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"
@ -1251,6 +1258,14 @@ cookiejar@^2.1.4:
resolved "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz" resolved "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz"
integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw== integrity sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==
cors@^2.8.5:
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"
create-jest@^29.7.0: create-jest@^29.7.0:
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"
@ -2534,6 +2549,11 @@ npm-run-path@^4.0.1:
dependencies: dependencies:
path-key "^3.0.0" path-key "^3.0.0"
object-assign@^4:
version "4.1.1"
resolved "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==
object-inspect@^1.9.0: object-inspect@^1.9.0:
version "1.13.1" version "1.13.1"
resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz" resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz"
@ -3151,7 +3171,7 @@ v8-to-istanbul@^9.0.1:
"@types/istanbul-lib-coverage" "^2.0.1" "@types/istanbul-lib-coverage" "^2.0.1"
convert-source-map "^2.0.0" convert-source-map "^2.0.0"
vary@~1.1.2: vary@^1, vary@~1.1.2:
version "1.1.2" version "1.1.2"
resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz" resolved "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz"
integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==