Skip to content

Instantly share code, notes, and snippets.

@tgmarinho
Last active September 11, 2020 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tgmarinho/3a38d50190da5f36c8f13b1005be9369 to your computer and use it in GitHub Desktop.
Save tgmarinho/3a38d50190da5f36c8f13b1005be9369 to your computer and use it in GitHub Desktop.
require("dotenv").config();
const express = require("express");
const morgan = require("morgan");
const mongoose = require("mongoose");
const path = require("path");
const cors = require("cors");
const app = express();
/**
* Database setup
*/
mongoose.connect(
process.env.MONGO_URL,
{
useNewUrlParser: true
}
);
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(morgan("dev"));
app.use(
"/files",
express.static(path.resolve(__dirname, "..", "tmp", "uploads"))
);
app.use(require("./routes"));
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment