For development, you will only need Node.js, a node global package, npm, MySQL and Redis installed in your development environment.
-
Visit official Node.js website and download the installer. Also, be sure to have
git
available in your PATH andnpm
(You can find git here). -
You can install nodejs and npm easily with apt install, just run the following commands.
$ sudo apt install nodejs $ sudo apt install npm
-
You can install nodejs and npm easily with brew install, just run the following commands.
$ brew install node
-
Visit MySQL official documentation for installation guide.
-
Visit Redis official website for installation guide.
$ git clone https://github.com/ayodeleoniosun/url-shortener.git
$ cd url-shortener
-
Copy the contents of .env.sample to env -
cp .env.sample .env
-
You can replace the database credentials where necessary
-
Create the database on your local MySQL instance
-
Run the
setup.sh
file in the project root.
If you got a permission error, please runchmod +x setup.sh
to change permission, then try again.
Thesetup.sh
file does the following:- Installs project Dependencies
- Runs the Project Build
- Runs the Database Migration
- Run
npm start
to start the app (app runs on PORT 3000 by default). - Run
npm run dev
to start the app in development mode. - Run
npm test
to run test. - To test the api, kindly visit Here
- Shortened URL was stored in both db and redis for faster access and better performance.