Skip to content

Instantly share code, notes, and snippets.

@Lahirutech
Last active June 5, 2022 13:56
Show Gist options
  • Save Lahirutech/810f1e5489c83f7893906c37cb3065e5 to your computer and use it in GitHub Desktop.
Save Lahirutech/810f1e5489c83f7893906c37cb3065e5 to your computer and use it in GitHub Desktop.
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose = require("mongoose")
//importing the profile route
const profileRoutes=require('./routers/profile')
app.use(cors());
app.use(express.json());
require("dotenv").config({ path: "./config.env" });
const port = process.env.PORT || 5001;
//app.get('/ping', (req, res) => res.send('pong'))
//using the route
app.use('/',profileRoutes)
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