What I'm gonna use:
-
Rails API 5.2.1
-
RSpec for testing
-
Shoulda Matchers for simplier
RSpectesting -
Heroku for deployment & development
-
Husky to manage GIT hooks & to run
RSpectest onpre-commit&pre-push -
Rack::Attack to prevent DOS
-
Rack CORS for Cross-Origin Resource Sharing
-
Memcached/Dalli for requests throttling
-
Geocoder to track locations
Use rails s and curl for HTTP requests.
This might be deployed as an isolated API as it is shown here (this exactly route returns the current number of links for base62 encoding). Along with a frontend like this (git for it) served with some http server. Just don't forget to respect the CORS as it is shown here.
On the other hand it could be deployed as a part of monolithic system as it is shown here (react branch of this repo) with a Puma for http serving.
You may know the app/ structure since it's pretty default. It's the home to models, controllers, validators, exception handlers etc.
There are three controllers which are interesting for us:
application_controllerwith module dependencies;links_controllerhandlesstore-ing,get-ing,count-ing for theLinkmodel;redirect_controllerwith a single method toredirectand store theRedirectitself (i.e. it's location) using the Geocoder;
Linkto store:urland:shortened;Redirectto store:locationand:time;
A single Link has many Redirects. A single Redirect belongs to one Link.
Base62Validatortovalidate :base62shortening;UrlValidatortovalidate :urlformatting;
-
initializers/rack_attack.rbto configure Rack::Attack; -
environments/*.rbto manage herokuproductionand local environments (developmentandtesting);
This is for RSpec with Shoulda Matchers & Faker testing.
I belive that everything is backed by tests by now.
.branch-ignore is used by me to manage branch-specific .gitignore using Husky and .gitignore.<branch-name> files.