
Product
Introducing Socket Scanning for OpenVSX Extensions
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
@ideal-photography/shared
Advanced tools
Shared MongoDB and utility logic for Ideal Photography PWAs: users, products, services, bookings, orders/cart, galleries, reviews, notifications, campaigns, settings, audit logs, and minimart items/orders.
A comprehensive shared package for photography business applications with MongoDB and Mongoose integration. It powers bookings, rentals, mini‑mart sales, client galleries, notifications, campaigns, settings, and admin workflows.
User, Product, Service, Booking, Order (cart/checkout/payments), Gallery, Review, Notification, Campaign, Settings, AuditLogrequireAuth, requireAdmin, role/permission checks (pluggable JWT verification placeholder)@ideal-photography/shared/validations/common.js)npm install @ideal-photography/shared
import express from 'express';
import { connectDB } from '@ideal-photography/shared';
const app = express();
// Connect to MongoDB
await connectDB(process.env.MONGODB_URI || 'mongodb://localhost:27017/ideal-photography');
app.listen(4000, () => {
console.log(`🚀 Server ready at http://localhost:4000`);
});
import express from 'express';
import { connectDB, models } from '@ideal-photography/shared';
const app = express();
// Connect to MongoDB
await connectDB(process.env.MONGODB_URI || 'mongodb://localhost:27017/ideal-photography');
// Use the models
const { User, Product, Booking } = models;
app.listen(4000, () => {
console.log(`🚀 Server ready at http://localhost:4000`);
});
import { models } from '@ideal-photography/shared';
// Create a user
const user = await models.User.create({
name: 'John Doe',
email: 'john@example.com',
password: 'securepassword123',
role: 'client'
});
// Create a booking
const booking = await models.Booking.create({
client: user._id,
product: productId,
date: new Date('2024-01-15'),
time: '14:00',
duration: 2,
totalAmount: 150,
location: {
type: 'studio',
address: '123 Studio St'
}
});
import {
isEmail,
isValidPrice,
isValidRating,
isValidBookingStatus
} from '@ideal-photography/shared/validations/common.js';
// Validate user input
if (!isEmail(email)) {
throw new Error('Invalid email format');
}
if (!isValidPrice(price)) {
throw new Error('Invalid price value');
}
me, users, user, userByEmail, stats/queuesmyCart, myOrders, orders, order, orderStats, revenue series, overdue rentalsThe models include optimized indexes for common queries:
expiresAtconst { models } = require('@ideal-photography/shared/mongoDB');
// Create a photography service
const service = await models.Service.create({
name: 'Portrait Session',
description: 'Professional portrait photography session',
category: 'portrait',
basePrice: 150,
priceStructure: {
type: 'fixed',
packageDetails: '2-hour session with 20 edited photos'
},
duration: { min: 1, max: 3 },
includes: ['Professional editing', 'Online gallery', 'Print rights'],
deliverables: {
photos: { digital: 20, prints: 5 },
editedPhotos: 20,
deliveryTime: '7-10 days',
format: ['jpeg', 'raw']
}
});
// Create a booking
const booking = await models.Booking.create({
client: userId,
product: service._id,
date: new Date('2024-01-20'),
time: '15:00',
duration: 2,
totalAmount: 150,
location: {
type: 'studio',
address: '123 Photography Studio'
},
contactInfo: {
phone: '+1234567890',
email: 'client@example.com'
}
});
// Get dashboard statistics
const stats = await models.Booking.aggregate([
{ $match: { status: { $in: ['confirmed', 'completed'] } } },
{ $group: {
_id: null,
totalBookings: { $sum: 1 },
totalRevenue: { $sum: '$totalAmount' }
}}
]);
// Get pending reviews for moderation
const pendingReviews = await models.Review.find({ isApproved: false })
.populate('client')
.populate('booking')
.sort({ createdAt: -1 });
Uservalidations/common.jsIf you're upgrading from Apollo Server v3, here are the key changes:
const { ApolloServer } = require('apollo-server-express');
const { typeDefs, resolvers } = require('@ideal-photography/shared/graphql');
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({ user: req.user }),
});
server.applyMiddleware({ app });
const { createApolloServer, applyApolloMiddleware } = require('@ideal-photography/shared/graphql');
const server = createApolloServer({
context: ({ req }) => ({ user: req.user }),
});
await applyApolloMiddleware(app, server);
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This package is provided under a proprietary license. See the LICENSE file for terms.
@apollo/client - GraphQL client for React applications@apollo/server - GraphQL server for Node.jsmongoose - MongoDB object modeling for Node.jsBuilt with ❤️ for the photography community
FAQs
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies