TDevShortener has been developed by TotenDev Studio, as an internal system with the main goal of been a private and simple shortener for anyone who needs it..
##Requirements
####Modules
- [mysql-native] (https://www.npmjs.com/package/mysql-native) for mysql connection
- [js_cache] (https://www.npmjs.com/package/js_cache) for in-memory cache
- [newrelic] (https://www.npmjs.com/package/newrelic) for new relic analysis
##Installing
All Stable code will be on master
branch, any other branch is designated to unstable codes. So if you are installing for production environment, use master
branch for better experience.
To run TDevShortener you MUST have mysql server connection and database configured. All credentials and preferences can be configured with ENV IVARS and are described here.
--
After configured your environment you can run commands below to start TDevShortener:
Download and install dependencies
$ npm install
Start server
$ 'node main.js' OR 'foreman start'
Also you can use command bellow for quick testing without any credentials
$ 'node main.js --test'
##Configuration
All Configuration NEED to be done with ENV IVARS.
Database is used for storing all shortened URL and Codes.
database.host
- MySQL Host. REQUIREDdatabase.port
- MySQL Host Port. REQUIREDdatabase.user
- MySQL DB User. REQUIREDdatabase.password
- MySQL DB Password. OPTIONALdatabase.database
- MySQL DB Name. REQUIREDdatabase.table
- MySQL DB Table Name. REQUIRED
REST is used for all HTTP
talks.
rest.host
- Listening host. REQUIREDrest.port
- Listening port. REQUIREDrest.cache-state
- cache state (1-ON 0-OFF), it'll cache last 1000 URLs and Codes. REQUIREDrest.cache-expires
- cache expire time in milliseconds. REQUIRED IF rest.cache-state is ONrest.cache-rows-limit
- cache max recoreds. REQUIRED IF rest.cache-state is ONrest.max-request-buffer
- max request BODY buffer size. OPTIONAL (if not specified will use default value256 bytes
)rest.fallbackURL
- URL to be used on fallback of 404. OPTIONAL (if not specified will use show empty page with error)
logging.log-type
- Logging type.. You can use 1,2 or 3 for more verbosity. REQUIREDshortener.acceptedURLS
- Array of regex, that will validate any URL to be shortened. REQUIREDNEW_RELIC_APP_NAME
- New Relic application name. REQUIREDNEW_RELIC_LICENSE_KEY
- New Relic license key. REQUIRED
##Rest API
####Short URL (POST)
- Method:
POST
- URL:
example.com/create/
- Body:
link=http://mylongurl.sobig.com/tolong
- Success codes:
200
-http://sh.tt/12345678
- Error Codes:
202
409
500
####Short URL (GET OR HEAD)
- Method:
GET
ORHEAD
- URL:
example.com/create/http://mylongurl.sobig.com/tolong
- Success codes:
200
-http://sh.tt/12345678
- Error Codes:
202
409
500
####Solve URL (GET OR HEAD)
- Method:
GET
ORHEAD
- URL:
example.com/12345678/
- Success codes:
302
- Error Codes:
202
409
500
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
##License GPLv3