https://github.com/cyan903/lua-url-shortener
URL shortening API written in lua. Similar to how bit.ly works.
https://github.com/cyan903/lua-url-shortener
api bitly-clone lua lua-http url-shortener
Last synced: about 1 year ago
JSON representation
URL shortening API written in lua. Similar to how bit.ly works.
- Host: GitHub
- URL: https://github.com/cyan903/lua-url-shortener
- Owner: Cyan903
- Created: 2021-10-17T08:55:07.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-20T03:49:23.000Z (over 4 years ago)
- Last Synced: 2025-01-23T18:48:46.266Z (over 1 year ago)
- Topics: api, bitly-clone, lua, lua-http, url-shortener
- Language: Lua
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# lua-url-shortener
  
URL shortening API written in lua. Similar to how [bit.ly](https://bitly.com/) works. This isn't meant to be a serious project and I made it mostly for getting better at the language. This api won't scale at all and I probably spent more time writing helper functions than actually writing the api.
## Installation
This api requires MySQL (or MariaDB) to be installed and configured. First install the required luarocks.
```sh
$ luarocks install http
$ luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql # or wherever you have your mysql dir.
$ luarocks install json-lua
```
Execute `ext/db.sql`.
```
$ mysql -u user -p
mysql> source /path/to/api/ext/db.sql;
```
Copy and configure `config.json`.
```sh
$ cp ext/config.sample.json ./config.json
$ nano config.json
```
Finally, run the api with:
```sh
$ lua app.lua
```
## Dependencies
`rxi/log.lua` and `golgote/neturl` don't exist on luarocks and are installed in the `/lib` directory.
- [rxi/log.lua](https://github.com/rxi/log.lua)
- [keplerproject/luasql](https://github.com/keplerproject/luasql/)
- [daurnimator/lua-http](https://github.com/daurnimator/lua-http)
- [jiyinyiyong/json-lua](https://github.com/jiyinyiyong/json-lua)
- [golgote/neturl](https://github.com/golgote/neturl)