Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ env:
IS_PRODUCTION: 1
ORIGIN: https://samepage.network
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
PG_DATABASE_URL: ${{ secrets.PG_DATABASE_URL }}
REMIX_CACHE_POLICY_ID: ${{ secrets.REMIX_CACHE_POLICY_ID }}
S3_WEBSITE_ENDPOINT: ${{ secrets.S3_WEBSITE_ENDPOINT }}
SAMEPAGE_DEVELOPMENT_TOKEN: ${{ secrets.SAMEPAGE_DEVELOPMENT_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion api/access-token/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { accessTokens } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "package/backend/createAPIGatewayProxyHandler";
import { BackendRequest } from "package/internal/types";
import getMysql from "~/data/mysql.server";
Expand Down
2 changes: 1 addition & 1 deletion api/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
tokenNotebookLinks,
tokens,
} from "data/schema";
import { and, desc, eq } from "drizzle-orm/expressions";
import { and, desc, eq } from "drizzle-orm";
import {
GetAccessTokenResponse,
zGetAccessTokenPayload,
Expand Down
2 changes: 1 addition & 1 deletion api/app/get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apps } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "package/backend/createAPIGatewayProxyHandler";
import { NotFoundError } from "~/data/errors.server";
import getMysql from "~/data/mysql.server";
Expand Down
2 changes: 1 addition & 1 deletion api/apps/slack/events/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apps, employeeInboxMessages } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import uploadFileContent from "package/backend/uploadFileContent";
import createAPIGatewayHandler from "samepage/backend/createAPIGatewayProxyHandler";
import { v4 } from "uuid";
Expand Down
2 changes: 1 addition & 1 deletion api/backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Web3Storage, File } from "web3.storage";
import uploadFile from "~/data/uploadFile.server";
import { downloadFileBuffer } from "~/data/downloadFile.server";
import getMysql from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import type { Context } from "aws-lambda";
import { v4 } from "uuid";
import Automerge from "automerge";
Expand Down
2 changes: 1 addition & 1 deletion api/errors/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import createAPIGatewayProxyHandler from "package/backend/createAPIGatewayProxyH
import sendEmail from "package/backend/sendEmail.server";
import { z } from "zod";
import getMysql from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import ExtensionErrorEmail from "~/components/ExtensionErrorEmail";
import { v4, validate } from "uuid";
import uploadFile from "~/data/uploadFile.server";
Expand Down
2 changes: 1 addition & 1 deletion api/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { users } from "@clerk/clerk-sdk-node";
import { Handler } from "aws-lambda";
import { websites } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import emailError from "package/backend/emailError.server";
import uploadFileContent from "package/backend/uploadFileContent";
import { Json } from "package/internal/types";
Expand Down
2 changes: 1 addition & 1 deletion api/notebook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { users } from "@clerk/clerk-sdk-node";
import type { Handler } from "aws-lambda";
import { apps, notebooks, tokenNotebookLinks, tokens } from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { and, eq } from "drizzle-orm";
import {
GetNotebookCredentialsResponse,
zGetNotebookCredentialsPayload,
Expand Down
2 changes: 1 addition & 1 deletion api/oauth/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { authorizationCodes, oauthClients, tokens } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "package/backend/createAPIGatewayProxyHandler";
import type { BackendRequest } from "package/internal/types";
import { z } from "zod";
Expand Down
2 changes: 1 addition & 1 deletion api/origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
Context,
} from "aws-lambda";
import { websiteRedirects } from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { and, eq } from "drizzle-orm";
import getMysql from "~/data/mysql.server";

export const handler = async (
Expand Down
2 changes: 1 addition & 1 deletion api/page/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
} from "~/data/errors.server";
import catchError from "~/data/catchError.server";
import getMysql from "~/data/mysql.server";
import { eq, and, ne, gt, inArray, isNull } from "drizzle-orm/expressions";
import { eq, and, ne, gt, inArray, isNull } from "drizzle-orm";
import { sql } from "drizzle-orm/sql";
import { downloadFileContent } from "~/data/downloadFile.server";
import uploadFile from "~/data/uploadFile.server";
Expand Down
2 changes: 1 addition & 1 deletion api/publishing/launch-website/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
websiteSharing,
websites,
} from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { and, eq } from "drizzle-orm";
import createPublicAPIGatewayProxyHandler from "package/backend/createPublicAPIGatewayProxyHandler";
import { BackendRequest } from "package/internal/types";
import { v4 } from "uuid";
Expand Down
2 changes: 1 addition & 1 deletion api/publishing/website-redirects/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BackendRequest } from "package/internal/types";
import getWebsiteUuidByRoamJSToken from "~/data/getWebsiteUuidByRoamJSToken.data";
import getMysql from "~/data/mysql.server";
import { websiteRedirects } from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { and, eq } from "drizzle-orm";
import { v4 } from "uuid";
import { BadRequestError } from "~/data/errors.server";

Expand Down
2 changes: 1 addition & 1 deletion api/publishing/website-sharing/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import createAPIGatewayProxyHandler from "package/backend/createAPIGatewayProxyH
import { BadRequestError, UnauthorizedError } from "~/data/errors.server";
import getMysql from "~/data/mysql.server";
import { websiteSharing } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import getWebsiteUuidByRoamJSToken from "~/data/getWebsiteUuidByRoamJSToken.data";

type GetArgs = { method: "GET"; authorization: string; requestId: string };
Expand Down
2 changes: 1 addition & 1 deletion api/publishing/website-status/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import createPublicAPIGatewayProxyHandler from "package/backend/createPublicAPIG
import { BackendRequest } from "package/internal/types";
import getMysql from "~/data/mysql.server";
import { z } from "zod";
import { and, desc, eq } from "drizzle-orm/expressions";
import { and, desc, eq } from "drizzle-orm";
import authenticateRoamJSToken from "~/data/authenticateRoamJSToken.server";
import getWebsiteByNotebookProperties from "~/data/getWebsiteByNotebookProperties.server";

Expand Down
10 changes: 5 additions & 5 deletions api/roamjsauth/get.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { apps, oauthClients } from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { and, eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "samepage/backend/createAPIGatewayProxyHandler";
import getMysql from "~/data/mysql.server";
import getPostgres from "~/data/pg.server";
import { z } from "zod";
import { BackendRequest } from "dist/internal/types";

const bodySchema = z.object({ state: z.string() });

const logic = async ({
state,
requestId,
requestId: _,
}: BackendRequest<typeof bodySchema>) => {
const cxn = await getMysql(requestId);
const cxn = await getPostgres();
const [service, otp] = state.split("_");
const [oauth] = await cxn
.select({
Expand All @@ -20,7 +20,7 @@ const logic = async ({
.from(oauthClients)
.innerJoin(apps, eq(apps.id, oauthClients.appId))
.where(and(eq(oauthClients.id, otp), eq(apps.code, service)));
await cxn.end();
// await cxn.end();
return { success: !!oauth };
};

Expand Down
12 changes: 6 additions & 6 deletions api/roamjsauth/post.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { apps, oauthClients } from "data/schema";
import { and, eq } from "drizzle-orm/expressions";
import { apps, oauthClients } from "data/schema-postgres";
import { and, eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "samepage/backend/createAPIGatewayProxyHandler";
import getMysql from "~/data/mysql.server";
import getPostgres from "~/data/pg.server";

const logic = async ({
service,
otp,
requestId,
requestId: _,
}: {
requestId: string;
service: string;
otp: string;
}) => {
const cxn = await getMysql(requestId);
const cxn = await getPostgres();
const [oauth] = await cxn
.select({
secret: oauthClients.secret,
})
.from(oauthClients)
.innerJoin(apps, eq(apps.id, oauthClients.appId))
.where(and(eq(oauthClients.id, otp), eq(apps.code, service)));
await cxn.end();
// await cxn.end();
if (!oauth) return { code: 204 };
return { auth: oauth.secret };
};
Expand Down
14 changes: 7 additions & 7 deletions api/roamjsauth/put.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { apps, oauthClients } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { apps, oauthClients } from "data/schema-postgres";
import { eq } from "drizzle-orm";
import createAPIGatewayProxyHandler from "samepage/backend/createAPIGatewayProxyHandler";
import getMysql from "~/data/mysql.server";
import getPostgres from "~/data/pg.server";

const logic = async ({
service,
otp,
requestId,
requestId: _,
auth,
}: {
requestId: string;
service: string;
otp: string;
auth: string;
}) => {
const cxn = await getMysql(requestId);
const cxn = await getPostgres();
const appId = await cxn
.select({ id: apps.id })
.from(apps)
Expand All @@ -27,8 +27,8 @@ const logic = async ({
appId,
id: otp,
})
.onDuplicateKeyUpdate({ set: { secret: auth } });
await cxn.end();
.onConflictDoUpdate({ target: oauthClients.id, set: { secret: auth } });
// await cxn.end();
return { success: true };
};

Expand Down
2 changes: 1 addition & 1 deletion api/shutdown.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CloudFormation } from "@aws-sdk/client-cloudformation";
import { S3 } from "@aws-sdk/client-s3";
import { websites } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import clearRecords from "~/data/clearRoute53Records.server";
import getMysql from "~/data/mysql.server";
import startWebsiteOperation from "~/data/startWebsiteOperation.server";
Expand Down
2 changes: 1 addition & 1 deletion api/snsubcriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { v4 } from "uuid";
import { Json } from "package/internal/types";
import getMysql from "~/data/mysql.server";
import { websiteStatuses, websites } from "data/schema";
import { desc, eq } from "drizzle-orm/expressions";
import { desc, eq } from "drizzle-orm";
import { CloudFormation } from "@aws-sdk/client-cloudformation";
import { CloudFront } from "@aws-sdk/client-cloudfront";
import { SES } from "@aws-sdk/client-ses";
Expand Down
2 changes: 1 addition & 1 deletion api/user/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { v4 } from "uuid";
import randomString from "~/data/randomString.server";
import { tokens } from "data/schema";
import { sql } from "drizzle-orm/sql";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import stripe from "~/data/stripe.server";

const wh = new Webhook(process.env.SVIX_SECRET);
Expand Down
2 changes: 1 addition & 1 deletion api/ws/sendmessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
onlineClients,
tokenNotebookLinks,
} from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import debugMod from "package/utils/debugger";

export type WSEvent = Pick<APIGatewayProxyEvent, "body"> & {
Expand Down
2 changes: 1 addition & 1 deletion app/data/authenticateNotebook.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { apps, notebooks, tokenNotebookLinks, tokens } from "data/schema";
import { NotFoundError, UnauthorizedError } from "~/data/errors.server";
import getMysql from "~/data/mysql.server";
import { eq, and } from "drizzle-orm/expressions";
import { eq, and } from "drizzle-orm";
import { AuthenticateNotebook } from "samepage/internal/types";

const authenticateNotebook: AuthenticateNotebook = async (args) => {
Expand Down
2 changes: 1 addition & 1 deletion app/data/authenticateUser.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apps, tokenNotebookLinks, notebooks } from "data/schema";
import { eq, and } from "drizzle-orm/expressions";
import { eq, and } from "drizzle-orm";
import { AuthenticateUser } from "package/internal/types";
import getMysql from "./mysql.server";
import verifyUser from "./verifyUser.server";
Expand Down
2 changes: 1 addition & 1 deletion app/data/completeWebsiteOperation.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { websiteOperations } from "data/schema";
import getMysql from "./mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";

const completeWebsiteOperation = async ({
operationUuid,
Expand Down
2 changes: 1 addition & 1 deletion app/data/createUserNotebook.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { tokens } from "data/schema";
import { ConflictError } from "~/data/errors.server";
import getMysql from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import getOrGenerateNotebookUuid from "./getOrGenerateNotebookUuid.server";

const createUserNotebook = async ({
Expand Down
2 changes: 1 addition & 1 deletion app/data/deleteNotebook.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
tokenNotebookLinks,
} from "data/schema";
import getMysql from "~/data/mysql.server";
import { eq, or } from "drizzle-orm/expressions";
import { eq, or } from "drizzle-orm";
import { MySql2Database } from "drizzle-orm/mysql2";
import endClient from "./endClient.server";

Expand Down
2 changes: 1 addition & 1 deletion app/data/deleteSharedPage.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getMysql from "~/data/mysql.server";
import { S3 } from "@aws-sdk/client-s3";
import { pageNotebookLinks, pages } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";

const s3 = new S3({ region: "us-east-1", endpoint: process.env.AWS_ENDPOINT });

Expand Down
2 changes: 1 addition & 1 deletion app/data/deleteUser.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { notebooks, tokenNotebookLinks, tokens } from "data/schema";
import getMysql from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import deleteNotebook from "./deleteNotebook.server";
import { users } from "@clerk/clerk-sdk-node";
import { MySql2Database } from "drizzle-orm/mysql2";
Expand Down
2 changes: 1 addition & 1 deletion app/data/deleteWebsite.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
websiteNotebookLinks,
websites,
} from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import getMysql from "./mysql.server";

const deleteWebsite = async ({
Expand Down
2 changes: 1 addition & 1 deletion app/data/disconnectNotebookFromPage.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pageNotebookLinks } from "data/schema";
import getMysqlConnection from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";

const disconnectNotebookFromPage = ({
uuid,
Expand Down
2 changes: 1 addition & 1 deletion app/data/endClient.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { clientSessions, onlineClients } from "data/schema";
import getMysqlConnection from "~/data/mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import { MySql2Database } from "drizzle-orm/mysql2";

const endClient = async (
Expand Down
2 changes: 1 addition & 1 deletion app/data/fireUserEmployee.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
NotFoundError,
} from "./errors.server";
import getMysql from "./mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import { EC2 } from "@aws-sdk/client-ec2";

const fireUserEmployee = async ({
Expand Down
2 changes: 1 addition & 1 deletion app/data/getActorInfo.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { apps, notebooks, tokenNotebookLinks, tokens } from "data/schema";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import { ActorInfo } from "package/internal/types";
import getMysql from "./mysql.server";

Expand Down
2 changes: 1 addition & 1 deletion app/data/getAdminNotebookProfile.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
tokenNotebookLinks,
tokens,
} from "data/schema";
import { eq, desc, and } from "drizzle-orm/expressions";
import { eq, desc, and } from "drizzle-orm";
import { sql } from "drizzle-orm/sql";
import { zSamePageSchema } from "package/internal/types";

Expand Down
2 changes: 1 addition & 1 deletion app/data/getHostedZoneByWebsiteUuid.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CloudFormation } from "@aws-sdk/client-cloudformation";
import getMysql from "./mysql.server";
import { eq } from "drizzle-orm/expressions";
import { eq } from "drizzle-orm";
import { websites } from "data/schema";
import getHostedZoneByDomain from "./getHostedZoneByDomain.server";

Expand Down
2 changes: 1 addition & 1 deletion app/data/getLatestOperation.server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { websiteOperations } from "data/schema";
import getMysql from "./mysql.server";
import { and, desc, eq, isNull } from "drizzle-orm/expressions";
import { and, desc, eq, isNull } from "drizzle-orm";

const getLatestOperation = async ({
websiteUuid,
Expand Down
Loading
Loading