Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aswinbennyofficial/url-shortner

URL shortner backend using NodeJs, Express and MongoDb
https://github.com/aswinbennyofficial/url-shortner

express expressjs mongodb mongodb-database mongoose node node-js nodejs url-shortener urlshortener

Last synced: about 11 hours ago
JSON representation

URL shortner backend using NodeJs, Express and MongoDb

Awesome Lists containing this project

README

        

# URL-shortner
This project is a URL shortner backend using NodeJs, Express and MongoDb. Short links can be generated from making a put request on `/api/url/shorten`


### Prerequisites
- Install the latest nodeJS

### Usage
- Clone the repo
```bash
git clone https://github.com/aswinbennyofficial/aswinbennyofficial/URL-shortner.git
```

- fix dependency issues
```bash
npm install
```

- include your Mongodb connection string in the variable `MONGO_URI` in `.env` file
```env
MONGO_URI='mongodb+srv://username:[email protected]/url-collection?retryWrites=true&w=majority'
```


- include your base address in the variable `BASE_URL` in `.env` file
```
BASE_URL='http://localhost:5000'
```

- use `npm start` to run the app


### Project structure
- `config` folder
- `db` : configuration to connect to Mongodb



- `models` folder
- `urlSchema.js` : contains the schema and model of the project



- `routes` folder
- `index.js` : routes for the root path `/` is defined. Responsible for decoding shortlinks to long
- `url.js` : routes for the path `/api/url/shorten` is defined. Responsible for creating short links



- `app.js` : main file