connection to mongodb

using mongoose, no schema yet.
This commit is contained in:
Sunny Dhoke
2020-10-08 11:49:58 +05:30
parent 1a541097da
commit d5c8e8fe04
3 changed files with 13 additions and 3 deletions

View File

@@ -14,7 +14,7 @@
<body>
<div class="container">
<h1>URL Shortner</h1>
<form action="" method="POST" class="my-4 form-inline">
<form action="shortUrls" method="POST" class="my-4 form-inline">
<label for="fullurl" class="sr-only">URL</label>
<input
required

1
models/README.md Normal file
View File

@@ -0,0 +1 @@
model to store all the urls and information

View File

@@ -1,16 +1,25 @@
//web framework
const express = require("express");
//make basic app
//create basic app
const app = express();
//setting ejs as view engine
app.set("view engine", "ejs");
// to connect to database
const mongoose = require("mongoose");
mongoose.connect("mongodb://localhost/urlShortner", {
useNewUrlParser: true,
useUnifiedTopology: true,
});
//get
// index page with request and response parameters
app.get("/", (req, res) => {
res.render("index");
});
//post
app.post("/shortUrls", (req, res) => {});
// start listening on specified port
app.listen(process.env.PORT || 4567);