chore(memoro): remove old NestJS backends (Phase 8+9)
Delete apps/memoro/apps/backend/ (NestJS) and apps/memoro/apps/audio-backend/ (NestJS) — all functionality has been ported to the new Hono/Bun servers (apps/server/ and apps/audio-server/). Also clean up root and memoro package.json scripts to remove references to the old @memoro/backend and @memoro/audio-backend packages. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
|
@ -19,6 +19,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 1. Installation
|
||||
|
||||
- [ ] Install the package:
|
||||
|
||||
```bash
|
||||
npm install git+https://github.com/Memo-2023/mana-core-nestjs-package.git
|
||||
```
|
||||
|
|
@ -31,6 +32,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 2. Environment Configuration
|
||||
|
||||
- [ ] Create/update `.env` file:
|
||||
|
||||
```env
|
||||
MANA_SERVICE_URL=https://your-mana-instance.com
|
||||
APP_ID=your-app-id
|
||||
|
|
@ -47,17 +49,18 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
- [ ] Import `ManaCoreModule` in `app.module.ts`
|
||||
|
||||
- [ ] Configure with `forRootAsync()`:
|
||||
|
||||
```typescript
|
||||
ManaCoreModule.forRootAsync({
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
manaServiceUrl: 'your-mana-url',
|
||||
appId: 'your-app-id',
|
||||
serviceKey: configService.get('MANA_SUPABASE_SECRET_KEY'),
|
||||
debug: configService.get('NODE_ENV') === 'development',
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
})
|
||||
imports: [ConfigModule],
|
||||
useFactory: (configService: ConfigService) => ({
|
||||
manaServiceUrl: 'your-mana-url',
|
||||
appId: 'your-app-id',
|
||||
serviceKey: configService.get('MANA_SUPABASE_SECRET_KEY'),
|
||||
debug: configService.get('NODE_ENV') === 'development',
|
||||
}),
|
||||
inject: [ConfigService],
|
||||
});
|
||||
```
|
||||
|
||||
- [ ] Test backend starts without errors
|
||||
|
|
@ -65,11 +68,13 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 4. Protect Routes with AuthGuard
|
||||
|
||||
- [ ] Import `AuthGuard` in controller:
|
||||
|
||||
```typescript
|
||||
import { AuthGuard } from '@mana-core/nestjs-integration';
|
||||
```
|
||||
|
||||
- [ ] Apply to controller or route:
|
||||
|
||||
```typescript
|
||||
@Controller('protected')
|
||||
@UseGuards(AuthGuard)
|
||||
|
|
@ -81,11 +86,13 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 5. Extract User Information
|
||||
|
||||
- [ ] Import `@CurrentUser()` decorator:
|
||||
|
||||
```typescript
|
||||
import { CurrentUser } from '@mana-core/nestjs-integration';
|
||||
```
|
||||
|
||||
- [ ] Use in route handlers:
|
||||
|
||||
```typescript
|
||||
@Get('profile')
|
||||
async getProfile(@CurrentUser() user: JwtPayload) {
|
||||
|
|
@ -98,31 +105,31 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 6. Integrate Credit System
|
||||
|
||||
- [ ] Inject `CreditClientService`:
|
||||
|
||||
```typescript
|
||||
constructor(private creditClient: CreditClientService) {}
|
||||
```
|
||||
|
||||
- [ ] Add pre-flight credit validation:
|
||||
|
||||
```typescript
|
||||
const validation = await this.creditClient.validateCredits(
|
||||
userId,
|
||||
'operation_type',
|
||||
creditCost,
|
||||
);
|
||||
const validation = await this.creditClient.validateCredits(userId, 'operation_type', creditCost);
|
||||
```
|
||||
|
||||
- [ ] Add credit consumption after success:
|
||||
|
||||
```typescript
|
||||
await this.creditClient.consumeCredits(
|
||||
userId,
|
||||
'operation_type',
|
||||
creditCost,
|
||||
'Description',
|
||||
metadata,
|
||||
userId,
|
||||
'operation_type',
|
||||
creditCost,
|
||||
'Description',
|
||||
metadata
|
||||
);
|
||||
```
|
||||
|
||||
- [ ] Handle `InsufficientCreditsException`:
|
||||
|
||||
```typescript
|
||||
import { InsufficientCreditsException } from '@mana-core/nestjs-integration';
|
||||
```
|
||||
|
|
@ -132,18 +139,17 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 7. (Optional) Custom Token Decorator
|
||||
|
||||
- [ ] Create `@UserToken()` decorator for RLS:
|
||||
|
||||
```typescript
|
||||
// decorators/user.decorator.ts
|
||||
export const UserToken = createParamDecorator(
|
||||
(_data: unknown, ctx: ExecutionContext): string => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
const authHeader = request.headers.authorization;
|
||||
if (authHeader?.startsWith('Bearer ')) {
|
||||
return authHeader.substring(7);
|
||||
}
|
||||
return request.token;
|
||||
},
|
||||
);
|
||||
export const UserToken = createParamDecorator((_data: unknown, ctx: ExecutionContext): string => {
|
||||
const request = ctx.switchToHttp().getRequest();
|
||||
const authHeader = request.headers.authorization;
|
||||
if (authHeader?.startsWith('Bearer ')) {
|
||||
return authHeader.substring(7);
|
||||
}
|
||||
return request.token;
|
||||
});
|
||||
```
|
||||
|
||||
- [ ] Use for database RLS:
|
||||
|
|
@ -164,6 +170,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 1. Configure API Base URL
|
||||
|
||||
- [ ] Create `.env` file:
|
||||
|
||||
```env
|
||||
EXPO_PUBLIC_STORYTELLER_BACKEND_URL=http://localhost:3002
|
||||
```
|
||||
|
|
@ -178,17 +185,18 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
- [ ] Create `services/authService.ts`
|
||||
|
||||
- [ ] Implement sign-in:
|
||||
|
||||
```typescript
|
||||
signIn: async (email: string, password: string) => {
|
||||
const deviceInfo = await getDeviceInfo();
|
||||
const response = await fetch(`${BACKEND_URL}/auth/signin`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password, deviceInfo }),
|
||||
});
|
||||
const data = await response.json();
|
||||
await storeTokens(data.appToken, data.refreshToken);
|
||||
}
|
||||
const deviceInfo = await getDeviceInfo();
|
||||
const response = await fetch(`${BACKEND_URL}/auth/signin`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password, deviceInfo }),
|
||||
});
|
||||
const data = await response.json();
|
||||
await storeTokens(data.appToken, data.refreshToken);
|
||||
};
|
||||
```
|
||||
|
||||
- [ ] Implement sign-up
|
||||
|
|
@ -202,29 +210,31 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
- [ ] Create `services/tokenManager.ts`
|
||||
|
||||
- [ ] Implement `getValidToken()`:
|
||||
|
||||
```typescript
|
||||
getValidToken: async () => {
|
||||
let token = await storage.getItem('appToken');
|
||||
if (isExpiringSoon(token)) {
|
||||
await this.refreshToken();
|
||||
token = await storage.getItem('appToken');
|
||||
}
|
||||
return token;
|
||||
}
|
||||
let token = await storage.getItem('appToken');
|
||||
if (isExpiringSoon(token)) {
|
||||
await this.refreshToken();
|
||||
token = await storage.getItem('appToken');
|
||||
}
|
||||
return token;
|
||||
};
|
||||
```
|
||||
|
||||
- [ ] Implement `refreshToken()`:
|
||||
|
||||
```typescript
|
||||
refreshToken: async () => {
|
||||
const refreshToken = await storage.getItem('refreshToken');
|
||||
const deviceInfo = await getDeviceInfo();
|
||||
const response = await fetch(`${BACKEND_URL}/auth/refresh`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ refreshToken, deviceInfo }),
|
||||
});
|
||||
const data = await response.json();
|
||||
await storeTokens(data.appToken, data.refreshToken);
|
||||
}
|
||||
const refreshToken = await storage.getItem('refreshToken');
|
||||
const deviceInfo = await getDeviceInfo();
|
||||
const response = await fetch(`${BACKEND_URL}/auth/refresh`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ refreshToken, deviceInfo }),
|
||||
});
|
||||
const data = await response.json();
|
||||
await storeTokens(data.appToken, data.refreshToken);
|
||||
};
|
||||
```
|
||||
|
||||
- [ ] Test: Verify automatic refresh works
|
||||
|
|
@ -232,23 +242,24 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 4. Create Authenticated API Client
|
||||
|
||||
- [ ] Create `fetchWithAuth()` function:
|
||||
|
||||
```typescript
|
||||
export async function fetchWithAuth(endpoint: string, options = {}) {
|
||||
const token = await tokenManager.getValidToken();
|
||||
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
const token = await tokenManager.getValidToken();
|
||||
const response = await fetch(`${API_BASE_URL}${endpoint}`, {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.status === 401) {
|
||||
await tokenManager.refreshToken();
|
||||
// Retry request
|
||||
}
|
||||
if (response.status === 401) {
|
||||
await tokenManager.refreshToken();
|
||||
// Retry request
|
||||
}
|
||||
|
||||
return response;
|
||||
return response;
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -257,19 +268,21 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 5. Handle Credit Errors
|
||||
|
||||
- [ ] Create error handling utility:
|
||||
|
||||
```typescript
|
||||
export function isInsufficientCreditsError(error: any) {
|
||||
return error?.error === 'insufficient_credits';
|
||||
return error?.error === 'insufficient_credits';
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] Handle in UI:
|
||||
|
||||
```typescript
|
||||
if (data.error === 'insufficient_credits') {
|
||||
showPurchaseCreditsModal({
|
||||
required: data.requiredCredits,
|
||||
available: data.availableCredits,
|
||||
});
|
||||
showPurchaseCreditsModal({
|
||||
required: data.requiredCredits,
|
||||
available: data.availableCredits,
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -278,16 +291,17 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### 6. Device Management
|
||||
|
||||
- [ ] Create `utils/deviceManager.ts`:
|
||||
|
||||
```typescript
|
||||
export class DeviceManager {
|
||||
static async getDeviceInfo() {
|
||||
return {
|
||||
deviceId: await getOrCreateDeviceId(),
|
||||
deviceName: Platform.OS,
|
||||
deviceType: Platform.OS as 'ios' | 'android' | 'web',
|
||||
userAgent: getUserAgent(),
|
||||
};
|
||||
}
|
||||
static async getDeviceInfo() {
|
||||
return {
|
||||
deviceId: await getOrCreateDeviceId(),
|
||||
deviceName: Platform.OS,
|
||||
deviceType: Platform.OS as 'ios' | 'android' | 'web',
|
||||
userAgent: getUserAgent(),
|
||||
};
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
|
@ -302,6 +316,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### Backend Tests
|
||||
|
||||
- [ ] Create unit tests with mocked services:
|
||||
|
||||
```typescript
|
||||
{
|
||||
provide: CreditClientService,
|
||||
|
|
@ -341,6 +356,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### Backend
|
||||
|
||||
- [ ] Set production environment variables:
|
||||
|
||||
```env
|
||||
MANA_SERVICE_URL=https://production-mana.com
|
||||
APP_ID=production-app-id
|
||||
|
|
@ -357,6 +373,7 @@ Use this checklist when integrating `@mana-core/nestjs-integration` into a new N
|
|||
### Frontend
|
||||
|
||||
- [ ] Update `.env` for production:
|
||||
|
||||
```env
|
||||
EXPO_PUBLIC_BACKEND_URL=https://your-api.com
|
||||
```
|
||||
|
|
@ -439,6 +456,7 @@ Once all items are checked, your application is fully integrated with Mana Core.
|
|||
**Estimated Time**: 2-4 hours for basic integration, 1-2 days for complete implementation with testing.
|
||||
|
||||
**Next Steps**:
|
||||
|
||||
1. Define your operation types and credit costs
|
||||
2. Implement purchase flow for credits
|
||||
3. Add analytics and monitoring
|
||||
|
|
@ -4,14 +4,11 @@ import sitemap from '@astrojs/sitemap';
|
|||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: 'https://manadeck.app',
|
||||
integrations: [
|
||||
tailwind(),
|
||||
sitemap()
|
||||
],
|
||||
vite: {
|
||||
ssr: {
|
||||
noExternal: ['@manacore/shared-landing-ui']
|
||||
}
|
||||
}
|
||||
site: 'https://manadeck.app',
|
||||
integrations: [tailwind(), sitemap()],
|
||||
vite: {
|
||||
ssr: {
|
||||
noExternal: ['@manacore/shared-landing-ui'],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Before Width: | Height: | Size: 211 B After Width: | Height: | Size: 211 B |
37
apps/cards/apps/landing/tailwind.config.mjs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
'./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}',
|
||||
'../../packages/shared-landing-ui/src/**/*.{astro,html,js,jsx,ts,tsx}',
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// ManaDeck Purple Theme
|
||||
primary: {
|
||||
DEFAULT: '#7C3AED',
|
||||
hover: '#8B5CF6',
|
||||
glow: 'rgba(124, 58, 237, 0.3)',
|
||||
},
|
||||
background: {
|
||||
page: '#0f0a1a',
|
||||
card: '#1a1625',
|
||||
'card-hover': '#2d2640',
|
||||
},
|
||||
text: {
|
||||
primary: '#f9fafb',
|
||||
secondary: '#d1d5db',
|
||||
muted: '#6b7280',
|
||||
},
|
||||
border: {
|
||||
DEFAULT: '#3d3555',
|
||||
hover: '#4d4570',
|
||||
},
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'system-ui', 'sans-serif'],
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [require('@tailwindcss/typography')],
|
||||
};
|
||||
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 46 KiB |