create-prism
v1.0.0
Published
A fast, no-nonsense CLI to scaffold Node.js + Express + Prisma (MySQL) starter projects in JavaScript or TypeScript.
Downloads
139
Maintainers
Readme
create-prism
A fast, no-nonsense CLI to scaffold Node.js + Express + Prisma (MySQL) starter projects in JavaScript or TypeScript.
Quick Start
Create a new project instantly using npx or npm create:
npx create-prism my-appnpm create prism my-appCLI Flags
You can bypass the interactive prompts by providing flags directly:
| Flag | Description |
|---|---|
| --js | Initialize a JavaScript project |
| --ts | Initialize a TypeScript project |
| --skip-install | Skip installing npm dependencies |
Example:
npx create-prism my-api --ts --skip-installWhat Gets Generated
Your scaffolded project will have the following flat, simplified structure. We intentionally omit separate models or middlewares folders to keep things straightforward—controllers query Prisma directly.
my-app/
├── prisma/
│ └── schema.prisma # Prisma schema (MySQL) with a sample User model
├── src/
│ ├── config/
│ │ └── db.(js|ts) # Prisma Client singleton
│ ├── controllers/
│ │ └── user.controller.(js|ts) # HTTP req/res handling and DB queries
│ ├── routes/
│ │ └── user.routes.(js|ts) # Express router definitions mapping to controllers
│ └── index.(js|ts) # Express app entry point that mounts routes
├── .env # Environment variables (e.g., DATABASE_URL)
└── package.json # Project dependencies and scriptsAdding a New Resource
We follow a simple 3-step convention for adding new resources (e.g., Post):
- Controller: Create
src/controllers/post.controller.(js|ts)and write your CRUD logic queryingprisma. - Routes: Create
src/routes/post.routes.(js|ts)to map HTTP endpoints to your controller methods. - Register: Import and mount the router in
src/index.(js|ts)usingapp.use('/posts', postRoutes).
Prerequisites
Before starting the generated app, ensure you have:
- Node.js (v16+)
- MySQL running locally or a remote database
- A valid
DATABASE_URLconfigured in your.envfile
Local Development
If you want to contribute or test the CLI locally:
# Clone the repository
git clone https://github.com/your-username/refract.git
cd refract
# Install dependencies
npm install
# Link the package globally to test the CLI
npm link
# Test the CLI locally
create-prism test-appContributing
Contributions are always welcome! Please open an issue or submit a pull request with any improvements or bug fixes. Ensure you follow the existing code style.
License
MIT
