https://github.com/flyingcakes85/js-url-shortener
simple url shortener, using express and sqlite
https://github.com/flyingcakes85/js-url-shortener
Last synced: about 2 months ago
JSON representation
simple url shortener, using express and sqlite
- Host: GitHub
- URL: https://github.com/flyingcakes85/js-url-shortener
- Owner: flyingcakes85
- License: mit
- Created: 2025-01-08T18:25:57.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-01-08T18:36:40.000Z (3 months ago)
- Last Synced: 2025-01-16T23:16:07.410Z (3 months ago)
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple link shortener
## First run
To create database
```py
node init.js
```## Running
```sh
node index.js
```## Using
### Creating short link
```sh
curl -X "POST" localhost:3000 -d "dest=https://ref.snehit.dev/packaging/what-is-packaging.html"
```This returns the shortcode and id.
```json
{
"id": 13030177,
"shortcode": "jwZd",
"dest": "https://ref.snehit.dev/packaging/what-is-packaging.html"
}
```- `id` is required to later delete the short url
- `shortcode` is the actual route
- eg. in this case, `http://127.0.0.1:3000/jwZd` will take you to `https://ref.snehit.dev/packaging/what-is-packaging.html`### Deleting short link
With the id you get for short links you create, run this.
```sh
curl -X "DELETE" 127.0.0.1:3000 -d "id=13030177"
``````
{"msg":"success"}
```