Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] refactor: move to tRPC #549

Merged
merged 34 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9b1bb1f
[WIP] refactor: move to trpc
devrsi0n Nov 25, 2022
731d508
fix: update ref tables
devrsi0n Nov 25, 2022
23ed1dc
wip: create trpc and emails packages
devrsi0n Nov 25, 2022
929eb0d
refactor: notifcation hub and play page
devrsi0n Nov 25, 2022
f0902f4
refactor: notification subscription
devrsi0n Nov 25, 2022
a350176
fix: cannot find prisma schema and next-auth model errors
devrsi0n Nov 25, 2022
dcb97a8
fix: dashboard trpc
devrsi0n Nov 25, 2022
5ecc7c8
fix: theme ssg
devrsi0n Nov 26, 2022
52ae927
fix: theme editor
devrsi0n Nov 26, 2022
ac2b99a
fix: analytics trpc
devrsi0n Nov 26, 2022
adba245
fix: comment widget
devrsi0n Nov 26, 2022
98a652e
fix: comment timeline hydration
devrsi0n Nov 26, 2022
57a52d9
fix: create/delete a comment
devrsi0n Nov 26, 2022
58ac3b6
fix: toggle a comment like
devrsi0n Nov 26, 2022
42b9aa3
fix: fetch and update profile
devrsi0n Nov 26, 2022
ff03a37
refactor: notification
devrsi0n Nov 27, 2022
abe2218
refactor: remove graphql ref
devrsi0n Nov 27, 2022
ca281fe
refactor: remove graphql packages
devrsi0n Nov 27, 2022
88b4c87
refactor: revalidate api
devrsi0n Nov 27, 2022
ac7fc6f
refactor: remove hasura stuff
devrsi0n Nov 27, 2022
095940c
refactor: fix ts errors
devrsi0n Nov 27, 2022
1e1edc1
fix: add db scripts
devrsi0n Nov 27, 2022
7a338ac
fix: turbo env
devrsi0n Nov 27, 2022
7f29a04
fix: ignore .env
devrsi0n Nov 27, 2022
284c4c0
fix(bundle-analyze): type error
devrsi0n Nov 28, 2022
6d3fe2b
fix(release): add turbo remote cache
devrsi0n Nov 28, 2022
40871e0
fix: skip auto query if no session
devrsi0n Nov 28, 2022
715126b
fix: select comment fields
devrsi0n Nov 28, 2022
e1ec2e8
fix: disable queries without session
devrsi0n Nov 28, 2022
1ffbead
fix: db schema error
devrsi0n Nov 28, 2022
1b99167
fix: notification message not work and sort message orders
devrsi0n Nov 29, 2022
854a309
fix: unexpected stripped subscription object
devrsi0n Nov 29, 2022
9b272ed
fix: ut errors
devrsi0n Dec 1, 2022
755a681
fix: e2e errors
devrsi0n Dec 1, 2022
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
4 changes: 0 additions & 4 deletions .github/workflows/bundle-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ jobs:
ANALYZE: true
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
HASURA_EVENT_SECRET: ${{ secrets.HASURA_EVENT_SECRET }}
HASH_ALGORITHM: ${{ secrets.HASH_ALGORITHM }}
HASURA_ADMIN_SECRET: ${{ secrets.HASURA_ADMIN_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
NEXT_PUBLIC_ANALYTICS_DOMAIN: ${{ secrets.NEXT_PUBLIC_ANALYTICS_DOMAIN }}
NEXT_PUBLIC_APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
NEXT_PUBLIC_HASURA_HTTP_ORIGIN: ${{ secrets.NEXT_PUBLIC_HASURA_HTTP_ORIGIN }}
NEXT_PUBLIC_HASURA_WS_ORIGIN: ${{ secrets.NEXT_PUBLIC_HASURA_WS_ORIGIN }}
2 changes: 0 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,5 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
TEST_USER_ID: ${{ secrets.TEST_USER_ID }}
HASURA_EVENT_SECRET: ${{ secrets.HASURA_EVENT_SECRET }}
NEXT_PUBLIC_HASURA_HTTP_ORIGIN: ${{ secrets.NEXT_PUBLIC_HASURA_HTTP_ORIGIN }}
# DEBUG: 'cypress:*'
# DEBUG_DEPTH: 9
42 changes: 0 additions & 42 deletions .github/workflows/hasura-cdyml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
HASURA_EVENT_SECRET: ${{ secrets.HASURA_EVENT_SECRET }}
HASH_ALGORITHM: ${{ secrets.HASH_ALGORITHM }}
HASURA_ADMIN_SECRET: ${{ secrets.HASURA_ADMIN_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
NEXT_PUBLIC_ANALYTICS_DOMAIN: ${{ secrets.NEXT_PUBLIC_ANALYTICS_DOMAIN }}
NEXT_PUBLIC_APP_URL: ${{ secrets.NEXT_PUBLIC_APP_URL }}
NEXT_PUBLIC_HASURA_HTTP_ORIGIN: ${{ secrets.NEXT_PUBLIC_HASURA_HTTP_ORIGIN }}
NEXT_PUBLIC_HASURA_WS_ORIGIN: ${{ secrets.NEXT_PUBLIC_HASURA_WS_ORIGIN }}
29 changes: 0 additions & 29 deletions .github/workflows/stellate.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
.DS_Store
.next
out/
.env
*.env.local
.envproduction
.vercel
Expand Down
5 changes: 0 additions & 5 deletions .graphqlrc

This file was deleted.

4 changes: 3 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
strict-peer-dependencies=false
strict-peer-dependencies=false
save-exact=true
public-hoist-pattern[]=*prisma*
3 changes: 0 additions & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
.github/ISSUE_TEMPLATE
**/.next
**/.cache
**/generated
services/hasura/metadata

.github/PULL_REQUEST_TEMPLATE.md
pnpm-lock.yaml
**/schema.graphql
**/email/templates/*.html
1 change: 0 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
- [![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white)](https://tailwindcss.com/)
- [![cypress](https://img.shields.io/badge/-cypress-%23E5E5E5?style=for-the-badge&logo=cypress&logoColor=058a5e)](https://www.cypress.io/)
- [![Jest](https://img.shields.io/badge/-jest-%23C21325?style=for-the-badge&logo=jest&logoColor=white)](https://jestjs.io/)
- [urql](https://github.com/FormidableLabs/urql)
- [next-auth](https://github.com/nextauthjs/next-auth)
- [tiptap](https://tiptap.dev)
- [Plausible](https://github.com/plausible/analytics)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ You can have a [self-hosted](https://chirpy.dev/docs/self-hosted) version of Chi
- [![TailwindCSS](https://img.shields.io/badge/tailwindcss-%2338B2AC.svg?style=for-the-badge&logo=tailwind-css&logoColor=white)](https://tailwindcss.com/)
- [![cypress](https://img.shields.io/badge/-cypress-%23E5E5E5?style=for-the-badge&logo=cypress&logoColor=058a5e)](https://www.cypress.io/)
- [![Jest](https://img.shields.io/badge/-jest-%23C21325?style=for-the-badge&logo=jest&logoColor=white)](https://jestjs.io/)
- [urql](https://github.com/FormidableLabs/urql)
- [next-auth](https://github.com/nextauthjs/next-auth)
- [tiptap](https://tiptap.dev)
- [Plausible](https://github.com/plausible/analytics)
Expand Down
2 changes: 1 addition & 1 deletion apps/comment-bootstrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"dotenv": "16.0.3",
"dotenv-cli": "6.0.0",
"dotenv-expand": "9.0.0",
"eslint": "8.27.0",
"eslint": "8.28.0",
"jest": "29.3.1",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand Down
6 changes: 3 additions & 3 deletions apps/comment-bootstrapper/src/lib/comment-bootstrapper.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EVENT_CLICK_CONTAINER } from '@chirpy-dev/utils';

import { ERR_UNMATCHED_DOMAIN } from '../../../main/src/server/common/error-code';
import type { PagePayload } from '../../../main/src/server/services/page';
import type { ResponseError } from '../../../main/src/server/types/error';
import type { GetPagByUrl } from '../../../main/src/server/types/page';
import {
observeAndBroadcastThemeChange,
observeWidgetLoadedEvent,
Expand Down Expand Up @@ -49,7 +49,7 @@ export async function initCommentWidget(): Promise<void> {
origin + pathname,
)}&title=${encodeURIComponent(window.document.title)}`,
);
const page: GetPagByUrl = await res.json();
const page: PagePayload = await res.json();
if (isResponseError(page)) {
if (page.code == ERR_UNMATCHED_DOMAIN) {
return console.error(page.error);
Expand Down Expand Up @@ -96,7 +96,7 @@ export async function initCommentWidget(): Promise<void> {
renderTarget.append(iframe);
}

function isResponseError(res: GetPagByUrl): res is ResponseError {
function isResponseError(res: PagePayload): res is ResponseError {
return !!(res as ResponseError).error;
}

Expand Down
4 changes: 0 additions & 4 deletions apps/e2e/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,5 @@ export default function Plugins(
0,
23,
);
config.env.HASURA_EVENT_SECRET = process.env.HASURA_EVENT_SECRET;
config.env.NEXT_PUBLIC_HASURA_HTTP_ORIGIN =
process.env.NEXT_PUBLIC_HASURA_HTTP_ORIGIN;

return config;
}
2 changes: 0 additions & 2 deletions apps/e2e/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import '@testing-library/cypress/add-commands';
import { waitGraphql } from '../fixtures/utils';

Cypress.Commands.add('login', () => {
cy.intercept(Cypress.env('NEXT_PUBLIC_HASURA_HTTP_ORIGIN')).as('graphql');

cy.visit('/auth/sign-in?allowAnonymous=true');
cy.get('input[name=name]').type(Cypress.env('TEST_USER_ID'));
cy.get('button[type=submit]').click();
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dotenv": "16.0.3",
"dotenv-cli": "6.0.0",
"dotenv-expand": "9.0.0",
"eslint": "8.27.0",
"eslint": "8.28.0",
"typescript": "4.9.3"
},
"publishConfig": {
Expand Down
5 changes: 1 addition & 4 deletions apps/emails/config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ module.exports = {
build: {
templates: {
destination: {
path: path.resolve(
__dirname,
'../main/src/server/services/email/templates',
),
path: path.resolve(__dirname, '../../packages/emails/src/templates'),
},
},
},
Expand Down
6 changes: 2 additions & 4 deletions apps/emails/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@chirpy-dev/emails",
"name": "@chirpy-dev/emails-app",
"version": "0.0.1",
"license": "AGPL-3.0-or-later",
"main": "./config.js",
Expand All @@ -19,7 +19,5 @@
"tailwindcss-email-variants": "2.0.0",
"tailwindcss-mso": "1.3.0"
},
"publishConfig": {
"access": "public"
}
"private": true
}
5 changes: 0 additions & 5 deletions apps/main/.env-tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Default value for local development
NEXT_PUBLIC_HASURA_HTTP_ORIGIN="http://localhost:8080/v1/graphql"
NEXT_PUBLIC_HASURA_WS_ORIGIN="ws://localhost:8080/v1/graphql"
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_ANALYTICS_DOMAIN=http://localhost:8000

HASURA_ADMIN_SECRET=myadminsecretkey
HASURA_EVENT_SECRET=myeventsecretkey

NEXTAUTH_URL=http://localhost:3000
# Copy the key of `HASURA_GRAPHQL_JWT_SECRET` from `services/hasura/docker-compose.local.yaml`, it used by next-auth and hasura
NEXTAUTH_SECRET=
Expand Down
2 changes: 0 additions & 2 deletions apps/main/.env.docker
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

# Used by docker to generate runtime public env var
NEXT_PUBLIC_HASURA_HTTP_ORIGIN=
NEXT_PUBLIC_HASURA_WS_ORIGIN=
NEXT_PUBLIC_APP_URL=
NEXT_PUBLIC_ANALYTICS_DOMAIN=
NEXT_PUBLIC_VAPID=
14 changes: 14 additions & 0 deletions apps/main/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ const nextConfig = {
scrollRestoration: true,
legacyBrowsers: false,
transpilePackages: [
'@chirpy-dev/emails',
'@chirpy-dev/ui',
'@chirpy-dev/utils',
'@chirpy-dev/graphql',
'@chirpy-dev/types',
'@chirpy-dev/trpc',
],
swcPlugins: [
// Allow Date/Map in getStaticProps
['next-superjson-plugin', {}],
],
},
async rewrites() {
Expand Down Expand Up @@ -106,6 +112,14 @@ const nextConfig = {
test: /\.html$/,
loader: 'html-loader',
});
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
net: false,
tls: false,
fs: false,
};
}
return config;
},
};
Expand Down
16 changes: 6 additions & 10 deletions apps/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
"test:coverage": "DEBUG_PRINT_LIMIT=999999 jest --silent=false --coverage"
},
"dependencies": {
"@chirpy-dev/graphql": "workspace:*",
"@chirpy-dev/emails": "workspace:*",
"@chirpy-dev/trpc": "workspace:*",
"@chirpy-dev/types": "workspace:*",
"@chirpy-dev/ui": "workspace:*",
"@chirpy-dev/utils": "workspace:*",
"@radix-ui/colors": "0.1.8",
"@sendinblue/client": "3.2.2",
"@tensorflow-models/toxicity": "1.2.2",
"@tensorflow/tfjs": "3.18.0",
"@tensorflow/tfjs-converter": "3.18.0",
"@tensorflow/tfjs-core": "3.18.0",
"cors": "2.8.5",
"eta": "1.12.3",
"github-slugger": "1.5.0",
"graphql": "16.6.0",
"graphql-tag": "2.12.6",
Expand All @@ -35,14 +34,13 @@
"html-loader": "4.2.0",
"jsonwebtoken": "8.5.1",
"lodash": "4.17.21",
"next": "13.0.4",
"next-auth": "4.16.4",
"next": "13.0.5",
"next-axiom": "0.15.1",
"next-connect": "0.13.0",
"next-mdx-remote": "3.0.8",
"next-plausible": "3.6.4",
"next-superjson-plugin": "0.4.9",
"next-themes": "0.2.1",
"next-urql": "4.0.0",
"nodemailer": "6.7.8",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -54,7 +52,6 @@
"shiki": "0.11.1",
"superjson": "1.11.0",
"type-fest": "3.2.0",
"urql": "3.0.3",
"web-push": "3.5.0",
"wonka": "6.1.1",
"ws": "8.11.0"
Expand All @@ -65,7 +62,7 @@
"@chirpy-dev/eslint-config": "workspace:*",
"@chirpy-dev/service-worker": "workspace:*",
"@chirpy-dev/tsconfigs": "workspace:*",
"@next/bundle-analyzer": "13.0.4",
"@next/bundle-analyzer": "13.0.5",
"@relative-ci/agent": "4.1.1",
"@types/cors": "2.8.12",
"@types/github-slugger": "1.3.0",
Expand All @@ -82,10 +79,9 @@
"dotenv": "16.0.3",
"dotenv-cli": "6.0.0",
"dotenv-expand": "9.0.0",
"eslint": "8.27.0",
"eslint": "8.28.0",
"jest": "29.3.1",
"postcss": "8.4.19",
"stellate": "1.17.1",
"tailwindcss": "3.2.4",
"typescript": "4.9.3",
"webpack": "5.75.0"
Expand Down
Loading