backend project
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import cors from "cors";
|
||||
import express from "express";
|
||||
|
||||
import todosRoutes from "./routes/todos/todos.routes";
|
||||
import authRoutes from "./routes/auth/auth.routes";
|
||||
import usersRoutes from "./routes/users/users.routes";
|
||||
import searchRoutes from "./routes/search/search.routes";
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 5000;
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
origin: true,
|
||||
methods: ["GET", "POST", "PUT", "DELETE"],
|
||||
allowedHeaders: ["Content-Type", "Authorization"],
|
||||
credentials: true,
|
||||
})
|
||||
);
|
||||
|
||||
app.use(express.json());
|
||||
|
||||
app.use("/api/auth", authRoutes);
|
||||
app.use("/api/todos", todosRoutes);
|
||||
app.use("/api/users", usersRoutes);
|
||||
app.use("/api/search", searchRoutes);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server started on port ${port}`);
|
||||
});
|
||||
Reference in New Issue
Block a user