Skip to content

Commit

Permalink
Fix formatting (#345)
Browse files Browse the repository at this point in the history
* fix: nostr sdk formatting

* fix: data backend formatting

* fix: mobile formatting

* fix: pwa formatting

* fix: typos
  • Loading branch information
ncoquelet authored Dec 12, 2024
1 parent 1707b0e commit 5b3fe46
Show file tree
Hide file tree
Showing 109 changed files with 952 additions and 997 deletions.
1 change: 1 addition & 0 deletions .github/workflows/config/typos.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[default.extend-words]
ba = "ba"
frst = "frst"

[files]
extend-exclude = ["/**/patches/**", "/**/assets/**", "/**/src/config/**", "**/*.config.ts"]
2 changes: 1 addition & 1 deletion .github/workflows/data-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
fi
- name: Prettier Format Check
run: pnpm prettier:check
run: pnpm format:check

- name: TypeScript Check
run: pnpm ts:check
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pwa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
fi
- name: Prettier Format Check
run: pnpm prettier:check
run: pnpm format:check

- name: Lint
run: pnpm lint
Expand Down
4 changes: 2 additions & 2 deletions apps/data-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"prisma:generate": "npx prisma generate",
"prisma:push": "npx prisma db push",
"prisma:setup": "npx prisma generate && npx prisma db pull",
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
"prettier:check": "prettier --check \"src/**/*.{ts,tsx}\"",
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx}\"",
"ts:check": "tsc --noEmit"
},
"keywords": [],
Expand Down
22 changes: 11 additions & 11 deletions apps/data-backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import prismaPlugin from "./plugins/prisma";
import twitterPlugin from "./plugins/twitter-oauth";
import { launchBot } from "./services/telegram-app";
import declareRoutes from "./router";
import fastifySession from '@fastify/session';
import fastifySession from "@fastify/session";
import fastifyOauth2 from "@fastify/oauth2";

// Type declarations
Expand Down Expand Up @@ -53,23 +53,23 @@ async function buildServer() {
await fastify.register(authPlugin);
// await fastify.register(twitterPlugin);
await fastify.register(fastifyOauth2, {
name: 'twitterOAuth',
name: "twitterOAuth",
credentials: {
client: {
id: process.env.TWITTER_API_KEY!,
secret: process.env.TWITTER_API_SECRET_KEY!,
},
// auth: fastifyOauth2.TWITTER_CONFIGURATION,
auth: {
authorizeHost: 'https://api.twitter.com',
authorizePath: '/oauth/authorize',
tokenHost: 'https://api.twitter.com',
tokenPath: '/oauth/access_token',
}
authorizeHost: "https://api.twitter.com",
authorizePath: "/oauth/authorize",
tokenHost: "https://api.twitter.com",
tokenPath: "/oauth/access_token",
},
},
startRedirectPath: '/auth/login',
startRedirectPath: "/auth/login",
callbackUri: process.env.TWITTER_CALLBACK_URL!,
})
});

//Middleware to verify JWT
const JWT_SECRET = config.jwt.secret;
Expand All @@ -84,15 +84,15 @@ async function buildServer() {
});

fastify.register(fastifySession, {
secret: JWT_SECRET ?? 'your-secret-key',
secret: JWT_SECRET ?? "your-secret-key",
cookie: { secure: process.env.NODE_ENV == "production" ? true : false }, // Set to true in production
});

// Register routes
// Auth
// await fastify.register(authRoutes);
// Indexer
await declareRoutes(fastify)
await declareRoutes(fastify);

// Initialize WebSocket handlers
fastify.ready((err) => {
Expand Down
87 changes: 43 additions & 44 deletions apps/data-backend/src/plugins/twitter-oauth.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
import fp from 'fastify-plugin';
import fastifyOauth2 from '@fastify/oauth2';
import fp from "fastify-plugin";
import fastifyOauth2 from "@fastify/oauth2";

export default fp(async (fastify, opts) => {
// fastify.decorate("oauth2Twitter",
// {
// name: 'twitterOAuth',
// credentials: {
// client: {
// id: process.env.TWITTER_API_KEY!,
// secret: process.env.TWITTER_API_SECRET_KEY!,
// },
// // auth: fastifyOauth2.TWITTER_CONFIGURATION,
// auth:{
// authorizeHost: 'https://api.twitter.com',
// authorizePath: '/oauth/authorize',
// tokenHost: 'https://api.twitter.com',
// tokenPath: '/oauth/access_token',
// }
// },
// startRedirectPath: '/auth/login',
// // callbackUri: process.env.TWITTER_CALLBACK_URL!,
// }
// )
// fastify.register(fastifyOauth2, {
// name: 'twitterOAuth',
// credentials: {
// client: {
// id: process.env.TWITTER_API_KEY!,
// secret: process.env.TWITTER_API_SECRET_KEY!,
// },
// // auth: fastifyOauth2.TWITTER_CONFIGURATION,
// auth:{
// authorizeHost: 'https://api.twitter.com',
// authorizePath: '/oauth/authorize',
// tokenHost: 'https://api.twitter.com',
// tokenPath: '/oauth/access_token',
// }
// },
// startRedirectPath: '/auth/login',
// // callbackUri: process.env.TWITTER_CALLBACK_URL!,
// });
// fastify.decorate("oauth2Twitter",
// {
// name: 'twitterOAuth',
// credentials: {
// client: {
// id: process.env.TWITTER_API_KEY!,
// secret: process.env.TWITTER_API_SECRET_KEY!,
// },
// // auth: fastifyOauth2.TWITTER_CONFIGURATION,
// auth:{
// authorizeHost: 'https://api.twitter.com',
// authorizePath: '/oauth/authorize',
// tokenHost: 'https://api.twitter.com',
// tokenPath: '/oauth/access_token',
// }
// },
// startRedirectPath: '/auth/login',
// // callbackUri: process.env.TWITTER_CALLBACK_URL!,
// }
// )
// fastify.register(fastifyOauth2, {
// name: 'twitterOAuth',
// credentials: {
// client: {
// id: process.env.TWITTER_API_KEY!,
// secret: process.env.TWITTER_API_SECRET_KEY!,
// },
// // auth: fastifyOauth2.TWITTER_CONFIGURATION,
// auth:{
// authorizeHost: 'https://api.twitter.com',
// authorizePath: '/oauth/authorize',
// tokenHost: 'https://api.twitter.com',
// tokenPath: '/oauth/access_token',
// }
// },
// startRedirectPath: '/auth/login',
// // callbackUri: process.env.TWITTER_CALLBACK_URL!,
// });
});


declare module "fastify" {
interface FastifyInstance {
twitterOAuth: any;
}
interface FastifyInstance {
twitterOAuth: any;
}
}
6 changes: 2 additions & 4 deletions apps/data-backend/src/routes/indexer/all-transactions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand Down Expand Up @@ -42,7 +40,7 @@ async function allTransactionsRoute(
transaction_type: true,
created_at: true,
quote_amount: true,
time_stamp:true,
time_stamp: true,
},
});

Expand Down
4 changes: 1 addition & 3 deletions apps/data-backend/src/routes/indexer/buy-coin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";

async function buyCoinRoute(fastify: FastifyInstance, options: RouteOptions) {
Expand Down
10 changes: 4 additions & 6 deletions apps/data-backend/src/routes/indexer/deploy-launch.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"
import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

interface DeployLaunchParams {
launch: string;
owner_address?:string
owner_address?: string;
}
interface DeployLaunchByUserParams {
owner_address:string
owner_address: string;
}
async function deployLaunchRoute(
fastify: FastifyInstance,
Expand Down Expand Up @@ -122,9 +121,8 @@ async function deployLaunchRoute(
}
});


// @TODO fix

// fastify.get<{
// Params: DeployLaunchByUserParams;
// }>("/deploy-launch/from/:user/", async (request, reply) => {
Expand Down
7 changes: 2 additions & 5 deletions apps/data-backend/src/routes/indexer/deploy-token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand Down Expand Up @@ -90,7 +88,7 @@ async function deployTokenRoute(
}

const deploys = await prisma.token_deploy.findMany({
where: { owner_address:owner_address },
where: { owner_address: owner_address },
select: {
memecoin_address: true,
owner_address: true,
Expand All @@ -112,7 +110,6 @@ async function deployTokenRoute(
.send({ message: "Internal server error." });
}
});

}

export default deployTokenRoute;
3 changes: 1 addition & 2 deletions apps/data-backend/src/routes/indexer/graph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"
import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand Down
5 changes: 1 addition & 4 deletions apps/data-backend/src/routes/indexer/holdings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand All @@ -23,7 +21,6 @@ async function holdingsRoute(fastify: FastifyInstance, options: RouteOptions) {
}

try {

const distributions = await prisma.token_transactions.groupBy({
by: ["owner_address", "transaction_type"],
// by: ["owner_address", "transaction_type"], // TODO add by tx type and sum sell and buy
Expand Down
9 changes: 4 additions & 5 deletions apps/data-backend/src/routes/indexer/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import allTransactionsRoute from "./all-transactions";
import buyCoinRoute from "./buy-coin";


export const indexerRoutes = {
buyCoinRoute,
allTransactionsRoute
}
export const indexerRoutes = {
buyCoinRoute,
allTransactionsRoute,
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
import prisma from "indexer-prisma";
import { HTTPStatus } from "../../../utils/http";
import { isValidStarknetAddress } from "../../../utils/starknet";

interface NameserviceParams {
username?: string;
owner_address?:string
owner_address?: string;
}

async function nameserviceRoutes(fastify: FastifyInstance, options: RouteOptions) {
async function nameserviceRoutes(
fastify: FastifyInstance,
options: RouteOptions
) {
fastify.get<{
Params: NameserviceParams;
}>("/username-claimed", async (request, reply) => {
Expand Down
4 changes: 1 addition & 3 deletions apps/data-backend/src/routes/indexer/token_stats.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand Down
8 changes: 3 additions & 5 deletions apps/data-backend/src/routes/indexer/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { FastifyInstance, RouteOptions } from "fastify";
import prisma from "indexer-prisma"
// import {prisma} from "indexer-prisma"

import prisma from "indexer-prisma";
import { HTTPStatus } from "../../utils/http";
import { isValidStarknetAddress } from "../../utils/starknet";

Expand Down Expand Up @@ -37,8 +35,8 @@ async function transactionsRoute(
amount: true,
quote_amount: true,
price: true,
time_stamp:true,
liquidity_raised:true
time_stamp: true,
liquidity_raised: true,
},
});

Expand Down
Loading

0 comments on commit 5b3fe46

Please sign in to comment.