fix(#10): Removes the timestamp from the API endpoint
The timestamp is generated by the database call, the value was mapped to TTL. It is currently removed from the API, the TTL can be added later when needed.
This commit is contained in:
parent
8dc4e41390
commit
4c36f35492
4 changed files with 4 additions and 7 deletions
|
@ -28,13 +28,11 @@ export default function URLShortener() {
|
|||
}
|
||||
|
||||
try {
|
||||
const timestamp = Math.floor(Date.now() / 1000);
|
||||
|
||||
// Send the POST request to the backend
|
||||
await axios
|
||||
.post("http://127.0.0.1:8000/api/v1/shorten", {
|
||||
url: url,
|
||||
timestamp: timestamp,
|
||||
url: url
|
||||
})
|
||||
.then((response) => {
|
||||
if (response) {
|
||||
|
|
|
@ -51,7 +51,7 @@ def main() -> typing.NoReturn:
|
|||
sys.exit(0)
|
||||
|
||||
|
||||
def shorten_it(config: dict, session: Session, data: str, ttl: int):
|
||||
def shorten_it(config: dict, session: Session, data: str, ttl: int = 0):
|
||||
shortener = Shortener(session, config)
|
||||
identifier = shortener.generate_uuid()
|
||||
if identifier:
|
||||
|
|
|
@ -21,7 +21,7 @@ class Pointer(base.Base):
|
|||
__tablename__ = "pointers"
|
||||
id: Mapped[int] = mapped_column(primary_key=True, index=True, init=False)
|
||||
data: Mapped[str] = mapped_column(index=True)
|
||||
ttl: Mapped[str]
|
||||
ttl: Mapped[int]
|
||||
link_id: Mapped[int] = mapped_column(ForeignKey("links.id"))
|
||||
link: Mapped["Link"] = relationship(back_populates="pointers")
|
||||
timestamp: Mapped[datetime] = mapped_column(default=func.now())
|
||||
|
|
|
@ -57,7 +57,7 @@ class SiteHandler:
|
|||
self.shorten_url = shorten_url
|
||||
self.lenghten_url = lenghten_url
|
||||
self.shortenit_load_format = trafaret.Dict(
|
||||
{trafaret.Key("url"): trafaret.URL, trafaret.Key("timestamp"): trafaret.Int}
|
||||
{trafaret.Key("url"): trafaret.URL}
|
||||
)
|
||||
|
||||
def _get_server_config(self):
|
||||
|
@ -87,7 +87,6 @@ class SiteHandler:
|
|||
self.configuration.get("Shortener", None),
|
||||
self.database,
|
||||
data["url"],
|
||||
data["timestamp"],
|
||||
)
|
||||
short_url = self._get_url(stub)
|
||||
except KeyError as e:
|
||||
|
|
Loading…
Reference in a new issue