Skip to content

Commit

Permalink
refactor(#21): changed the root path for relative imports
Browse files Browse the repository at this point in the history
  • Loading branch information
sametcodes committed Mar 6, 2023
1 parent c36a771 commit 0aee800
Show file tree
Hide file tree
Showing 29 changed files with 77 additions and 66 deletions.
3 changes: 2 additions & 1 deletion app/login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import { useSession, signIn, signOut } from "next-auth/react";
import Image from "next/image";

export default function LoginPage() {
const { data: session } = useSession();
Expand All @@ -8,7 +9,7 @@ export default function LoginPage() {
return (
<>
<p>Welcome, {session?.user?.name}</p>
<img src={session?.user?.image || ""} alt="photo" width={60} />
<Image src={session?.user?.image || ""} alt="photo" width={60} />
<p>
Signed in as {session?.user?.email} <br />
</p>
Expand Down
6 changes: 3 additions & 3 deletions components/svgs/codewars/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as Icons from "@components/icons";
import * as Icons from "@/components/icons";
import {
Document,
DocumentTitle,
List,
ListItem,
} from "@components/svgs/document";
import { ObjectEntries } from "@utils";
} from "@/components/svgs/document";
import { ObjectEntries } from "@/utils";

export const getUser = (result: any, platform: any) => {
const langs = ObjectEntries(result.ranks.languages).map(([key, value]) => ({
Expand Down
4 changes: 2 additions & 2 deletions components/svgs/github/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as Icons from "@components/icons";
import * as Icons from "@/components/icons";
import {
Document,
DocumentTitle,
List,
ListItem,
} from "@components/svgs/document";
} from "@/components/svgs/document";

export const getCurrentYearContributions = (result: any, platform: any) => {
const { totalContributions } =
Expand Down
4 changes: 2 additions & 2 deletions components/svgs/stackoverflow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
DocumentTitle,
List,
ListItem,
} from "@components/svgs/document";
import * as Icons from "@components/icons";
} from "@/components/svgs/document";
import * as Icons from "@/components/icons";

export const getReputation = (result: any, platform: any) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions components/svgs/wakatime/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
DocumentTitle,
List,
ListItem,
} from "@components/svgs/document";
import * as Icons from "@components/icons";
} from "@/components/svgs/document";
import * as Icons from "@/components/icons";

export const getAllTimeSinceToday = (result: any, platform: any) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NextAuth from "next-auth";
import { PrismaAdapter } from "@next-auth/prisma-adapter";
import prisma from "@services/prisma";
import callbacks from "@services/nextauth/callbacks";
import prisma from "@/services/prisma";
import callbacks from "@/services/nextauth/callbacks";

import GithubProvider from "next-auth/providers/github";
const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env;
Expand Down
8 changes: 4 additions & 4 deletions pages/api/data/[service].ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NextApiRequest, NextApiResponse } from "next";
import { Session, unstable_getServerSession } from "next-auth";
import { authOptions } from "@pages/api/auth/[...nextauth]";
import * as services from "@services/data";
import { authOptions } from "@/pages/api/auth/[...nextauth]";
import * as services from "@/services/data";

import methods from "@services/data/methods";
import type * as methodTypes from "@services/data";
import methods from "@/services/data/methods";
import type * as methodTypes from "@/services/data";

export default async function handler(
req: NextApiRequest,
Expand Down
8 changes: 4 additions & 4 deletions pages/api/oauth/[...route].ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { NextApiRequest, NextApiResponse } from "next";
import { unstable_getServerSession } from "next-auth";
import { generateRandomString } from "@utils";
import { authOptions } from "@pages/api/auth/[...nextauth]";
import { generateRandomString } from "@/utils";
import { authOptions } from "@/pages/api/auth/[...nextauth]";

import { providers } from "@services/oauth";
import actions from "@services/oauth/actions";
import { providers } from "@/services/oauth";
import actions from "@/services/oauth/actions";

export default async function handler(
req: NextApiRequest,
Expand Down
6 changes: 3 additions & 3 deletions pages/api/platform/codewars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as services from "@services/platform/codewars";
import * as templates from "@components/svgs/codewars";
import * as services from "@/services/platform/codewars";
import * as templates from "@/components/svgs/codewars";

import handlePlatformAPI from "@services/api/handler";
import handlePlatformAPI from "@/services/api/handler";
export default handlePlatformAPI("codewars", services, templates);
6 changes: 3 additions & 3 deletions pages/api/platform/github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as services from "@services/platform/github";
import * as templates from "@components/svgs/github";
import * as services from "@/services/platform/github";
import * as templates from "@/components/svgs/github";

import handlePlatformAPI from "@services/api/handler";
import handlePlatformAPI from "@/services/api/handler";
export default handlePlatformAPI("github", services, templates);
6 changes: 3 additions & 3 deletions pages/api/platform/stackoverflow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as services from "@services/platform/stackoverflow";
import * as templates from "@components/svgs/stackoverflow";
import * as services from "@/services/platform/stackoverflow";
import * as templates from "@/components/svgs/stackoverflow";

import handlePlatformAPI from "@services/api/handler";
import handlePlatformAPI from "@/services/api/handler";
export default handlePlatformAPI("stackoverflow", services, templates);
6 changes: 3 additions & 3 deletions pages/api/platform/wakatime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as services from "@services/platform/wakatime";
import * as templates from "@components/svgs/wakatime";
import * as services from "@/services/platform/wakatime";
import * as templates from "@/components/svgs/wakatime";

import handlePlatformAPI from "@services/api/handler";
import handlePlatformAPI from "@/services/api/handler";
export default handlePlatformAPI("wakatime", services, templates);
2 changes: 1 addition & 1 deletion scripts/migrates/platform.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ts from "typescript";
import fs from "fs";
import prisma from "@services/prisma";
import prisma from "@/services/prisma";

// @ts-ignore
import jsdoc from "jsdoc-api";
Expand Down
4 changes: 2 additions & 2 deletions services/api/handler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextApiHandler, NextApiRequest, NextApiResponse } from "next";
import { getPlatformResponse } from "@services/platform/response";
import prisma from "@services/prisma";
import { getPlatformResponse } from "@/services/platform/response";
import prisma from "@/services/prisma";

type PlatformAPIHandler = {
(platformCode: string, services: any, templates: any): NextApiHandler;
Expand Down
4 changes: 2 additions & 2 deletions services/data/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prisma from "@services/prisma";
import { DataAPIMethod } from "@services/data/types";
import prisma from "@/services/prisma";
import { DataAPIMethod } from "@/services/data/types";

export const getUserConfigs: DataAPIMethod = ({ session }) => {
return prisma.config.findMany({
Expand Down
4 changes: 2 additions & 2 deletions services/data/platform/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prisma from "@services/prisma";
import { DataAPIPayload } from "@services/data/types";
import prisma from "@/services/prisma";
import { DataAPIPayload } from "@/services/data/types";

export const getPlatforms = ({ payload, session }: DataAPIPayload) => {
return prisma.platform.findMany();
Expand Down
4 changes: 2 additions & 2 deletions services/data/user/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import prisma from "@services/prisma";
import { DataAPIPayload } from "@services/data/types";
import prisma from "@/services/prisma";
import { DataAPIPayload } from "@/services/data/types";

export const getUser = async ({ payload, session }: DataAPIPayload) => {
const user = await prisma.user.findFirst({ where: { id: session.user.id } });
Expand Down
2 changes: 1 addition & 1 deletion services/nextauth/callbacks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import prisma from "@services/prisma";
import prisma from "@/services/prisma";
import { CallbacksOptions } from "next-auth";

const session: CallbacksOptions["session"] = async ({ session }) => {
Expand Down
2 changes: 1 addition & 1 deletion services/oauth/actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import prisma from "@services/prisma";
import prisma from "@/services/prisma";
import { AccessToken } from "simple-oauth2";
import { Session } from "next-auth";
import { Provider, ConnectionProfile } from ".";
Expand Down
2 changes: 1 addition & 1 deletion services/oauth/providers/github.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthorizationCode } from "simple-oauth2";
import { Provider } from "@services/oauth";
import { Provider } from "@/services/oauth";

const config: Provider = {
code: "github",
Expand Down
2 changes: 1 addition & 1 deletion services/oauth/providers/stackoverflow.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthorizationCode } from "simple-oauth2";
import { Provider } from "@services/oauth";
import { Provider } from "@/services/oauth";

const config: Provider = {
code: "stackoverflow",
Expand Down
2 changes: 1 addition & 1 deletion services/oauth/providers/wakatime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AuthorizationCode } from "simple-oauth2";
import { Provider } from "@services/oauth";
import { Provider } from "@/services/oauth";

const config: Provider = {
code: "wakatime",
Expand Down
6 changes: 3 additions & 3 deletions services/platform/codewars/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ServiceResponse } from "@services/platform/types";
import request from "@services/platform/codewars/request";
import { CodewarsUserConfig } from "@services/platform/types";
import { ServiceResponse } from "@/services/platform/types";
import request from "@/services/platform/codewars/request";
import { CodewarsUserConfig } from "@/services/platform/types";
import { Connection } from "@prisma/client";

/**
Expand Down
6 changes: 3 additions & 3 deletions services/platform/github/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ServiceResponse } from "@services/platform/types";
import request from "@services/platform/github/request";
import { GithubUserConfig } from "@services/platform/types";
import { ServiceResponse } from "@/services/platform/types";
import request from "@/services/platform/github/request";
import { GithubUserConfig } from "@/services/platform/types";
import { Connection } from "@prisma/client";

/**
Expand Down
2 changes: 1 addition & 1 deletion services/platform/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export type {
getCurrentYearContributions,
getPopularContributions,
getContributionsSummary,
} from "@services/platform/github";
} from "@/services/platform/github";
4 changes: 2 additions & 2 deletions services/platform/response.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JSXRender from "@utils/render";
import { trimChars } from "@utils";
import JSXRender from "@/utils/render";
import { trimChars } from "@/utils";
import { Connection } from "@prisma/client";

export const getPlatformResponse = async (
Expand Down
4 changes: 2 additions & 2 deletions services/platform/stackoverflow/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ServiceResponse } from "@services/platform/types";
import request from "@services/platform/stackoverflow/request";
import { ServiceResponse } from "@/services/platform/types";
import request from "@/services/platform/stackoverflow/request";
import { Connection } from "@prisma/client";

/**
Expand Down
6 changes: 3 additions & 3 deletions services/platform/wakatime/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ServiceResponse } from "@services/platform/types";
import request from "@services/platform/wakatime/request";
import { WakatimeUserConfig } from "@services/platform/types";
import { ServiceResponse } from "@/services/platform/types";
import request from "@/services/platform/wakatime/request";
import { WakatimeUserConfig } from "@/services/platform/types";
import { Connection } from "@prisma/client";

/**
Expand Down
22 changes: 16 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
Expand All @@ -21,7 +25,9 @@
],
"baseUrl": ".",
"paths": {
"@*": ["*"]
"@/*": [
"*"
]
}
},
"include": [
Expand All @@ -30,16 +36,20 @@
"index.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"pages/api/github",
"services/prisma/schema.prisma",
".lintstagedrc.js"
".lintstagedrc.js",
"/Users/samet/Documents/GitHub/devstats/.next/types/**/*.ts"
],
"exclude": [
"node_modules"
],
"exclude": ["node_modules"],
"ts-node": {
"compilerOptions": {
"module": "commonjs"
},
"typeRoots": ["./node_modules/@types"]
"typeRoots": [
"./node_modules/@types"
]
}
}

0 comments on commit 0aee800

Please sign in to comment.