create-postpipe-appointment
v1.0.2
Published
CLI to scaffold PostPipe Appointment System
Downloads
297
Readme
create-postpipe-appointment
A CLI tool to scaffold a production-ready Appointment System for Next.js applications using MongoDB and Mongoose.
Features
- 📅 Appointment Model: Complete Mongoose schema with validation.
- 🚀 Server Actions: Ready-to-use Next.js Server Actions for creating and fetching appointments.
- 🔌 API Routes: Standard Next.js API route handlers.
- 🛡️ Type Safety: Fully typed with TypeScript.
- 📦 Zero Config: Installs necessary dependencies (
mongoose,zod) automatically.
Installation
Run the following command in your Next.js project root:
npx create-postpipe-appointmentWhat it does
- Prompts you to confirm the database (currently supports MongoDB).
- Copies the following files to your project:
lib/models/Appointment.ts: The Mongoose model.lib/actions/appointment.ts: Server actions for form submissions.lib/dbConnect.ts: MongoDB connection utility (if not present).app/api/appointment/route.ts: API route handler.
- Installs required dependencies:
mongoose,zod. - Configures your
.envfile with a placeholderDATABASE_URI.
Usage
After running the CLI, you can use the generated Server Actions in your components:
"use client";
import { useFormState } from "react-dom";
import { createAppointment } from "@/lib/actions/appointment";
export default function AppointmentForm() {
const [state, formAction] = useFormState(createAppointment, {
message: "",
success: false,
});
return (
<form action={formAction}>
<input name="name" placeholder="Name" required />
<input name="email" type="email" placeholder="Email" required />
<input name="date" type="date" required />
<input name="time" type="time" required />
<textarea name="reason" placeholder="Reason" required />
<button type="submit">Book Appointment</button>
{state.message && <p>{state.message}</p>}
</form>
);
}Requirements
- Next.js (App Router recommended)
- MongoDB Database
License
CC-BY-NC-SA-4.0
