Nano Banana Pro
Agent skill for nano-banana-pro
I am making a link redirection service in nodejs using typescript and express. Here I will describe the requirements.
Sign in to like and favorite skills
Please act as a backend developer proficient in nodejs and typescript.
I am making a link redirection service in nodejs using typescript and express. Here I will describe the requirements.
The goal of the service is to redirect short links (slugs) to specific amazon product pages. Each slug will be associated with more than one amazon page URL:
Here is the example format of the link: https://example.com/:slug
All the slugs that are supported by our service will be hard-coded in a separate file called "link-definitions.ts".
When our service gets a request, it will try to find one of the link definitions based on the slug. If we have defined a link for that slug, we should find the country of that request based on the IP, and using one of the NPM packages that can do this mapping.
Once we have the country, we will inspect the link definition and if we have this country in the definition, we will redirect the user to the link associated with that country.
In addition to the link definitions for each slug, we will have one fallback link definition that will be used in case we receive a request for a slug we don't recognize. This fallback link definition will have it's own mapping for each country and destination amazon URL.
In case that we do not have the amazon URL for a country, we should take the user to the URL for the US amazon store. All link definitions must have a link for amazon.
In addition to the country mapping each link definition will have one or more tags associated with it. Tags are represented as a list of strings.
Apart from redirecting the user, the goal of the service is to log every link click in a Postgres database. For each link click we want to save one record in a table with the following information:
The videoId will be added to the clicked link by YouTube in the form of a query param called "v". For example, if one of our short links is used in a YouTube video description like this:
Then YouTube will actually take the user to the following url:
https://example.com/my-slug?v=some-video-id
Our goal is to extract that videoId if present, and save it in the Postgres database.
The above are the basic requirements, please ask any clarifying questions before we get started with working on this project.
Before we continue what would be a good .gitignore file for this project?
Ok, let's continue I had to make a short break :)
Can you continue from the beginning of src/index.ts
Before we continue, let's address the following: I will provide you with a list of country codes that I would like to support with this service. However, some of those countries do not have their own amazon store. So we should create a mapping for each of the country codes that I will provide to a country code that actually has an amazon store. For each country that doesn't have it's own store, we should choose the amazon store in the same geographic region. And then let's make sure to use this mapping in the endpoint.
Here is a list of the country codes that I would like to support:
US IN DE BR RU GB PL CA TR IT ES ID UA VN FR JP PH NL AU RO MX PT SE TH MY CZ PK BD MA SG AR
Do you know which countries have amazon stores?
Can you use this list of known countries with amazon stores to update the mapping so that countries that do not have their own amazon stores are mapped to the ones that do that are in the same geographic region?
Ok, can you show me how to use this mapping in the endpoint?
Ok, let's. continue with saving this info in postgres
continue from src/index.ts
how can I query this table in psql?