Follow along with the video below to see how to install our site as a web app on your home screen.
Note: this_feature_currently_requires_accessing_site_using_safari
Nice CRUD operation definition so far,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();