Skip to content

Instantly share code, notes, and snippets.

@malavsoni
Created May 3, 2020 12:53
Show Gist options
  • Save malavsoni/9b21dbfd14f26dd21bf4a00e572aa6b7 to your computer and use it in GitHub Desktop.
Save malavsoni/9b21dbfd14f26dd21bf4a00e572aa6b7 to your computer and use it in GitHub Desktop.
Startup config for Node JS app.
const mongoose = require("mongoose");
module.exports = function () {
const result = mongoose.connect("mongodb://localhost/app", {
useNewUrlParser: true,
useUnifiedTopology: true,
});
result
.then((response) => {
console.log("Connection Established" + response);
})
.catch((error) => {
console.log("Failed to connect with error " + error);
});
};
const express = require("express");
const user = require("../routes/users");
module.exports = function (app) {
app.use(express.json());
app.use("/api/user", user);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment