Skip to content

Commit 4873407

Browse files
committed
feat: url shortener
1 parent 90b7408 commit 4873407

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3327
-986
lines changed

.claude/settings.local.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
"Bash(powershell -Command \"Stop-Process -Id 8644 -Force\")",
1919
"Bash(powershell -Command:*)",
2020
"Bash(uv sync:*)",
21-
"Bash(python:*)"
21+
"Bash(python:*)",
22+
"Bash(curl:*)",
23+
"Bash(npm run build:*)",
24+
"Bash(uv add:*)",
25+
"Bash(dir:*)"
2226
],
2327
"deny": [],
2428
"ask": []

backend/app/alembic/env.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
# target_metadata = mymodel.Base.metadata
1919
# target_metadata = None
2020

21-
from app.models import SQLModel # noqa
22-
from app.core.config import settings # noqa
21+
# Import all models to ensure they are registered with SQLModel metadata
22+
from sqlmodel import SQLModel
23+
from app.modules.users.models import User # noqa
24+
from app.modules.items.models import Item # noqa
25+
from app.modules.shortener.models import ShortUrl # noqa
26+
from app.core.config import settings # noqa
2327

2428
target_metadata = SQLModel.metadata
2529

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""add_shorturl_table
2+
3+
Revision ID: d19595e777a0
4+
Revises: 5d2541ab9041
5+
Create Date: 2025-11-29 21:54:22.369039
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
import sqlmodel.sql.sqltypes
11+
12+
13+
# revision identifiers, used by Alembic.
14+
revision = 'd19595e777a0'
15+
down_revision = '5d2541ab9041'
16+
branch_labels = None
17+
depends_on = None
18+
19+
20+
def upgrade():
21+
# ### commands auto generated by Alembic - please adjust! ###
22+
op.create_table('shorturl',
23+
sa.Column('original_url', sqlmodel.sql.sqltypes.AutoString(length=2048), nullable=False),
24+
sa.Column('title', sqlmodel.sql.sqltypes.AutoString(length=255), nullable=True),
25+
sa.Column('is_active', sa.Boolean(), nullable=False),
26+
sa.Column('id', sa.Uuid(), nullable=False),
27+
sa.Column('short_code', sqlmodel.sql.sqltypes.AutoString(length=50), nullable=False),
28+
sa.Column('click_count', sa.Integer(), nullable=False),
29+
sa.Column('created_at', sa.DateTime(), nullable=False),
30+
sa.Column('updated_at', sa.DateTime(), nullable=False),
31+
sa.Column('owner_id', sa.Uuid(), nullable=False),
32+
sa.ForeignKeyConstraint(['owner_id'], ['user.id'], ondelete='CASCADE'),
33+
sa.PrimaryKeyConstraint('id')
34+
)
35+
op.create_index(op.f('ix_shorturl_short_code'), 'shorturl', ['short_code'], unique=True)
36+
# ### end Alembic commands ###
37+
38+
39+
def downgrade():
40+
# ### commands auto generated by Alembic - please adjust! ###
41+
op.drop_index(op.f('ix_shorturl_short_code'), table_name='shorturl')
42+
op.drop_table('shorturl')
43+
# ### end Alembic commands ###

backend/app/api/main.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

backend/app/api/router.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from fastapi import APIRouter
2+
3+
from app.core.config import settings
4+
from app.modules.auth.routes import router as auth_router
5+
from app.modules.users.routes import router as users_router
6+
from app.modules.items.routes import router as items_router
7+
from app.modules.shortener.routes import router as shortener_router
8+
from app.modules.utils.routes import router as utils_router
9+
from app.modules.private.routes import router as private_router
10+
11+
api_router = APIRouter()
12+
13+
# Include all module routers
14+
api_router.include_router(auth_router)
15+
api_router.include_router(users_router)
16+
api_router.include_router(utils_router)
17+
api_router.include_router(items_router)
18+
api_router.include_router(shortener_router)
19+
20+
# Include private routes only in local environment
21+
if settings.ENVIRONMENT == "local":
22+
api_router.include_router(private_router)

backend/app/api/routes/__init__.py

Whitespace-only changes.

backend/app/api/routes/items.py

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)