diff --git a/.gitignore b/.gitignore index dbf0821..ea59b81 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -node_modules/* \ No newline at end of file +src/node_modules/ diff --git a/src/package-lock.json b/src/package-lock.json index 7e48d72..746d138 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -1,5 +1,5 @@ { - "name": "secrets", + "name": "src", "lockfileVersion": 3, "requires": true, "packages": { @@ -8,6 +8,7 @@ "@types/ejs": "^3.1.5", "@types/express": "^4.17.21", "@types/uuid": "^9.0.7", + "cors": "^2.8.5", "crypto": "^1.0.1", "ejs": "^3.1.9", "express": "^4.18.2", @@ -16,6 +17,9 @@ "ts-node": "^10.9.2", "typescript": "^5.3.3", "uuid": "^9.0.1" + }, + "devDependencies": { + "@types/cors": "^2.8.17" } }, "node_modules/@cspotcode/source-map-support": { @@ -93,6 +97,15 @@ "@types/node": "*" } }, + "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/ejs": { "version": "3.1.5", "resolved": "https://registry.npmjs.org/@types/ejs/-/ejs-3.1.5.tgz", @@ -447,6 +460,18 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "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-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", @@ -1074,6 +1099,14 @@ "node": ">=0.10.0" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.13.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", diff --git a/src/package.json b/src/package.json index cc95f97..bcedc47 100644 --- a/src/package.json +++ b/src/package.json @@ -3,6 +3,7 @@ "@types/ejs": "^3.1.5", "@types/express": "^4.17.21", "@types/uuid": "^9.0.7", + "cors": "^2.8.5", "crypto": "^1.0.1", "ejs": "^3.1.9", "express": "^4.18.2", @@ -16,5 +17,8 @@ "dev": "cd src && nodemon --exec ts-node server.ts", "build": "tsc -p . && cp -r pages dist/ && cp -r public dist/", "start": "cd dist && node server.js" + }, + "devDependencies": { + "@types/cors": "^2.8.17" } } diff --git a/src/server.ts b/src/server.ts index 04f26fb..884a61a 100644 --- a/src/server.ts +++ b/src/server.ts @@ -2,9 +2,15 @@ import express, { type Request, type Response } from "express"; import { v4 as uuidv4 } from "uuid"; -import { encryptText, decryptText, validateRequestBody, RedisWrapper } from "./utils"; +import { + encryptText, + decryptText, + validateRequestBody, + RedisWrapper, +} from "./utils"; import { notFoundHandler, errorHandler } from "./middleware"; import config from "./config"; +import cors from "cors"; interface Secret { id: string; @@ -14,6 +20,7 @@ interface Secret { const app = express(); +app.use(cors({ origin: "*" })); app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.use(express.static("public"));