Skip to content

Commit

Permalink
fix: code cleanup (#48)
Browse files Browse the repository at this point in the history
* chore: cleaning file names in client

* fix: cleaning up server code

* fix: removing tests from worker
  • Loading branch information
brayn003 authored Apr 1, 2024
1 parent ab3f6ea commit ab1b825
Show file tree
Hide file tree
Showing 26 changed files with 23 additions and 256 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSearchParams } from "next/navigation";

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";

export default function ErrorAlert() {
export function ErrorAlert() {
const searchParams = useSearchParams();
const error = searchParams.get("error");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const loginFormSchema = z.object({

interface UserLoginProps extends React.HTMLAttributes<HTMLDivElement> {}

export default function UserLogin({ className, ...props }: UserLoginProps) {
export function UserLogin({ className, ...props }: UserLoginProps) {
const form = useForm<z.infer<typeof loginFormSchema>>({
resolver: zodResolver(loginFormSchema),
defaultValues: {
Expand Down
55 changes: 0 additions & 55 deletions client/app/login-callback/route.ts

This file was deleted.

4 changes: 2 additions & 2 deletions client/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Metadata } from "next";
import { Suspense } from "react";

import ErrorAlert from "./_components/ErrorAlert";
import UserLogin from "./_components/UserLogin";
import { ErrorAlert } from "./_components/error-alert";
import { UserLogin } from "./_components/user-login";

export const metadata: Metadata = {
// template is not supported in siblings
Expand Down
2 changes: 1 addition & 1 deletion client/app/private/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { PageHeader } from "@/components/PageHeader";
import { PageHeader } from "@/components/page-header";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";

Expand Down
3 changes: 0 additions & 3 deletions client/app/private/page.tsx

This file was deleted.

41 changes: 0 additions & 41 deletions client/app/private/settings/_components/CaptureAction.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions client/app/private/settings/_components/Processes.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion client/app/private/settings/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Metadata } from "next";

import { PageHeader } from "@/components/PageHeader";
import { PageHeader } from "@/components/page-header";

import { SettingsNav } from "./_components/settings-nav";

Expand Down
13 changes: 0 additions & 13 deletions client/app/private/settings/page.tsx

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions client/app/private/settings/sessions/page.tsx

This file was deleted.

File renamed without changes.
3 changes: 2 additions & 1 deletion server/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,8 @@ disable=raw-checker-failed,
missing-module-docstring,
missing-class-docstring,
missing-function-docstring,
unrecognized-option
unrecognized-option,
too-few-public-methods

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
9 changes: 0 additions & 9 deletions server/app/constants.py

This file was deleted.

18 changes: 0 additions & 18 deletions server/app/errors.py
Original file line number Diff line number Diff line change
@@ -1,18 +0,0 @@
class MissingEnvException(Exception):
pass


class DatabaseNotConnectedException(Exception):
pass


class UserAlreadyExistsException(Exception):
pass


class WeakPasswordException(Exception):
pass


class InvalidEmailException(Exception):
pass
19 changes: 0 additions & 19 deletions server/app/helpers/store.py

This file was deleted.

5 changes: 2 additions & 3 deletions server/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from starlette.middleware.sessions import SessionMiddleware

from app.middlewares.auth_session import AuthSessionMiddleware
from app.routes import auth, integration_routes, session_routes, ticks
from app.routes import auth_routes, integration_routes, session_routes
from app.services.env import SESSION_SECRET

# @asynccontextmanager
Expand All @@ -30,9 +30,8 @@
app.add_middleware(AuthSessionMiddleware)
app.add_middleware(SessionMiddleware, secret_key=SESSION_SECRET)

app.include_router(auth.router)
app.include_router(auth_routes.router)
app.include_router(session_routes.router)
app.include_router(ticks.router)
app.include_router(integration_routes.router)


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from fastapi import APIRouter, HTTPException, Request
from pydantic import BaseModel

from app.errors import (
InvalidEmailException,
)
from app.helpers.auth import compare_passwords, hash_password
from app.helpers.models import User, UserInDB
from app.helpers.session import Session, SessionManager
Expand Down Expand Up @@ -57,7 +54,7 @@ async def signup(body: SignupBody):
@router.post("/login", response_model=LoginResponse, response_model_by_alias=False)
async def login(request: Request, body: LoginBody):
if not is_valid_email(body.email):
raise InvalidEmailException("Email is invalid")
raise HTTPException(status_code=400, detail="Email is invalid")
user = db.users.find_one({"email": body.email})
if not user:
raise HTTPException(status_code=401, detail="Invalid credentials")
Expand Down
8 changes: 0 additions & 8 deletions server/app/routes/ticks.py

This file was deleted.

9 changes: 7 additions & 2 deletions server/app/services/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
from pymongo.collection import Collection
from pymongo.database import Database

from app.errors import MissingEnvException
from app.helpers.auth import hash_password
from app.helpers.models import UserInDB
from app.services.env import ADMIN_EMAIL, ADMIN_PASSWORD, MONGODB_DB_NAME, MONGODB_URI
from app.services.env import (
ADMIN_EMAIL,
ADMIN_PASSWORD,
MONGODB_DB_NAME,
MONGODB_URI,
MissingEnvException,
)


class Db:
Expand Down
5 changes: 5 additions & 0 deletions server/app/services/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
REDIS_URI: str = getenv("REDIS_URI")
ENC_KEY: str = getenv("ENC_KEY")


class MissingEnvException(Exception):
pass


print("[Initialized] Environment Variables")
43 changes: 0 additions & 43 deletions server/scripts/migrate_collection_to_timeseries.py

This file was deleted.

2 changes: 0 additions & 2 deletions tick-workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,3 @@ To run `stonk.ninja tick-worker` locally, run the following command:
pnpm run dev [worker-type]
```
`worker-type` can either be a `producer` or a `recorder`.

# test

0 comments on commit ab1b825

Please sign in to comment.