source: backend/server.js@ 717ceae

Last change on this file since 717ceae was 717ceae, checked in by Nace Gjorgjievski <nace.gorgievski123@…>, 2 years ago

connected db

  • Property mode set to 100644
File size: 624 bytes
Line 
1import express from "express";
2import data from "./data.js";
3import mongoose from "mongoose";
4import dotenv from "dotenv";
5import seedRouter from "./routes/seedRoutes.js";
6import productRouter from "./routes/productRoutes.js";
7
8dotenv.config();
9
10mongoose
11 .connect(process.env.MONGODB_URI)
12 .then(() => {
13 console.log("connected to db");
14 })
15 .catch((err) => {
16 console.log(err.message);
17 });
18
19const app = express();
20app.use("/api/seed", seedRouter);
21app.use("/api/products", productRouter);
22
23const port = process.env.PORT || 5000;
24app.listen(port, () => {
25 console.log(`serve at http://localhost:${port}`);
26});
Note: See TracBrowser for help on using the repository browser.