-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename User table NewsletterSubscriber * move users to newsletterSubscribers in api * init uses /api/newsletterSubscribers * working on migration [wip] * fix migrations for indexes * fix messed up prisma migration * signup and session * use iron-session for session management * email validator, signup page * login page * login * auth demo * refactor session stuff into util * sendMail api * /api/logout route analytics page requires login * api keys * nonworking * add iron-session to cli and rename cookies * session, logout * refactor * working github oauth * add oauth_tokens table * add prisma to cli * email and password validations on signup * ui for login * add Config table to cli db * add signup link to header for testing * start of Organization in CLI * global prisma * fix types * finish oauth callback maybe * fix logix * add iron session to callback route * working on api * return the user that sent the oauth token * settings * sendMail with api keys * nodemail opts * validate api key * add cache control header (30s) to validate * fix apikey response parse * integration test for /api/apiKeys/:k/validate * try ankane/setup-postgres@v1 * try user postgres * try petersugihara * try with service * MM_DEV=1 * migrate in cli too * try checking in generated client * rm packages/cli/prisma/generated from git * generate web client locally too * beautiful green * fix posthog test to work when MM_DEV=1 * MM_DEV=1 works for setup test * refactor * use the right type * refactor * user.test.ts for users api in web * test db url * .envrc * database cleaning * test create user and login * use test db's in github * test passwords for github actions * signup: if no redirectTo, take them to settings * invariants * separate e2e tests from regular jest tests * woops, needed to fix yarn test * rename e2e -> integration * comment * try prisma * use DATABASE_URL=$DATABASE_URL_TEST WEB_DATABASE_URL=$WEB_DATABASE_URL_TEST * hmm * move tests that use the db into integration folder * fix lint errors * rename * fix merge conflict * comment out tests * uncomment out tests * - remove cli and web prisma migrations - update cli and web schemas - i didn't run prisma migrate dev yet * delete oauth files * move apiKeys to cli * more schema update * migrate * update package script names * move users, session api to cli * remove oauth redirect * remove signup page * remove signup link from cli * move settings page from web to cli and delete login page from web * signup page in cli * signup in cli * find first user or 404 * working * remove loggin * login * fix useRef types * text * properly type session user * styling * auth * sync table names for integration tests * working on integration tests * integration tests * /api/apiKeys should only return active api keys * working api/sendMail test * do not open * rm unused import * prettiiier * refactor fetch to apiSendMail * only look at ts/tsx in CLI tsconfig.json include * fix types * next build works in cli * validateSessionSetup when running instead of loading * web has no login, session, signup atm * better ts * delete unused mailingApi.ts * jest integration should only run .test.ts files (e.g. not util files) * refactor integration apiCreateUser * fix integration test * remove more oauth from migration * wait for databases to be empty, all integration tests passing * apiKeys * fix cliPrisma types, delete with prisma... 100ms -> 30ms * refactor * logout integration test * fix fn name * generate prisma client in server build * add more user api tests * MAILING_DATABASE_URL, runInBand :( * fix type errors, build works * - move apiIntegrationTestUtil to __integration__ - ignore __integration__ in .npmignore and .mailing build step * ignore __integration__ also in tsconfig? * fix link:emails * cd into .mailing before running prisma commands * added prisma to package.json files to copy into node_modules * email-validator import * move packages to the right place * unused_no_db_session_password123 idea * return 404 if MAILING_SESSION_PASSWORD is undefined (sessions not in use or forgot to define * refactoring apiIntegrationTestUtil.ts * refactor helper functions for api integration tests * don't need ? * correct ci:test command to user ci:cli * assert ports are free * fix ci:test:next * debug ci * try import fetch from "node-fetch"; * start the web server * ci:test set db url for web * fail-fast false * also run yarn prisma generate * fix next.js web deploy vercel run yarn prisma generate && yarn prisma migrate deploy in build * psql -> mysql; tests run locally * db name * Revert "db name" This reverts commit d806b45. * Revert "psql -> mysql; tests run locally" This reverts commit 1be2c92. * session should 404 if MAILING_SESSION_PASSWORD is not set * px-[12px] -> px-2; py-[8px] -> py-2 * border-[1px] -> border Co-authored-by: Peter Sugihara <[email protected]> Co-authored-by: Elliot Hursh <[email protected]>
- Loading branch information
1 parent
e30ff34
commit 2ed3d46
Showing
62 changed files
with
4,788 additions
and
3,260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
**/dist/** | ||
**/generated/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { Config } from "jest"; | ||
|
||
const config: Config = { | ||
setupFilesAfterEnv: ["<rootDir>/testSetup.integration.ts"], | ||
testMatch: ["<rootDir>/packages/**/__integration__/**/*.test.[jt]s?(x)"], | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
maxConcurrency: 1, | ||
maxWorkers: 1, | ||
// TODO: keep testTimeout low and use jest.setTimeout for long ones | ||
testTimeout: 60000, | ||
transform: { | ||
"^.+\\.(ts|tsx)$": "ts-jest", | ||
"^.+\\.(js)$": "babel-jest", | ||
}, | ||
testPathIgnorePatterns: [ | ||
"scripts", | ||
"<rootDir>/emails/", | ||
"<rootDir>/.mailing/", | ||
"<rootDir>/packages/cli/.mailing", | ||
"<rootDir>/packages/cli/src/pages/.*/__test__", | ||
"<rootDir>/packages/cli/src/components", | ||
], | ||
watchPathIgnorePatterns: [ | ||
"<rootDir>/emails/", | ||
"<rootDir>/packages/cli/src/emails/", | ||
"<rootDir>/packages/cli/src/generator_templates/ts/emails/", | ||
"<rootDir>/.mailing/", | ||
"tmp-testMailQueue.json", | ||
], | ||
}; | ||
|
||
// Point to the correct DB in dev | ||
process.env.MAILING_DATABASE_URL = process.env.MAILING_DATABASE_URL_TEST; | ||
process.env.WEB_DATABASE_URL = process.env.WEB_DATABASE_URL_TEST; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
node_modules | ||
.next | ||
__test__ | ||
__integration__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { PrismaClient } from "../generated/client"; | ||
import { mockDeep, mockReset, DeepMockProxy } from "jest-mock-extended"; | ||
|
||
import prisma from ".."; | ||
|
||
jest.mock("..", () => ({ | ||
__esModule: true, | ||
default: mockDeep<PrismaClient>(), | ||
})); | ||
|
||
beforeEach(() => { | ||
mockReset(prismaMock); | ||
}); | ||
|
||
export const prismaMock = prisma as unknown as DeepMockProxy<PrismaClient>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { PrismaClient } from "./generated/client"; | ||
|
||
declare global { | ||
// eslint-disable-next-line no-var | ||
var prisma: PrismaClient<any>; | ||
} | ||
|
||
const prisma = global.prisma || new PrismaClient(); | ||
|
||
if (process.env.NODE_ENV === "development") global.prisma = prisma; | ||
|
||
export default prisma; |
43 changes: 43 additions & 0 deletions
43
packages/cli/prisma/migrations/20221013235437_add_organization_api_keyand_user/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
-- CreateTable | ||
CREATE TABLE "User" ( | ||
"id" TEXT NOT NULL, | ||
"email" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"password" TEXT NOT NULL, | ||
"organizationId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "User_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "Organization" ( | ||
"id" TEXT NOT NULL, | ||
"name" TEXT NOT NULL, | ||
|
||
CONSTRAINT "Organization_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateTable | ||
CREATE TABLE "ApiKey" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"active" BOOLEAN NOT NULL DEFAULT true, | ||
"organizationId" TEXT NOT NULL, | ||
|
||
CONSTRAINT "ApiKey_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "User_organizationId_idx" ON "User"("organizationId"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "ApiKey_organizationId_idx" ON "ApiKey"("organizationId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "User" ADD CONSTRAINT "User_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "ApiKey" ADD CONSTRAINT "ApiKey_organizationId_fkey" FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE RESTRICT ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Please do not edit this file manually | ||
# It should be added in your version-control system (i.e. Git) | ||
provider = "postgresql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
output = "./generated/client" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = env("MAILING_DATABASE_URL") | ||
} | ||
|
||
model User { | ||
id String @id @default(cuid()) | ||
email String @unique | ||
createdAt DateTime @default(now()) | ||
password String | ||
organizationId String | ||
Organization Organization @relation(fields: [organizationId], references: [id]) | ||
@@index([organizationId]) | ||
} | ||
|
||
model Organization { | ||
id String @id @default(cuid()) | ||
name String | ||
User User[] | ||
ApiKey ApiKey[] | ||
} | ||
|
||
model ApiKey { | ||
id String @id @default(cuid()) | ||
createdAt DateTime @default(now()) | ||
active Boolean @default(true) | ||
organizationId String | ||
Organization Organization @relation(fields: [organizationId], references: [id]) | ||
@@index([organizationId]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
2ed3d46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mailing-dynamic-demo – ./
mailing-dynamic-demo-git-main-sofn.vercel.app
demo.mailing.run
mailing-dynamic-demo.vercel.app
mailing-dynamic-demo-sofn.vercel.app
2ed3d46
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
web – ./packages/web
web-sofn.vercel.app
web-git-main-sofn.vercel.app
mailing.run
web-rho-puce.vercel.app
www.mailing.run