feat: deploy standalone Hono/Bun auth and API backend
This commit is contained in:
13
src/types/context.ts
Normal file
13
src/types/context.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Hono context type definitions
|
||||
|
||||
import type { User } from '@vibncode/shared';
|
||||
import type { Env } from './env';
|
||||
|
||||
export type HonoContext = {
|
||||
Bindings: Env;
|
||||
Variables: {
|
||||
user?: User;
|
||||
userId?: string;
|
||||
deviceId?: string;
|
||||
};
|
||||
};
|
||||
47
src/types/database.ts
Normal file
47
src/types/database.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
// Type definitions for database tables
|
||||
import type { SQL } from 'drizzle-orm';
|
||||
import type {
|
||||
categories,
|
||||
marketplaceAgents,
|
||||
marketplaceSkills,
|
||||
skillCategories,
|
||||
skillTags,
|
||||
tags,
|
||||
users,
|
||||
} from '../db/schema';
|
||||
|
||||
// Types for database records
|
||||
export type CategoryRecord = typeof categories.$inferSelect;
|
||||
export type SkillCategoryRecord = typeof skillCategories.$inferSelect & {
|
||||
category: CategoryRecord;
|
||||
};
|
||||
export type TagRecord = typeof tags.$inferSelect;
|
||||
export type SkillTagRecord = typeof skillTags.$inferSelect & {
|
||||
tag: TagRecord;
|
||||
};
|
||||
export type MarketplaceSkillRecord = typeof marketplaceSkills.$inferSelect;
|
||||
|
||||
// User types
|
||||
export type DbUser = typeof users.$inferSelect;
|
||||
|
||||
// Category types (alias for backward compatibility)
|
||||
export type DbCategory = CategoryRecord;
|
||||
|
||||
// Marketplace types
|
||||
export type DbMarketplaceAgent = typeof marketplaceAgents.$inferSelect;
|
||||
|
||||
// Tag types (alias for backward compatibility)
|
||||
export type DbTag = TagRecord;
|
||||
|
||||
// Config types
|
||||
export type ToolsConfig = Record<string, boolean | string | number | null | undefined>;
|
||||
|
||||
export type DynamicPromptConfig = {
|
||||
enabled?: boolean;
|
||||
variables?: Record<string, string | number | boolean>;
|
||||
templates?: string[];
|
||||
providers?: string[];
|
||||
} | null;
|
||||
|
||||
// SQL condition type
|
||||
export type SQLCondition = SQL<unknown>;
|
||||
94
src/types/env.ts
Normal file
94
src/types/env.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
// Environment variables type definitions
|
||||
|
||||
export interface Env {
|
||||
TURSO_DATABASE_URL: string;
|
||||
TURSO_AUTH_TOKEN: string;
|
||||
JWT_SECRET: string;
|
||||
GITHUB_CLIENT_ID: string;
|
||||
GITHUB_CLIENT_SECRET: string;
|
||||
GOOGLE_CLIENT_ID: string;
|
||||
GOOGLE_CLIENT_SECRET: string;
|
||||
GOOGLE_REDIRECT_URI?: string;
|
||||
NODE_ENV?: string;
|
||||
RELEASES_BUCKET?: R2Bucket;
|
||||
TALKCODY_DAILY_TOKEN_LIMIT?: string;
|
||||
SERPER_API_KEY?: string;
|
||||
JINA_API_KEY?: string;
|
||||
}
|
||||
|
||||
// Cloudflare R2 Bucket type
|
||||
export interface R2Bucket {
|
||||
get(key: string): Promise<R2Object | null>;
|
||||
put(
|
||||
key: string,
|
||||
value: ReadableStream | ArrayBuffer | string,
|
||||
options?: R2PutOptions
|
||||
): Promise<R2Object>;
|
||||
delete(key: string): Promise<void>;
|
||||
list(options?: R2ListOptions): Promise<R2Objects>;
|
||||
}
|
||||
|
||||
export interface R2Object {
|
||||
key: string;
|
||||
version: string;
|
||||
size: number;
|
||||
etag: string;
|
||||
httpEtag: string;
|
||||
uploaded: Date;
|
||||
httpMetadata?: R2HTTPMetadata;
|
||||
customMetadata?: Record<string, string>;
|
||||
body: ReadableStream;
|
||||
bodyUsed: boolean;
|
||||
arrayBuffer(): Promise<ArrayBuffer>;
|
||||
text(): Promise<string>;
|
||||
json<T = unknown>(): Promise<T>;
|
||||
blob(): Promise<Blob>;
|
||||
}
|
||||
|
||||
export interface R2PutOptions {
|
||||
httpMetadata?: R2HTTPMetadata;
|
||||
customMetadata?: Record<string, string>;
|
||||
}
|
||||
|
||||
export interface R2HTTPMetadata {
|
||||
contentType?: string;
|
||||
contentLanguage?: string;
|
||||
contentDisposition?: string;
|
||||
contentEncoding?: string;
|
||||
cacheControl?: string;
|
||||
cacheExpiry?: Date;
|
||||
}
|
||||
|
||||
export interface R2ListOptions {
|
||||
limit?: number;
|
||||
prefix?: string;
|
||||
cursor?: string;
|
||||
delimiter?: string;
|
||||
include?: ('httpMetadata' | 'customMetadata')[];
|
||||
}
|
||||
|
||||
export interface R2Objects {
|
||||
objects: R2Object[];
|
||||
truncated: boolean;
|
||||
cursor?: string;
|
||||
delimitedPrefixes: string[];
|
||||
}
|
||||
|
||||
declare global {
|
||||
namespace Bun {
|
||||
interface Env {
|
||||
TURSO_DATABASE_URL: string;
|
||||
TURSO_AUTH_TOKEN: string;
|
||||
JWT_SECRET: string;
|
||||
GITHUB_CLIENT_ID: string;
|
||||
GITHUB_CLIENT_SECRET: string;
|
||||
GOOGLE_CLIENT_ID: string;
|
||||
GOOGLE_CLIENT_SECRET: string;
|
||||
GOOGLE_REDIRECT_URI?: string;
|
||||
NODE_ENV?: string;
|
||||
TALKCODY_DAILY_TOKEN_LIMIT?: string;
|
||||
SERPER_API_KEY?: string;
|
||||
JINA_API_KEY?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user