Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/aswinbennyofficial/url-shortner
- Owner: aswinbennyofficial
- License: mit
- Created: 2023-09-30T16:08:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-02T10:04:16.000Z (about 1 year ago)
- Last Synced: 2023-10-02T20:44:23.604Z (about 1 year ago)
- Topics: express, expressjs, mongodb, mongodb-database, mongoose, node, node-js, nodejs, url-shortener, urlshortener
- Language: JavaScript
- Homepage:
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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