CoastalCommitsPastes/server/src/app.ts

31 lines
667 B
TypeScript
Raw Normal View History

2022-03-24 14:57:40 -07:00
import * as express from "express"
import * as bodyParser from "body-parser"
import * as errorhandler from "strong-error-handler"
import * as cors from "cors"
import { posts, users, auth, files } from "@routes/index"
import { errors } from "celebrate"
2022-03-06 16:46:59 -08:00
2022-03-24 14:57:40 -07:00
export const app = express()
2022-03-06 16:46:59 -08:00
2022-03-24 14:57:40 -07:00
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json({ limit: "5mb" }))
2022-03-06 16:46:59 -08:00
const corsOptions = {
2022-03-24 14:57:40 -07:00
origin: `http://localhost:3001`
}
app.use(cors(corsOptions))
2022-03-06 16:46:59 -08:00
app.use("/auth", auth)
2022-03-06 16:46:59 -08:00
app.use("/posts", posts)
app.use("/users", users)
app.use("/files", files)
2022-03-06 16:46:59 -08:00
2022-03-24 14:57:40 -07:00
app.use(errors())
2022-03-24 14:53:57 -07:00
2022-03-24 14:57:40 -07:00
app.use(
errorhandler({
debug: process.env.ENV !== "production",
log: true
})
)