From 9c47a9d5f78a6d5ca980804179e6628fc2760d62 Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 08:38:53 +0545 Subject: [PATCH 1/6] added procfile --- .gitignore | 5 ++++- Procfile | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Procfile 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 From a535ffd2d3b592714a00a5fed7772332ed8abe2e Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 08:48:47 +0545 Subject: [PATCH 2/6] catch connection --- server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index f93eef6..df9c5d0 100644 --- a/server.js +++ b/server.js @@ -6,7 +6,9 @@ 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 })) From a1ba29bd500c330116d399a4daeca478c6f81fb7 Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 08:58:56 +0545 Subject: [PATCH 3/6] catch connection --- server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server.js b/server.js index df9c5d0..0b777bb 100644 --- a/server.js +++ b/server.js @@ -14,17 +14,17 @@ 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++ From d61fb5abbeaf35256d1bf326cdc2ecc540a9c13e Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 09:02:17 +0545 Subject: [PATCH 4/6] catch connection --- views/index.ejs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/index.ejs b/views/index.ejs index 6e49619..4339c3e 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -23,13 +23,13 @@ - <% shortUrls.forEach(shortUrl => { %> + From 43ce21468772c81bfe9b61d65a625d6bb4ef71fa Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 09:03:51 +0545 Subject: [PATCH 5/6] catch connection --- views/index.ejs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/views/index.ejs b/views/index.ejs index 4339c3e..0aef06a 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -23,13 +23,7 @@ - + From 262a0858a702f317f171a22796c4cd6e3dcc562d Mon Sep 17 00:00:00 2001 From: bipinparajuli Date: Sun, 31 Oct 2021 18:43:32 +0545 Subject: [PATCH 6/6] deployed --- README.md | 2 +- views/index.ejs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) 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/views/index.ejs b/views/index.ejs index 0aef06a..6e49619 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -23,7 +23,13 @@ - + <% shortUrls.forEach(shortUrl => { %> + + <%= shortUrl.full %> + <%= shortUrl.short %> + <%= shortUrl.clicks %> + + <% }) %>