Skip to content

Commit

Permalink
add default route
Browse files Browse the repository at this point in the history
  • Loading branch information
shobhamrj committed May 21, 2023
1 parent 825f466 commit 0806935
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions controllers/urlController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const crypto = require('crypto');
const URL = require('../models/URL')

const redirectToDocs = (req, res) => {
return res.redirect('/api-docs')
}
const hashUrl = async (req, res) => {
const longURL = req.body.url;
if (!longURL) {
Expand Down Expand Up @@ -38,6 +41,7 @@ const getUrl = async (req, res) => {
}

module.exports = {
redirectToDocs,
hashUrl,
getUrl
}
13 changes: 7 additions & 6 deletions routes/urlRoutes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const express = require('express');
const {hashUrl, getUrl} = require('../controllers/urlController');
const express = require('express')
const {redirectToDocs, hashUrl, getUrl} = require('../controllers/urlController')

const router = express.Router();
const router = express.Router()

router.post('/api/hash-url', hashUrl);
router.get('/api/hash-url/:id', getUrl);
router.post('/api/hash-url', hashUrl)
router.get('/api/hash-url/:id', getUrl)
router.get('/', redirectToDocs)

module.exports = router;
module.exports = router

0 comments on commit 0806935

Please sign in to comment.