Skip to content

Commit

Permalink
chore: Update package dependencies and add CORS support
Browse files Browse the repository at this point in the history
  • Loading branch information
devfxx committed Jul 13, 2024
1 parent dc968a6 commit 9793947
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules/*
src/node_modules/
35 changes: 34 additions & 1 deletion src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
}
9 changes: 8 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
Expand Down

0 comments on commit 9793947

Please sign in to comment.