d1snin / linda Goto Github PK
View Code? Open in Web Editor NEWSelf-hosted redirecting service with UTM parameters support.
License: Apache License 2.0
Self-hosted redirecting service with UTM parameters support.
License: Apache License 2.0
Permission to use UTM parameters should be given either for all short link objects, or for some specific ones
Preferred location; /api/shortLinks/resolution
with required request parameter alias
.
I already have the logic for it in ShortLinkService.resolveAlias
. And even the DTO.
I figured out how to fix the stupidity of mock with a rather unusual crutch. So I can go back to full call verification, including self-call verification. The tests themselves need a little refactoring, there is repetitive template code that I would like to get rid of.
The tests are passing now.
I have to make another field for the entity and have not yet come up with a name. Something like enabled
or allowRedirects
.
With the value false
redirects cannot be performed on a specific short link.
The origin url connection should be checked asynchronously every time the user creates the short link and within the cron job. Also, the event should be fired if the short link has unvailable origin.
The entire test suite has been removed since #47 because I want to rewrite it.
Although, the best way is to have a user-defined strategy for such cases. So the user would decide whether to delete a short link or simply prohibit redirects.
The app user should be able to disable some of the alias generators, for example:
linda:
alias-generators:
disable: "custom,crc32" # comma separated list (for better env vars supprt)
It is necessary to include the Location
header within the response, the user might want to access the newly created short link without any effort.
Redirect
should contain the rawAlias
field that is an alias passed within the request, example:
POST http://localhost:8080/api/shortLinks
Content-Type: application/json
{
"alias": "yt-{v}",
"target": "https://www.youtube.com/watch?v={v}",
"aliasType": "TEMPLATE",
"aliasGeneratorId": null,
"allowUtmParameters": false,
"deleteAfter": null,
"defaultUtmParameters": [],
"allowedUtmParameters": []
}
###
GET http://localhost:8080/yt-0000
Raw alias there is yt-0000
When the amount of redirects exceeds the value of the fixedRedirectsCount
field, then shortlink redirects should be disabled, and the value of fixedRedirectsCount
must be null
. Or the short link should be removed, depending on the strategy. The value of fixedRedirectsCount
must be greater than or equal to one (@javax.validation.Min(1)
).
Basically, applications like Twitter and Discord can detect links in the message and fetch them to render embed in the UI. The problem is that such non-human requests will be recorded. So, I should add an another endpoint for defaul redirecting interface which will be used in the Location
header:
http://localhost:8080/{alias}/confirmed
http://localhost:8080/example
will answer with 301
and http://localhost:8080/example/confirmed
as a Location
header.
This functionality should be optional, but enabled by default.
The user should be able to create temporary short links that will be deleted in the future.
All dependencies are already ready for writing Swagger documentation for the API as well as wiki
Now the events are being pushed at the controller level, which is not right, and it bothers my eyes. I did this because events require a DTO object, which is created at the controller level. There are several options - either to use caching (which will cause a lot of issues), or to create a DTO inside the service and return it paired with an entity, like this:
// ...
typealias EntityWithDto<E, D> = Pair<E, D?>
// ...
// ...
fun service(requireDto: Boolean = true): EntityWithDto<Entity, EntityDto>
// ...
// ...
val (entity, dto) = service()
// ...
// or
// ...
val (entity, _) = service(false)
// ...
This will also allow sending events not only in response to user actions. Internal actions would also act as a trigger.
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
Describe the solution you'd like
A clear and concise description of what you want to happen.
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The user should be able to indicate the default parameters during the short link creation (withing the request body ig)
e. g.:
curl -X POST -d '\
{\
"url": "https://youtu.be/dQw4w9WgXcQ",\
"aliasGeneratorId": "friendly",\
"defaultUtm": {\
"campaign": "trolling"\
...\
}\
}' https://yourlindaserver.com/api/shortLinks
Currently, it's impossible to update them using PATCH/PUT
requests.
Now the user can use UTM parameters on any short link. Some administrators will prefer to restrict the use of any UTM parameters on a specific short link object.
Java 17 is supported by Spring and is an LTS version. So it would be better to switch on it.
I've tried to do that once but had some issues on Tomcat's side. I think I can also switch to Undertow as a Servlet engine, it's also considered more lightweight.
Linda has been changed a bit, so the documentation update is required for both OpenAPI docs and ones on GitBook
Now it's only possible to trigger availability checks for every short link.
the current API has no security, so I think I will soon finish my starter for security
The API user should be allowed to disable the main redirecting interface, possible reasons are:
Currently, you can remove some amount of short links by passing the batch of IDs, this is not yet implemented for redirects.
The alias generation is limited to friendly alias generator (gfycat style) and the random char sequence generator. But the user should be able to specify the alias within the request, preferably in the body.
AvailabilityChange.available
is entirely pointless. AvailabilityChange.unavailabilityReason
is always null if the origin url is available and not null if the origin url is unavailable.
The CRC32 checksum generation takes <0 ms, so it would be better than the current implementation.
there's snippet:
val checksum = CRC32() // note that I probably should use the local variable since Checksum is not thread-safe
checksum.update(url.toByteArray())
return String.format(Locale.US, "%08x", checksum.value)
To solve the data inconsistency problem, I can just add the random character at the end of checksum.
Tests are needed with the greatest coverage of the project, I think I will make a checklist for the tested cases here soon
As described in the project description. UTM request parameters should be fully supported.
Currently, when using the default redirecting interface, the controller waits for the redirect creation.
There should be an option whether to wait for the completion or not.
Spring Boot supports async execution via @EnableAsync
and @Async
with Future<T>
return type.
Currently the API user can only remove and find redirects, which are created internally, but since the ability to disable the main redirecting interface is planned (see #6), user should be allowed to do that manually.
I think I'll have to work with html parsing here, I'll need to collect meta tags from the original url content and use them for short link html content, basically
Templates are arbitrary aliases with placeholder declarations. Basically, templates work like a short link, but in a dynamic manner.
Here's an example:
POST http://localhost:8080/api/templates
Content-Type: application/json
{
"source": "gh-{owner}-{repo}",
"target": "https://github.com/{owner}/{repo}"
}
source
can be interpreted as short link alias, but dynamic. target
is a target url which is being built using template variables.
In this example, base redirecting interface will redirect the user from http://localhost:8080/gh-torvalds-linux
to https://github.com/torvalds/linux
General rules:
source
and target
)target
)source
or target
target
that does not match the URL patternsource
should contain at least one placeholdersource
pattern should not collide with other onessource
should contain a separator between multiple variables (if present)Redirect and consumed UTM parameters should be registered as well.
Note that templates are not available for availability checks since the target url is only known at the time of request execution.
It's possible to use WebSocket to send necessary data to the client, but there are security problems. Instead, I can use long polling fetching method.
I'm literally ddos'ing the database. For example, to remove a batch of domains, I first search for them, and then delete them separately.
Should look like this:
GET http://localhost:8080/api/utmParameters/{type}/{value}
Preferred event group names are short-link-expired
and short-link-max-redirects-reached
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.