Skip to content

Commit

Permalink
refactor: moveout of nextjs (#15)
Browse files Browse the repository at this point in the history
* remove web, tsconfig, ui and minimize

* new @web

* Update main file path in wrangler.toml

* fix

* up latest and fix build

* Update TypeScript and Tailwind configurations

* fix

* fix trpc

* login

* implement turnstile cloudflare

* implement theme color

* error boundary for web

* fix tailwind

* fix logo

* sidebar

* logo dropdown menu

* profile dropdown menu

* done navigation and basic org detail page

* organization settings page

* update organization member

* fix typo

* accept invitation page

* fix permission check

* profile page

* fix close sidebar mobile on navigation

* improve

* fix user login when not belong to any organizations

* leave organization feat

* feat: delete organization

* check permission

* update env

* compatible date

* fix

* fix logout feat

* fix turnstile display

* update email template

* Update GitHub workflows to remove unnecessary matrix configuration

* Remove Cloudflare purge action

* fix color mutation status
  • Loading branch information
unnoq authored Dec 30, 2023
1 parent 9698829 commit dd33c32
Show file tree
Hide file tree
Showing 195 changed files with 4,568 additions and 4,862 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"overrides": [
{
"files": "./@ui/ui/**.*",
"files": "./@web/components/ui/**.*",
"rules": {
"react/prop-types": "off",
"react/no-unknown-property": "off"
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ on:

jobs:
deploy-preview:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [20.x]
runs-on: ubuntu-latest
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
DATABASE_URL: ${{ secrets.PREVIEW_DATABASE_URL }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- uses: pnpm/action-setup@v2

- run: pnpm i
Expand Down
15 changes: 1 addition & 14 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,14 @@ on:

jobs:
deploy-production:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [20.x]
runs-on: ubuntu-latest
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
DATABASE_URL: ${{ secrets.PRODUCTION_DATABASE_URL }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

- uses: pnpm/action-setup@v2

- run: pnpm i
Expand All @@ -33,8 +25,3 @@ jobs:
- run: pnpm run --filter @dinstack/api db:migrate

- run: pnpm run deploy:production

- uses: nathanvaughn/actions-cloudflare-purge@master
with:
cf_zone: ${{ secrets.CLOUDFLARE_ZONE_ID }}
cf_auth: ${{ secrets.CLOUDFLARE_API_TOKEN }}
35 changes: 8 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage

# next.js
.next/
out/
build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# turbo
.turbo

# vercel
.vercel
dist/
build/
.env
.dev.vars

.*/
!.github/
!.vscode/
3 changes: 1 addition & 2 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use-node-version = 20.10.0
auto-install-peers = true
shamefully-hoist = true
enable-pre-post-scripts = true
shamefully-hoist = true
5 changes: 2 additions & 3 deletions .vscode/settings.example.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"editor.formatOnSave": true,
"prettier.documentSelectors": ["**/*.astro"],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.organizeImports": false
"source.fixAll.eslint": "never",
"source.organizeImports": "never"
},
"typescript.tsdk": "node_modules/typescript/lib",
"files.associations": {
Expand Down
14 changes: 2 additions & 12 deletions @api/.dev.example.vars
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
WORKER_ENV="development" # development, production
APP_BASE_URL="http://localhost:4000/"

DATABASE_URL=
AUTH_SECRET="secret_value"
DATABASE_URL=
RESEND_API_KEY=
TURNSTILE_SECRET_KEY="1x0000000000000000000000000000000AA"

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URL="http://localhost:4000/oauth/google/callback"

RESEND_API_KEY=
RESEND_FROM="Dinh Le <[email protected]>"

GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
3 changes: 0 additions & 3 deletions @api/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions @api/router.ts → @api/core/router.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { authRouter } from './features/auth/router'
import { organizationRouter } from './features/organization/router'
import { procedure, router } from './trpc'
import { authRouter } from '@api/features/auth/router'
import { organizationRouter } from '@api/features/organization/router'
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'

export const appRouter = router({
Expand Down
4 changes: 2 additions & 2 deletions @api/trpc.ts → @api/core/trpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Context } from './context'
import type { Db } from './lib/db'
import type { Context } from '@api/lib/context'
import type { Db } from '@api/lib/db'
import { TRPCError, experimental_standaloneMiddleware, initTRPC } from '@trpc/server'
import SuperJSON from 'superjson'

Expand Down
4 changes: 2 additions & 2 deletions @api/worker.ts → @api/core/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*
* Learn more at https://developers.cloudflare.com/workers/
*/
import { createContext } from './context'
import { envSchema } from './env'
import { appRouter } from './router'
import { createContext } from '@api/lib/context'
import { envSchema } from '@api/lib/env'
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'

export default {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ CREATE TABLE IF NOT EXISTS "oauth_accounts" (
CONSTRAINT "oauth_accounts_provider_user_id_unique" UNIQUE("provider","user_id")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "organization_invitations" (
"secret_key" char(64) PRIMARY KEY NOT NULL,
"organization_id" uuid NOT NULL,
"email" varchar(255) NOT NULL,
"role" "organization_member_roles" DEFAULT 'member' NOT NULL,
"expired_at" timestamp NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "organization_invitations_organization_id_email_unique" UNIQUE("organization_id","email")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "organization_members" (
"organization_id" uuid NOT NULL,
"user_id" uuid NOT NULL,
Expand All @@ -45,7 +55,7 @@ CREATE TABLE IF NOT EXISTS "organizations" (
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "sessions" (
"id" char(64) PRIMARY KEY NOT NULL,
"secret_key" char(64) PRIMARY KEY NOT NULL,
"user_id" uuid NOT NULL,
"organization_id" uuid NOT NULL,
"headers" jsonb NOT NULL,
Expand All @@ -67,6 +77,12 @@ EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "organization_invitations" ADD CONSTRAINT "organization_invitations_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "organizations"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "organization_members" ADD CONSTRAINT "organization_members_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "organizations"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
Expand Down
14 changes: 0 additions & 14 deletions @api/database/migrations/0001_grey_wiccan.sql

This file was deleted.

1 change: 0 additions & 1 deletion @api/database/migrations/0002_medical_lilith.sql

This file was deleted.

2 changes: 0 additions & 2 deletions @api/database/migrations/0003_youthful_magneto.sql

This file was deleted.

70 changes: 67 additions & 3 deletions @api/database/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "be57e4a8-c363-4a94-93e7-dba50163ab8b",
"id": "18e1f6c0-bd33-48f9-bf23-0257f114c1af",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "5",
"dialect": "pg",
Expand Down Expand Up @@ -101,6 +101,70 @@
}
}
},
"organization_invitations": {
"name": "organization_invitations",
"schema": "",
"columns": {
"secret_key": {
"name": "secret_key",
"type": "char(64)",
"primaryKey": true,
"notNull": true
},
"organization_id": {
"name": "organization_id",
"type": "uuid",
"primaryKey": false,
"notNull": true
},
"email": {
"name": "email",
"type": "varchar(255)",
"primaryKey": false,
"notNull": true
},
"role": {
"name": "role",
"type": "organization_member_roles",
"primaryKey": false,
"notNull": true,
"default": "'member'"
},
"expired_at": {
"name": "expired_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp",
"primaryKey": false,
"notNull": true,
"default": "now()"
}
},
"indexes": {},
"foreignKeys": {
"organization_invitations_organization_id_organizations_id_fk": {
"name": "organization_invitations_organization_id_organizations_id_fk",
"tableFrom": "organization_invitations",
"tableTo": "organizations",
"columnsFrom": ["organization_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"organization_invitations_organization_id_email_unique": {
"name": "organization_invitations_organization_id_email_unique",
"nullsNotDistinct": false,
"columns": ["organization_id", "email"]
}
}
},
"organization_members": {
"name": "organization_members",
"schema": "",
Expand Down Expand Up @@ -201,8 +265,8 @@
"name": "sessions",
"schema": "",
"columns": {
"id": {
"name": "id",
"secret_key": {
"name": "secret_key",
"type": "char(64)",
"primaryKey": true,
"notNull": true
Expand Down
Loading

0 comments on commit dd33c32

Please sign in to comment.