Dating app code ? Invite

Are you in for coding

  • Yes

    Votes: 5 83.3%
  • No

    Votes: 0 0.0%
  • If yes ping me here

    Votes: 1 16.7%
  • If no suggestions?

    Votes: 0 0.0%

  • Total voters
    6

MalvikaA

New Member
import { Waitlist, InsertWaitlist, User, InsertUser } from "@shared/schema";

// Storage interface with necessary CRUD operations
export interface IStorage {
// User operations
getUser(id: number): Promise<User | undefined>;
getUserByUsername(username: string): Promise<User | undefined>;
getUserByEmail(email: string): Promise<User | undefined>;
createUser(user: InsertUser): Promise<User>;

// Waitlist operations
getWaitlistEntries(): Promise<Waitlist[]>;
getWaitlistEntryByEmail(email: string): Promise<Waitlist | undefined>;
createWaitlistEntry(entry: InsertWaitlist): Promise<Waitlist>;
}

// In-memory implementation of storage
export class MemStorage implements IStorage {
private users: Map<number, User>;
private waitlist: Map<number, Waitlist>;
private userCurrentId: number;
private waitlistCurrentId: number;

constructor() {
this.users = new Map();
this.waitlist = new Map();
this.userCurrentId = 1;
this.waitlistCurrentId = 1;
}

// User methods
async getUser(id: number): Promise<User | undefined> {
return this.users.get(id);
}

async getUserByUsername(username: string): Promise<User | undefined> {
return Array.from(this.users.values()).find(
(user) => user.username === username,
);
}

async getUserByEmail(email: string): Promise<User | undefined> {
return Array.from(this.users.values()).find(
(user) => user.email === email,
);
}

async createUser(insertUser: InsertUser): Promise<User> {
const id = this.userCurrentId++;
const now = new Date().toISOString();
const user: User = { ...insertUser, id, createdAt: now };
this.users.set(id, user);
return user;
}

// Waitlist methods
async getWaitlistEntries(): Promise<Waitlist[]> {
return Array.from(this.waitlist.values());
}

async getWaitlistEntryByEmail(email: string): Promise<Waitlist | undefined> {
return Array.from(this.waitlist.values()).find(
(entry) => entry.email === email,
);
}

async createWaitlistEntry(insertEntry: InsertWaitlist): Promise<Waitlist> {
const id = this.waitlistCurrentId++;
const now = new Date().toISOString();
const entry: Waitlist = { ...insertEntry, id, createdAt: now };
this.waitlist.set(id, entry);
return entry;
}
}

export const storage = new MemStorage();
 

Lucifer_m

Active Member
import { Waitlist, InsertWaitlist, User, InsertUser } from "@shared/schema";

// Storage interface with necessary CRUD operations
export interface IStorage {
// User operations
getUser(id: number): Promise<User | undefined>;
getUserByUsername(username: string): Promise<User | undefined>;
getUserByEmail(email: string): Promise<User | undefined>;
createUser(user: InsertUser): Promise<User>;

// Waitlist operations
getWaitlistEntries(): Promise<Waitlist[]>;
getWaitlistEntryByEmail(email: string): Promise<Waitlist | undefined>;
createWaitlistEntry(entry: InsertWaitlist): Promise<Waitlist>;
}

// In-memory implementation of storage
export class MemStorage implements IStorage {
private users: Map<number, User>;
private waitlist: Map<number, Waitlist>;
private userCurrentId: number;
private waitlistCurrentId: number;

constructor() {
this.users = new Map();
this.waitlist = new Map();
this.userCurrentId = 1;
this.waitlistCurrentId = 1;
}

// User methods
async getUser(id: number): Promise<User | undefined> {
return this.users.get(id);
}

async getUserByUsername(username: string): Promise<User | undefined> {
return Array.from(this.users.values()).find(
(user) => user.username === username,
);
}

async getUserByEmail(email: string): Promise<User | undefined> {
return Array.from(this.users.values()).find(
(user) => user.email === email,
);
}

async createUser(insertUser: InsertUser): Promise<User> {
const id = this.userCurrentId++;
const now = new Date().toISOString();
const user: User = { ...insertUser, id, createdAt: now };
this.users.set(id, user);
return user;
}

// Waitlist methods
async getWaitlistEntries(): Promise<Waitlist[]> {
return Array.from(this.waitlist.values());
}

async getWaitlistEntryByEmail(email: string): Promise<Waitlist | undefined> {
return Array.from(this.waitlist.values()).find(
(entry) => entry.email === email,
);
}

async createWaitlistEntry(insertEntry: InsertWaitlist): Promise<Waitlist> {
const id = this.waitlistCurrentId++;
const now = new Date().toISOString();
const entry: Waitlist = { ...insertEntry, id, createdAt: now };
this.waitlist.set(id, entry);
return entry;
}
}

export const storage = new MemStorage();
Nice CRUD operation definition so far,
What's the next step?
Going to implement the match making logic?
And what about the frontend ?

BTW I'm in if u need me...
 
Back
Top