Skip to content

Commit

Permalink
fix: changed format rules
Browse files Browse the repository at this point in the history
opted for double quote
  • Loading branch information
raiyansarker committed Nov 2, 2023
1 parent fb7fd71 commit bba0a1d
Show file tree
Hide file tree
Showing 26 changed files with 186 additions and 191 deletions.
22 changes: 11 additions & 11 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:svelte/recommended",
"prettier"
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
parserOptions: {
sourceType: 'module',
sourceType: "module",
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
extraFileExtensions: [".svelte"]
},
env: {
browser: true,
Expand All @@ -20,10 +20,10 @@ module.exports = {
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
files: ["*.svelte"],
parser: "svelte-eslint-parser",
parserOptions: {
parser: '@typescript-eslint/parser'
parser: "@typescript-eslint/parser"
}
}
]
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"useTabs": true,
"singleQuote": true,
"singleQuote": false,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
Expand Down
24 changes: 12 additions & 12 deletions components.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "new-york",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/styles/tailwind.postcss",
"baseColor": "slate"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
}
}
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "new-york",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/styles/tailwind.postcss",
"baseColor": "slate"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
}
}
10 changes: 5 additions & 5 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { Config } from 'drizzle-kit';
import 'dotenv/config';
import type { Config } from "drizzle-kit";
import "dotenv/config";

export default {
schema: './src/lib/server/db/schema/**',
out: './src/lib/server/db/migrations',
driver: 'turso',
schema: "./src/lib/server/db/schema/**",
out: "./src/lib/server/db/migrations",
driver: "turso",
breakpoints: true,
dbCredentials: {
url: process.env.DATABASE_URL!,
Expand Down
4 changes: 2 additions & 2 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const tailwindcss = require('tailwindcss');
const autoprefixer = require('autoprefixer');
const tailwindcss = require("tailwindcss");
const autoprefixer = require("autoprefixer");

const config = {
plugins: [
Expand Down
14 changes: 7 additions & 7 deletions src/app.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces

import type { DefaultJWT, DefaultSession } from '@auth/core/types';
import type { UsersModel } from '$lib/db/models';
import type { User } from '@auth/core/types';
import type { IncomingRequestCfProperties } from '@cloudflare/workers-types';
import type { DefaultJWT, DefaultSession } from "@auth/core/types";
import type { UsersModel } from "$lib/db/models";
import type { User } from "@auth/core/types";
import type { IncomingRequestCfProperties } from "@cloudflare/workers-types";

declare global {
namespace App {
Expand All @@ -17,15 +17,15 @@ declare global {
}
}

declare module '@auth/core/types' {
export interface User extends Pick<UsersModel, 'id' | 'name' | 'email' | 'image' | 'status'> {}
declare module "@auth/core/types" {
export interface User extends Pick<UsersModel, "id" | "name" | "email" | "image" | "status"> {}

export interface Session extends DefaultSession {
user: User;
}
}

declare module '@auth/core/jwt' {
declare module "@auth/core/jwt" {
export interface JWT extends DefaultJWT {
user: User;
}
Expand Down
6 changes: 3 additions & 3 deletions src/hooks.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authHandler } from '$lib/server/hooks/auth';
import type { Handle } from '@sveltejs/kit';
import { sequence } from '@sveltejs/kit/hooks';
import { authHandler } from "$lib/server/hooks/auth";
import type { Handle } from "@sveltejs/kit";
import { sequence } from "@sveltejs/kit/hooks";

export const handle = sequence(authHandler) satisfies Handle;
6 changes: 2 additions & 4 deletions src/lib/components/ui/badge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ export const badgeVariants = tv({
base: "inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 select-none",
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground"
Expand Down
9 changes: 3 additions & 6 deletions src/lib/components/ui/button/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ const buttonVariants = tv({
base: "inline-flex items-center justify-center rounded-md text-sm font-medium whitespace-nowrap transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
outline:
"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
link: "text-primary underline-offset-4 hover:underline"
},
Expand Down
12 changes: 6 additions & 6 deletions src/lib/server/auth/drizzle-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Adapter, AdapterAccount } from '@auth/core/adapters';
import type { DbClient } from '../db';
import { users, sessions, accounts, verificationTokens } from '../db/schema';
import { and, eq } from 'drizzle-orm';
import type { Adapter, AdapterAccount } from "@auth/core/adapters";
import type { DbClient } from "../db";
import { users, sessions, accounts, verificationTokens } from "../db/schema";
import { and, eq } from "drizzle-orm";

export function DrizzleAdapter(client: DbClient): Adapter {
return {
Expand Down Expand Up @@ -36,7 +36,7 @@ export function DrizzleAdapter(client: DbClient): Adapter {
},
async updateUser(data) {
if (!data.id) {
throw new Error('No user id.');
throw new Error("No user id.");
}

return await client.update(users).set(data).where(eq(users.id, data.id)).returning().get();
Expand Down Expand Up @@ -108,7 +108,7 @@ export function DrizzleAdapter(client: DbClient): Adapter {
.get()) ?? null
);
} catch (err) {
throw new Error('No verification token found.');
throw new Error("No verification token found.");
}
},
async deleteUser(id) {
Expand Down
32 changes: 16 additions & 16 deletions src/lib/server/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { env } from '$env/dynamic/private';
import GitHubProvider from '@auth/core/providers/github';
import GoogleProvider from '@auth/core/providers/google';
import type { SvelteKitAuthConfig } from '@auth/sveltekit';
import { eq } from 'drizzle-orm';
import { db } from '../db';
import { users } from '../db/schema';
import { DrizzleAdapter } from './drizzle-adapter';
import { base as baseUrl } from '$app/paths';
import { env } from "$env/dynamic/private";
import GitHubProvider from "@auth/core/providers/github";
import GoogleProvider from "@auth/core/providers/google";
import type { SvelteKitAuthConfig } from "@auth/sveltekit";
import { eq } from "drizzle-orm";
import { db } from "../db";
import { users } from "../db/schema";
import { DrizzleAdapter } from "./drizzle-adapter";
import { base as baseUrl } from "$app/paths";

export const authOptions = {
adapter: DrizzleAdapter(db),
Expand All @@ -31,7 +31,7 @@ export const authOptions = {
* hold users can login but can't do much actions
*/
if (!user) return true; // user object is null if user is not found on the first signin
if (!user.email || user.status === 'banned') return false;
if (!user.email || user.status === "banned") return false;

return true;
},
Expand All @@ -53,7 +53,7 @@ export const authOptions = {
/**
* Refresh user data if they update their profile
*/
if (trigger === 'update') {
if (trigger === "update") {
const refreshedUser = await db.query.users.findFirst({
where: eq(users.id, token.sub!)
});
Expand All @@ -78,14 +78,14 @@ export const authOptions = {
}
},
session: {
strategy: 'jwt'
strategy: "jwt"
},
prefix: `${baseUrl}/api/auth`,
trustHost: true,
pages: {
signIn: '/login',
signOut: '/',
error: '/login',
verifyRequest: '/login'
signIn: "/login",
signOut: "/",
error: "/login",
verifyRequest: "/login"
}
} satisfies SvelteKitAuthConfig;
16 changes: 8 additions & 8 deletions src/lib/server/db/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { drizzle } from 'drizzle-orm/libsql';
import * as schema from './schema';
import { createClient } from '@libsql/client';
import { production } from '$lib/utils';
import { env } from '$env/dynamic/private';
import type { Logger } from 'drizzle-orm';
import chalk from 'chalk';
import { drizzle } from "drizzle-orm/libsql";
import * as schema from "./schema";
import { createClient } from "@libsql/client";
import { production } from "$lib/utils";
import { env } from "$env/dynamic/private";
import type { Logger } from "drizzle-orm";
import chalk from "chalk";

const connection = createClient({ url: env.DATABASE_URL, authToken: env.DATABASE_AUTH_TOKEN });

class CustomLogger implements Logger {
logQuery(query: string, params: unknown[]): void {
console.log(
`${chalk.blueBright('Query')} : ${chalk.greenBright(query)} - ${chalk.yellowBright(params)}`
`${chalk.blueBright("Query")} : ${chalk.greenBright(query)} - ${chalk.yellowBright(params)}`
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/lib/server/db/schema.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './schema/user';
export * from './schema/session';
export * from './schema/account';
export * from "./schema/user";
export * from "./schema/session";
export * from "./schema/account";
34 changes: 17 additions & 17 deletions src/lib/server/db/schema/account.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import type { AdapterAccount } from '@auth/core/adapters';
import type { InferSelectModel } from 'drizzle-orm';
import { integer, primaryKey, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { users } from './user';
import type { AdapterAccount } from "@auth/core/adapters";
import type { InferSelectModel } from "drizzle-orm";
import { integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { users } from "./user";

export const accounts = sqliteTable(
'account',
"account",
{
userId: text('userId')
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
type: text('type').$type<AdapterAccount['type']>().notNull(),
provider: text('provider').notNull(),
providerAccountId: text('providerAccountId').notNull(),
refresh_token: text('refresh_token'),
access_token: text('access_token'),
expires_at: integer('expires_at'),
token_type: text('token_type'),
scope: text('scope'),
id_token: text('id_token'),
session_state: text('session_state')
.references(() => users.id, { onDelete: "cascade" }),
type: text("type").$type<AdapterAccount["type"]>().notNull(),
provider: text("provider").notNull(),
providerAccountId: text("providerAccountId").notNull(),
refresh_token: text("refresh_token"),
access_token: text("access_token"),
expires_at: integer("expires_at"),
token_type: text("token_type"),
scope: text("scope"),
id_token: text("id_token"),
session_state: text("session_state")
},
(account) => ({
compoundKey: primaryKey(account.provider, account.providerAccountId)
Expand Down
24 changes: 12 additions & 12 deletions src/lib/server/db/schema/session.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { integer, primaryKey, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { users } from './user';
import type { InferSelectModel } from 'drizzle-orm';
import { integer, primaryKey, sqliteTable, text } from "drizzle-orm/sqlite-core";
import { users } from "./user";
import type { InferSelectModel } from "drizzle-orm";

export const sessions = sqliteTable('session', {
sessionToken: text('sessionToken').notNull().primaryKey(),
userId: text('userId')
export const sessions = sqliteTable("session", {
sessionToken: text("sessionToken").notNull().primaryKey(),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: 'cascade' }),
expires: integer('expires', { mode: 'timestamp_ms' }).notNull()
.references(() => users.id, { onDelete: "cascade" }),
expires: integer("expires", { mode: "timestamp_ms" }).notNull()
});

export const verificationTokens = sqliteTable(
'verification_token',
"verification_token",
{
identifier: text('identifier').notNull(),
token: text('token').notNull(),
expires: integer('expires', { mode: 'timestamp_ms' }).notNull()
identifier: text("identifier").notNull(),
token: text("token").notNull(),
expires: integer("expires", { mode: "timestamp_ms" }).notNull()
},
(vt) => ({
compoundKey: primaryKey(vt.identifier, vt.token)
Expand Down
Loading

0 comments on commit bba0a1d

Please sign in to comment.