nextjs-api-generator
v1.0.2
Published
A tool to generate Next.js API structure with MongoDB integration.
Downloads
6
Readme
Next.js API Generator
A tool to generate Next.js API structure with MongoDB integration.
Installation
Create a .env file in the root of your project and save your database uri in a var called NEXT_PUBLIC_DB_URI
npm install -g nextjs-api-generator
Usage
create-nextjs-api <base-path> <comma-separated-endpoint-names>
Example
create-nextjs-api ./my-nextjs-app user,post,comment
This will create the following folder structure
my-nextjs-app/ ├── api/ │ ├── user/ │ │ ├── route.ts │ │ └── [id]/ │ │ └── route.ts │ ├── post/ │ │ ├── route.ts │ │ └── [id]/ │ │ └── route.ts │ └── comment/ │ ├── route.ts │ └── [id]/ │ └── route.ts ├── database/ │ └── database.ts └── models/ ├── User.ts ├── Post.ts └── Comment.ts