Git Product home page Git Product logo

linda's People

Contributors

d1snin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

linda's Issues

Testing issues

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.

Check the origin url connection

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.

Add unit tests

The entire test suite has been removed since #47 because I want to rewrite it.

Include `rawAlias` field in the `Redirect` object

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

Short links with a fixed number of possible redirects

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)).

Add another Location layer to prevent unwanted redirects

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.

Documentation

All dependencies are already ready for writing Swagger documentation for the API as well as wiki

Better event management

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.

Can I update README with what Linda:// does?

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.

Default UTM parameters support

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

Switch to Java 17

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.

Update the documentation

Linda has been changed a bit, so the documentation update is required for both OpenAPI docs and ones on GitBook

Security

the current API has no security, so I think I will soon finish my starter for security

Get rid of `AvailabilityChange.available`

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.

Using CRC32 checksums as a backend for alias generator

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

Tests are needed with the greatest coverage of the project, I think I will make a checklist for the tested cases here soon

UTM parameters support

As described in the project description. UTM request parameters should be fully supported.

Count redirect asynchronously

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.

Ability to create redirects.

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.

Redirecting templates support

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:

  • duplicated placeholder declarations (in both - source and target)
  • unused variables (in target)
  • empty source or target
  • target that does not match the URL pattern
  • source should contain at least one placeholder
  • source pattern should not collide with other ones
  • source 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.

Optimize database interactions

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.

Zero width characters alias generator

The following characters are displayed as empty:

\u200B \u200C \u200D \u2060

It is possible to implement a generator that will use these characters to generate a unique, but "empty" alias.

Alias generator ID: zero-width

Note: the alias must necessarily end with \u200b character. See:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.