mirror of
https://github.com/SrIzan10/YouRL.git
synced 2026-05-01 11:15:09 +00:00
Added ability to deploy on Heroku
This commit is contained in:
13
README.md
13
README.md
@@ -33,3 +33,16 @@ make sure admin access
|
||||
- to start server
|
||||
|
||||
"C:\Program Files\MongoDB\Server\4.4\bin\mongo.exe"
|
||||
|
||||
## Deploy
|
||||
|
||||
### Heroku
|
||||
|
||||
1. Fork this repository
|
||||
1. Create a free Heroku Account
|
||||
1. Create free heroku app with your github fork
|
||||
|
||||
## Roadmap
|
||||
|
||||
- A login Screen
|
||||
- protected routes with JWT
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"description": "A url shortner",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "node ./server.js",
|
||||
"devStart": "nodemon server.js"
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -12,7 +12,9 @@ app.use(express.urlencoded({ extended: false }));
|
||||
|
||||
// to connect to database
|
||||
const mongoose = require("mongoose");
|
||||
mongoose.connect("mongodb://localhost/db", {
|
||||
|
||||
//App deploy or localhost mode connection to MongoDB
|
||||
mongoose.connect(process.env.MONGO_URL || "mongodb://localhost/db", {
|
||||
useNewUrlParser: true,
|
||||
useUnifiedTopology: true,
|
||||
});
|
||||
@@ -46,7 +48,8 @@ app.get("/:shortUrl", async (req, res) => {
|
||||
//otherwise increase the click
|
||||
shortUrl.clicks++;
|
||||
//save the changes in table
|
||||
shortUrl.save();
|
||||
//can use `await` here but speed of redirect is more important
|
||||
await shortUrl.save();
|
||||
|
||||
//redirect the full link corresponding the short url we found
|
||||
res.redirect(shortUrl.full);
|
||||
|
||||
Reference in New Issue
Block a user