Last change
on this file since 717ceae was 717ceae, checked in by Nace Gjorgjievski <nace.gorgievski123@…>, 23 months ago |
connected db
|
-
Property mode
set to
100644
|
File size:
624 bytes
|
Rev | Line | |
---|
[b612ab1] | 1 | import express from "express";
|
---|
| 2 | import data from "./data.js";
|
---|
[717ceae] | 3 | import mongoose from "mongoose";
|
---|
| 4 | import dotenv from "dotenv";
|
---|
| 5 | import seedRouter from "./routes/seedRoutes.js";
|
---|
| 6 | import productRouter from "./routes/productRoutes.js";
|
---|
[b612ab1] | 7 |
|
---|
[717ceae] | 8 | dotenv.config();
|
---|
[b612ab1] | 9 |
|
---|
[717ceae] | 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 | });
|
---|
[b612ab1] | 18 |
|
---|
[717ceae] | 19 | const app = express();
|
---|
| 20 | app.use("/api/seed", seedRouter);
|
---|
| 21 | app.use("/api/products", productRouter);
|
---|
[b612ab1] | 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.