Pass your original URL and get a shortened version of it.
The application is built on MERN stack. Node.js, Express as server and MongoDB for database. Client side code is written in React and the backend API is written using Express. Used Create React App boilerplate to get started.
This is a simple full stack React application with a Node.js and Express backend. Client side code is written in React and the backend API is written using Express. This application is configured with Airbnb's ESLint rules and formatted through prettier.
- NodeJS (12.0+)
- ExpressJS
- NPM latest.
- nodemon - For auto start
- config - Configuring dev and production setups
- mongoose - MongoDB object modeling tool
- valid-url - Validating URLs
- React-Toastify - Showing toast messages
- axios - XHR requests
# Clone the repository
git clone https://github.com/Sudharshaun/url-shortner.git
# Go inside the directory
cd url-shortener
# Install dependencies
yarn (or npm install)
# Start development server
yarn dev (or npm run dev)
# Build for production
yarn build (or npm run build)
# Start production server
yarn start (or npm start)
All the source code will be inside src directory. Inside src, there is client and server directory. All the frontend code (react, css, js and any other assets) will be in client directory. Backend Node.js/Express code will be in the server directory.
- /api/getAllUrls (GET) - Fetches all the URLs saved in the DB
- /api/:shortUrl (GET) - Called when Short URL is hit. (In URL bar, usually)
- /api/shorturl (POST) - Validates the given URL and generates a short URL then saves it in DB.