-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init commit with functioning shortening of url and vice-versa
- Loading branch information
0 parents
commit 5cd516c
Showing
27 changed files
with
43,068 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
url-shortener-web\node_modules | ||
|
||
config/development.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Full stack app to facilitate the shortening of long urls. | ||
|
||
## More details to be added. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const colors = require('colors') | ||
const mongoose = require('mongoose') | ||
const config = require('config') | ||
|
||
const MONGO_URI = config.get('mongoUri') | ||
|
||
const connectToDB = async () => { | ||
try { | ||
const conn = await mongoose.connect( | ||
MONGO_URI, | ||
{ | ||
useNewUrlParser: true, | ||
useCreateIndex: true, | ||
useUnifiedTopology: true, | ||
} | ||
) | ||
|
||
console.log(`Mongo Atlas connected: ${ conn.connection.host }`.magenta.underline.bold) | ||
} catch (error) { | ||
console.log(`There was an error ${ error.message }`.red.bgWhite.bold) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
module.exports = connectToDB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"baseUrl": "http://localhost:5000", | ||
"mongoUri": "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const mongoose = require('mongoose') | ||
const { nanoid } = require('nanoid') | ||
|
||
const UrlSchema = new mongoose.Schema({ | ||
longUrl: { | ||
type: String, | ||
required: true, | ||
}, | ||
// shortUrl: { // baseUrl + urlId | ||
// type: String, | ||
// required: true, | ||
// }, | ||
urlId: { | ||
type: String, | ||
required: true, | ||
default: nanoid(10), | ||
}, | ||
}) | ||
|
||
module.exports = mongoose.model('Url', UrlSchema) |
Oops, something went wrong.