feat: add cors middleware

This commit is contained in:
2022-07-15 11:08:20 +05:30
parent 656c95519d
commit e0d867fe30
4 changed files with 33 additions and 6 deletions

View File

@ -4,6 +4,7 @@ import BinRouter from "./routes/bin";
import { Client, Pool } from "pg";
import { createDataDir, errorHandler, logError, logSuccess } from "./utils";
import { tableExists, populateDB } from "./db";
import cors from "cors";
const main = async () => {
dotenv.config();
@ -33,8 +34,12 @@ const main = async () => {
const app: Express = express();
const port = process.env.PORT;
// FIX: other bodies panic
app.use(express.text());
// check more on this later
app.use(cors());
app.get("/", (req: Request, res: Response) => {
res.send("Hello, World!");
});

View File

@ -1,11 +1,10 @@
import { Router, Request, Response, NextFunction } from "express";
import { Pool, QueryResult } from "pg";
import path from "path";
import { Word } from "../utils/types";
import { Request, Response, Router } from "express";
import fsp from "fs/promises";
import { getPastePath, projectRoot } from "../utils";
import path from "path";
import { Pool } from "pg";
import { getAvailableWord, getWordFromVal, setWordTaken } from "../db/bin";
import { getPackedSettings } from "http2";
import { getPastePath, projectRoot } from "../utils";
import { Word } from "../utils/types";
export default function BinRouter(db: Pool) {
const router: Router = Router();