- Add controllers (Auth, Chat, Event) with placeholder implementations - Add services (Auth, Chat, Event) with business logic interfaces - Add repositories with MongoDB/Mongoose models (User, Event, Chat) - Add middleware for JWT authentication - Add Claude AI adapter implementing AIProvider interface - Add utility modules for JWT and password handling - Add shared types and DTOs for User, CalendarEvent, ChatMessage - Configure routes with proper endpoint structure - Update app.ts with dependency injection setup - Add required dependencies: mongoose, bcrypt, jsonwebtoken, @anthropic-ai/sdk
57 lines
1.1 KiB
TypeScript
57 lines
1.1 KiB
TypeScript
import mongoose, { Schema, Document } from 'mongoose';
|
|
import { CalendarEvent } from '@caldav/shared';
|
|
|
|
export interface EventDocument extends Omit<CalendarEvent, 'id'>, Document {}
|
|
|
|
const EventSchema = new Schema<EventDocument>(
|
|
{
|
|
userId: {
|
|
type: String,
|
|
required: true,
|
|
index: true,
|
|
},
|
|
title: {
|
|
type: String,
|
|
required: true,
|
|
trim: true,
|
|
},
|
|
description: {
|
|
type: String,
|
|
trim: true,
|
|
},
|
|
startTime: {
|
|
type: Date,
|
|
required: true,
|
|
},
|
|
endTime: {
|
|
type: Date,
|
|
required: true,
|
|
},
|
|
note: {
|
|
type: String,
|
|
},
|
|
isRecurring: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
recurrenceRule: {
|
|
type: String,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
toJSON: {
|
|
transform: (_, ret: Record<string, unknown>) => {
|
|
ret.id = String(ret._id);
|
|
delete ret._id;
|
|
delete ret.__v;
|
|
return ret;
|
|
},
|
|
},
|
|
}
|
|
);
|
|
|
|
EventSchema.index({ userId: 1, startTime: 1, endTime: 1 });
|
|
|
|
export const EventModel = mongoose.model<EventDocument>('Event', EventSchema);
|