Skip to content

Instantly share code, notes, and snippets.

@Lahirutech
Created June 4, 2022 10:54
Show Gist options
  • Select an option

  • Save Lahirutech/1f3b15d3a12cbe7521d6879d4ee16ca2 to your computer and use it in GitHub Desktop.

Select an option

Save Lahirutech/1f3b15d3a12cbe7521d6879d4ee16ca2 to your computer and use it in GitHub Desktop.
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose = require("mongoose")
app.use(cors());
app.use(express.json());
require("dotenv").config({ path: "./config.env" });
const port = process.env.PORT || 5001;
mongoose
.connect(process.env.ATLAS_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("db Connected"));
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment