#1, подключила базу, настроила сервер

parent 6dced87a
const path = require("path");
const rootPath = __dirname;
module.exports = {
rootPath,
uploadPath: path.join(rootPath, "public", "uploads"),
db: {
name: "shop",
url: "mongodb://localhost"
}
};
const express = require("express");
const cors = require("cors");
const mongoose = require("mongoose");
const products = require("./app/products");
const categories = require("./app/categories");
const users = require("./app/users");
const config = require("./config");
const app = express();
const PORT = 8000;
app.use(cors());
app.use(express.static("public"));
app.use(express.json());
mongoose.connect(`${config.db.url}/${config.db.name}`, {useNewUrlParser: true})
.then(() => {
console.log("Mongoose connected!");
app.use("/products", products());
app.use("/categories", categories());
app.use("/users", users());
app.listen(PORT, () => {
console.log("Server started at http://localhost:" + PORT);
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment