- FEATURES
- PREREQUISITES
- SETUP
- RUNNING THE SCRIPT
- ERROR HANDLING
- HOSTING
- USED PACKAGES
- TOOLS
- ARTICLES
- DO NOT FORGET TO DO
- TUTORIALS
- INSPIRATIONS
- CONTRIBUTE
- CONTRIBUTORS
- SPECIAL THANKS
- LICENSE
- CONTACT
- Create short URL
- Redirect to the original URL
- Get all URLs
-
Clone the repository and navigate to the directory:
git clone https://github.com/montasim/url-shortener-microservice.git cd url-shortener-microservice
-
Install the dependencies:
yarn install
-
Configuring the Environment:
Create a
.env.development
or.env.staging
or.env.production
file in the root directory of the project and populate it with the necessary environment variables. See the .env.example file for an example.
-
Running the Application:
To start the application in development mode, use:
yarn dev
This will run the server with nodemon, automatically restarting when any changes are made.
-
To build and run the application in production mode, use:
yarn start
This will build the application and start the server using the built files.
This script first builds the project by linting the code, fixing lint issues, running prettier, and then starts the application with pm2.
-
Testing:
To run the tests configured with Jest, use:
yarn test
This will build the project and then run all the Jest tests.
-
Linting and Code Formatting:
-
To check for linting errors:
yarn lint:check
-
To fix linting errors:
yarn lint:fix
-
To check if files are formatted correctly:
yarn prettier:check
-
To format files:
yarn prettier:fix
-
-
Generating Documentation:
To generate code documentation with JSDoc, run:
yarn generate-docs
This will create documentation based on your JSDoc comments.
-
Release Management:
To create a new release, you can use:
yarn release
This will automatically bump the version, update the CHANGELOG, and create a commit and a tag.
For minor or major releases:
yarn release:minor yarn release:major
-
Cleanup:
To clean up dependencies and rebuild the project:
yarn clean
This command initializes the auto cleanup process and then forces a rebuild.
-
Build the Docker Compose Services:
yarn docker:build-dev
-
Run the Docker Compose Services:
yarn docker:run-dev
-
Stop the Containers:
yarn docker:stop-dev
-
Rebuild the Containers:
yarn docker:rebuild-dev
Step-by-step guide on setting up your own Vercel instance:
Vercel is the recommended option for hosting the files since it is free and easy to set up.
- Go to vercel.com.
- Click on
Log in
. - Sign in with GitHub by pressing
Continue with GitHub
. - Sign in to GitHub and allow access to all repositories if prompted.
- Fork this repo.
- Go back to your Vercel dashboard.
- To import a project, click the
Add New...
button and select theProject
option. - Click the
Continue with GitHub
button, search for the required Git Repository and import it by clicking theImport
button. Alternatively, you can import a Third-Party Git Repository using theImport Third-Party Git Repository ->
link at the bottom of the page. - Create a personal access token (PAT) here and enable the
repo
anduser
permissions (this allows access to see private repo and user stats). - Copy all the .env.development file as environment variables in the Vercel dashboard.
- Click deploy, and you're good to go. See your domains to use the API!
Contributions are always welcome! Please read the contribution guidelines and contributor license agreement.