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 | |
---|
1 | import express from "express";
|
---|
2 | import data from "./data.js";
|
---|
3 | import mongoose from "mongoose";
|
---|
4 | import dotenv from "dotenv";
|
---|
5 | import seedRouter from "./routes/seedRoutes.js";
|
---|
6 | import productRouter from "./routes/productRoutes.js";
|
---|
7 |
|
---|
8 | dotenv.config();
|
---|
9 |
|
---|
10 | mongoose
|
---|
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 |
|
---|
19 | const app = express();
|
---|
20 | app.use("/api/seed", seedRouter);
|
---|
21 | app.use("/api/products", productRouter);
|
---|
22 |
|
---|
23 | const port = process.env.PORT || 5000;
|
---|
24 | app.listen(port, () => {
|
---|
25 | console.log(`serve at http://localhost:${port}`);
|
---|
26 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.