diff --git a/.gitignore b/.gitignore
index b512c09..e05de24 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
-node_modules
\ No newline at end of file
+/node_modules
+npm-debug.log
+.DS_Store
+/*.env
\ No newline at end of file
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..7170736
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web:node app.js
diff --git a/README.md b/README.md
index 43ab11d..4266a30 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@
Explore the docs »
- View Demo
+ View Demo
·
Report Bug
·
diff --git a/server.js b/server.js
index f93eef6..0b777bb 100644
--- a/server.js
+++ b/server.js
@@ -6,23 +6,25 @@ const app = express()
mongoose.connect('mongodb://localhost/urlShortener',{
useNewUrlParser: true,
useUnifiedTopology: true
-})
+}).then(data=>{
+ console.log("DB connected");
+}).catch(err=>console.log(err))
app.set('view engine', 'ejs')
app.use(express.urlencoded({ extended: false }))
app.get('/', async (req, res) => {
- const shortUrls = await ShortUrl.find()
+ const shortUrls = await ShortUrl.find().catch(err=>console.log(err))
res.render('index', { shortUrls: shortUrls })
})
app.post('/shortUrls', async (req, res) => {
- await ShortUrl.create({ full: req.body.fullUrl })
+ await ShortUrl.create({ full: req.body.fullUrl }).catch(err=>console.log(err))
res.redirect('/')
})
app.get('/:shortUrl', async(req, res) =>{
- const shortUrl = await ShortUrl.findOne({ short: req.params.shortUrl })
+ const shortUrl = await ShortUrl.findOne({ short: req.params.shortUrl }).catch(err=>console.log(err))
if(shortUrl == null) return res.sendStatus(404)
shortUrl.clicks++