mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 01:21:09 +02:00
feat: add monorepo configuration and shared packages structure
Root-level setup: - package.json with Turborepo scripts - pnpm-workspace.yaml for workspace management - turbo.json for build pipeline - Common config files (.nvmrc, .prettierrc, .editorconfig) Shared packages (packages/): - @manacore/shared-types - Common TypeScript types - @manacore/shared-supabase - Unified Supabase client - @manacore/shared-utils - Date, string, async utilities - @manacore/shared-ui - React Native UI components (placeholder) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e7f5f942f3
commit
2c58d03f63
23 changed files with 738 additions and 0 deletions
24
packages/shared-supabase/package.json
Normal file
24
packages/shared-supabase/package.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@manacore/shared-supabase",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "Shared Supabase client and utilities for Manacore monorepo",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"scripts": {
|
||||
"type-check": "tsc --noEmit",
|
||||
"clean": "rm -rf dist"
|
||||
},
|
||||
"dependencies": {
|
||||
"@supabase/supabase-js": "^2.81.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^5.9.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@manacore/shared-types": "workspace:*"
|
||||
}
|
||||
}
|
||||
62
packages/shared-supabase/src/index.ts
Normal file
62
packages/shared-supabase/src/index.ts
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/**
|
||||
* Shared Supabase utilities for Manacore monorepo
|
||||
*
|
||||
* This package provides a unified Supabase client and common database utilities.
|
||||
*/
|
||||
|
||||
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
||||
import type { SupabaseConfig } from '@manacore/shared-types';
|
||||
|
||||
export { SupabaseClient } from '@supabase/supabase-js';
|
||||
|
||||
/**
|
||||
* Create a Supabase client with the given configuration
|
||||
*/
|
||||
export function createSupabaseClient(config: SupabaseConfig): SupabaseClient {
|
||||
return createClient(config.url, config.anonKey, {
|
||||
auth: {
|
||||
persistSession: true,
|
||||
autoRefreshToken: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Supabase admin client with service role key
|
||||
*/
|
||||
export function createSupabaseAdminClient(config: SupabaseConfig): SupabaseClient {
|
||||
if (!config.serviceRoleKey) {
|
||||
throw new Error('Service role key is required for admin client');
|
||||
}
|
||||
|
||||
return createClient(config.url, config.serviceRoleKey, {
|
||||
auth: {
|
||||
persistSession: false,
|
||||
autoRefreshToken: false,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Common database query helpers
|
||||
*/
|
||||
export const dbHelpers = {
|
||||
/**
|
||||
* Handle Supabase query result and return standardized response
|
||||
*/
|
||||
handleQueryResult<T>(result: { data: T | null; error: any }): {
|
||||
data: T | null;
|
||||
error: { message: string; code?: string } | null;
|
||||
} {
|
||||
if (result.error) {
|
||||
return {
|
||||
data: null,
|
||||
error: {
|
||||
message: result.error.message,
|
||||
code: result.error.code,
|
||||
},
|
||||
};
|
||||
}
|
||||
return { data: result.data, error: null };
|
||||
},
|
||||
};
|
||||
17
packages/shared-supabase/tsconfig.json
Normal file
17
packages/shared-supabase/tsconfig.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"lib": ["ES2020"],
|
||||
"strict": true,
|
||||
"esModuleInterop": true,
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"outDir": "./dist"
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue