{"_id":"@3mo.tony/unc.js","_rev":"2-79fed2d688d4c937969900c49f418745","name":"@3mo.tony/unc.js","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.2":{"name":"@3mo.tony/unc.js","version":"1.0.2","keywords":["unc.js","unc","cli","backend","scaffold","express","nestjs","mongoose","prisma","sequelize","crud","generator"],"license":"MIT","_id":"@3mo.tony/unc.js@1.0.2","maintainers":[{"name":"3mo.tony","email":"antoniosamy14@gmail.com"}],"homepage":"https://github.com/3mo-tony/uncjs#readme","bugs":{"url":"https://github.com/3mo-tony/uncjs/issues"},"bin":{"unc":"dist/index.js"},"dist":{"shasum":"4b04505a7322a3b1c9dc0071f001403763e187b9","tarball":"https://registry.npmjs.org/@3mo.tony/unc.js/-/unc.js-1.0.2.tgz","fileCount":294,"integrity":"sha512-NIXioUUq7JAh6e5goPN3Ktxm9/JiWHD3xyxOFXZ4M1j2FMvBIWWdiCq64lhDD4AuqXeTUmBlVW+ul+bBRtYFOQ==","signatures":[{"sig":"MEUCIQCJ0rKQ60XVTF8AfyIbsIudjUl6dKQaJoI7kvNQ8dBh7AIgYjA4Jmkva73uv0Hk+61qHFEJYYAvwZrsG3emLidvYwE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":222158},"type":"commonjs","gitHead":"b18ba4baa4fd0b014d6f68870fefe4579a71ee7b","scripts":{"dev":"tsx src/index.ts","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"3mo.tony","email":"antoniosamy14@gmail.com"},"repository":{"url":"git+https://github.com/3mo-tony/uncjs.git","type":"git"},"_npmVersion":"10.9.4","description":"Unc.js — light CLI to scaffold Express backends (JS/TS, Mongoose/Prisma/Sequelize)","directories":{},"_nodeVersion":"22.22.0","dependencies":{"prompts":"^2.4.2","commander":"^14.0.0","typescript":"^5.8.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.20.3","@types/node":"^24.3.0","@types/prompts":"^2.4.9"},"_npmOperationalInternal":{"tmp":"tmp/unc.js_1.0.2_1784823028731_0.3573344852192535","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@3mo.tony/unc.js","version":"1.0.4","description":"Unc.js — light CLI to scaffold Express backends (JS/TS, Mongoose/Prisma/Sequelize)","license":"MIT","type":"commonjs","bin":{"unc":"dist/index.js"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/3mo-tony/uncjs.git"},"bugs":{"url":"https://github.com/3mo-tony/uncjs/issues"},"homepage":"https://github.com/3mo-tony/uncjs#readme","scripts":{"build":"tsc","dev":"tsx src/index.ts","prepublishOnly":"npm run build"},"dependencies":{"commander":"^14.0.0","prompts":"^2.4.2","typescript":"^5.8.3"},"devDependencies":{"@types/node":"^24.3.0","@types/prompts":"^2.4.9","tsx":"^4.20.3"},"keywords":["unc","uncjs","cli","nodejs","node","express","expressjs","typescript","javascript","backend","api","rest-api","scaffold","scaffolding","boilerplate","starter","generator","code-generator","project-generator","crud","module-generator","mongoose","mongodb","prisma","sequelize","orm","eslint","prettier","husky"],"_id":"@3mo.tony/unc.js@1.0.4","gitHead":"06c162c2bd821be629fca24097f142d7a022af7d","_nodeVersion":"22.22.0","_npmVersion":"10.9.4","dist":{"integrity":"sha512-DPmM64jCTbCAnmUB3lT/lBHMT/aFBKks3I50ma81CuPsm142OcAurxOMTatuBETOe4Eml6gSs6wJsThRBWRluw==","shasum":"2e247999cf7922581d17e2e7d9c0201a955cea63","tarball":"https://registry.npmjs.org/@3mo.tony/unc.js/-/unc.js-1.0.4.tgz","fileCount":294,"unpackedSize":223255,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDZ+NrHW/eTPxG+4/oxVCqjNv3O36QkKchnYijFQ42WgQIgGs8G7f99WiEeAFfrBzcchld5eRFaE/2fYVzJEvPhYU8="}]},"_npmUser":{"name":"3mo.tony","email":"antoniosamy14@gmail.com"},"directories":{},"maintainers":[{"name":"3mo.tony","email":"antoniosamy14@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unc.js_1.0.4_1784826120758_0.2989127290646947"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-23T16:10:28.571Z","modified":"2026-07-23T17:02:01.073Z","1.0.2":"2026-07-23T16:10:28.914Z","1.0.4":"2026-07-23T17:02:00.926Z"},"bugs":{"url":"https://github.com/3mo-tony/uncjs/issues"},"license":"MIT","homepage":"https://github.com/3mo-tony/uncjs#readme","keywords":["unc","uncjs","cli","nodejs","node","express","expressjs","typescript","javascript","backend","api","rest-api","scaffold","scaffolding","boilerplate","starter","generator","code-generator","project-generator","crud","module-generator","mongoose","mongodb","prisma","sequelize","orm","eslint","prettier","husky"],"repository":{"type":"git","url":"git+https://github.com/3mo-tony/uncjs.git"},"description":"Unc.js — light CLI to scaffold Express backends (JS/TS, Mongoose/Prisma/Sequelize)","maintainers":[{"name":"3mo.tony","email":"antoniosamy14@gmail.com"}],"readme":"# Unc.js\n\nForge production-ready backends in seconds — layered architecture, your stack, your ORM.\n\n**Unc.js** (`unc` on the command line, like Nest’s `nest`) scaffolds Express apps (JS or TS), wires Mongoose / Prisma / Sequelize, and generates full CRUD modules so you ship features instead of folder plumbing.\n\n- **Bootstrap a new API** with optional ESLint, Prettier, and Husky\n- **Choose your language** — JavaScript or TypeScript (Express)\n- **Pick your ORM** — Mongoose, Prisma, or Sequelize\n- **Ship modules fast** — model, service, controller, routes, schemas, DTOs in one command\n- **Commit helpers included** — `commit-and-push.bat` / `commit-and-push.sh` format, lint, commit, and publish the branch if it is not on the remote yet\n\n---\n\n## Why use it?\n\nBuilding a new backend usually means copying the same boilerplate over and over: folder structure, path aliases, linting, database loader, service base class, and CRUD files for each entity.\n\n`unc` automates that workflow so you can focus on business logic instead of file plumbing.\n\n| Step | What you run | What you get |\n|---|---|---|\n| 1 | `unc init my-api` | Full project scaffold + BaseService + ORM setup |\n| 2 | `unc generate module events` | Model, service, controller, routes, schemas, DTOs |\n\n---\n\n## Installation\n\n### Global install (recommended for daily use)\n\n```bash\nnpm install -g @3mo.tony/unc.js\n```\n\nOr without a global install:\n\n```bash\nnpx @3mo.tony/unc.js init my-api\n```\n\n### Local development\n\n```bash\ngit clone <repo-url>\ncd unc.js\nnpm install\nnpm run build\nnpm link\n```\n\nAfter linking, the `unc` command is available globally on your machine (same idea as Nest’s `nest` CLI).\n\n---\n\n## Quick start\n\n```bash\n# 1. Interactive init (prompts for language, ORM, tooling — then npm install)\nunc init events-api\ncd events-api\n\n# 2. Generate a full CRUD module (BaseService is created during init)\nunc generate module events --fields \"name:string,startsAt:date,description:string:optional\"\n\n# 3. Start developing\nnpm run dev\n```\n\nNon-interactive example:\n\n```bash\nunc init events-api --language ts --orm mongoose --eslint --prettier --husky\n```\n\n### Commit helpers (included in generated apps)\n\nAfter `init`, every project includes:\n\n| File | Platform |\n|------|----------|\n| `commit-and-push.bat` | Windows |\n| `commit-and-push.sh` | macOS / Linux |\n\nThey run format → lint:fix → `git add` → commit → push. If the branch has **no upstream**, they publish it with `git push -u origin HEAD`.\n\n```bash\n# Windows\ncommit-and-push.bat \"feat: add events module\"\ncommit-and-push.bat \"feat: add events module\" -d \"Optional longer description\"\n\n# Unix\nchmod +x commit-and-push.sh\n./commit-and-push.sh \"feat: add events module\"\n./commit-and-push.sh \"feat: add events module\" -d \"Optional longer description\"\n```\n\n---\n\n## Generated project structure\n\nWhen you run `init`, the CLI creates a project based on the **Unc.js** layout:\n\n```\nsrc/\n├── adapters/           # External service adapters\n├── combined-services/  # Cross-model service orchestration\n├── config/             # Environment and app configuration\n├── constants/          # Endpoints, tables, messages\n├── contracts/          # Interfaces and DTO contracts\n├── controllers/        # Request handlers\n├── interceptors/       # Third-party API interceptors\n├── loaders/            # Express app + database bootstrapping\n├── locales/            # i18n translation files\n├── middlewares/        # Express middlewares\n├── models/             # Database models\n├── processes/          # Cron jobs and background tasks\n├── routes/             # API route definitions\n├── schemas/            # Zod validation schemas\n├── services/           # Business logic layer\n├── swagger/            # OpenAPI definitions\n├── types/              # Enums and DTO types\n├── utils/              # Shared utilities\n└── views/              # View templates\n```\n\nThe scaffold also includes:\n\n- **TypeScript** with strict mode and path aliases (`@services`, `@controllers`, `@schema`, etc.)\n- **ESLint v9** flat config + **Prettier**\n- **Express** server with `/api/v1` routing\n- **Zod** validation middleware\n- A `.uncjs.json` config file that records your ORM choice\n- **`commit-and-push.bat` / `commit-and-push.sh`** — one-shot format → lint → commit → push (creates remote tracking branch when missing)\n\n---\n\n## How module generation works\n\nRunning `unc generate module events` creates a full vertical slice for the `events` resource:\n\n### New files\n\n| File | Description |\n|---|---|\n| `src/models/events.model.ts` | Sequelize model or Mongoose schema |\n| `src/services/events.service.ts` | Service class extending `BaseService` |\n| `src/controllers/events.controller.ts` | CRUD controller (`create`, `getAll`, `getOne`, `update`, `delete`) |\n| `src/routes/events.routes.ts` | Express router with validation |\n| `src/contracts/events.interface.ts` | Entity interface and create DTO |\n| `src/schemas/events.schema.ts` | Zod create/update schemas |\n| `src/types/dtos/events/*.dto.ts` | Request/response TypeScript types |\n\n### Updated files\n\nThe CLI also patches existing barrel files and constants:\n\n- `src/models/index.ts` — exports the new model\n- `src/services/index.ts` — exports the new service\n- `src/controllers/index.ts` — exports the new controller\n- `src/contracts/index.ts` — exports the new interface\n- `src/schemas/index.ts` — exports the new schema\n- `src/types/dtos/index.ts` — exports the new DTO folder\n- `src/constants/endpoints.ts` — adds `EVENTS` to `GENERAL_ENDPOINTS` and `EVENTS_ENDPOINTS`\n- `src/constants/tables.ts` — adds `Events` entry (Sequelize only)\n- `src/routes/index.ts` — imports and mounts the new router\n\n### Service inheritance\n\nEvery generated service extends the ORM-specific `BaseService`:\n\n```typescript\nclass EventsService extends BaseService<IEventsModel, EventCreateDTO> {\n  constructor() {\n    super(EventsModel, Tables.Events)\n  }\n}\n```\n\nYou can add custom methods to the generated service file without losing the base CRUD behavior.\n\n---\n\n## ORM support\n\n### Sequelize (PostgreSQL)\n\n- Selected with `--orm sequelize` (default)\n- Adds `sequelize`, `pg`, and `pg-hstore` dependencies\n- Generates Sequelize models using `DataTypes`\n- Base service uses `ModelStatic`, transactions, and `include` for population\n- Table names are registered in `src/constants/tables.ts`\n\n### Mongoose (MongoDB)\n\n- Selected with `--orm mongoose`\n- Adds `mongoose` dependency\n- Generates Mongoose schemas with `Schema` and `model`\n- Base service uses `FilterQuery`, `find`, `findOneAndUpdate`, etc.\n- Controllers use `_id` for lookups instead of numeric `id`\n\nThe ORM is stored in `.uncjs.json` at the project root:\n\n```json\n{\n  \"version\": \"1.0.4\",\n  \"language\": \"ts\",\n  \"framework\": \"express\",\n  \"orm\": \"mongoose\",\n  \"eslint\": true,\n  \"prettier\": true,\n  \"husky\": false\n}\n```\n\nAll `generate` commands read this file to pick the correct templates.\n\n---\n\n## Field definition syntax\n\nWhen generating a module, define model fields with `--fields`:\n\n```bash\nunc generate module products --fields name:string,price:number,isActive:boolean,expiresAt:date\n```\n\n| Type | Maps to (Sequelize) | Maps to (Mongoose) | Maps to (Zod) |\n|---|---|---|---|\n| `string` | `DataTypes.STRING` | `String` | `z.string()` |\n| `number` | `DataTypes.INTEGER` | `Number` | `z.number()` |\n| `boolean` | `DataTypes.BOOLEAN` | `Boolean` | `z.boolean()` |\n| `date` | `DataTypes.DATE` | `Date` | `z.coerce.date()` |\n\nMark a field as optional by adding `:optional` as a third segment:\n\n```bash\n--fields name:string,description:string:optional\n```\n\nIf `--fields` is omitted, a default `name:string` field is used.\n\nOn PowerShell, always quote multi-field values (unquoted commas become spaces):\n\n```powershell\nunc generate module events --fields \"name:string,startsAt:date,description:string:optional\"\n```\n\n---\n\n## Configuration file\n\n`.uncjs.json` is created during `init` and is required for all `generate` commands.\n\n| Key | Description |\n|---|---|\n| `language` | `\"ts\"` or `\"js\"` |\n| `framework` | Currently `\"express\"` (NestJS coming later) |\n| `orm` | `\"mongoose\"`, `\"prisma\"`, or `\"sequelize\"` |\n| `eslint` | Whether ESLint was included |\n| `prettier` | Whether Prettier was included |\n| `husky` | Whether Husky was included |\n| `version` | CLI config schema version |\n\nIf you run `generate` outside an initialized project, the CLI will exit with an error asking you to run `init` first.\n\n---\n\n## Path aliases\n\nGenerated projects use TypeScript path aliases for clean imports:\n\n| Alias | Path |\n|---|---|\n| `@types` | `src/types` |\n| `@config` | `src/config` |\n| `@loaders` | `src/loaders` |\n| `@contracts` | `src/contracts` |\n| `@combinedServices` | `src/combined-services` |\n| `@services` | `src/services` |\n| `@utils` | `src/utils` |\n| `@routes` | `src/routes` |\n| `@controllers` | `src/controllers` |\n| `@constants` | `src/constants` |\n| `@models` | `src/models` |\n| `@schema` | `src/schemas` |\n| `@middlewares` | `src/middlewares` |\n| `@adapters` | `src/adapters` |\n| `@interceptors` | `src/interceptors` |\n| `@processes` | `src/processes` |\n\n---\n\n## Recommended workflow\n\n```\ninit  →  generate module(s)  →  npm run dev\n```\n\n1. **Initialize** the project (runs `npm install` for you)\n2. **Generate modules** for each entity/resource you need\n3. **Customize** generated files — add associations, business rules, auth middleware, etc.\n4. **Develop** with `npm run dev`\n6. **Run** with `npm run dev` or `npm run build && npm start`\n\n---\n\n## Scripts in generated apps\n\n| Script | Description |\n|---|---|\n| `npm run dev` | Start dev server with hot reload (`nodemon` + `tsx`) |\n| `npm run build` | Compile TypeScript and resolve path aliases |\n| `npm start` | Run compiled app from `dist/` |\n| `npm run start:ts` | Run TypeScript directly with `tsx` |\n| `npm run lint` | Run ESLint |\n| `npm run lint:fix` | Auto-fix lint issues |\n| `npm run format` | Format code with Prettier |\n\n---\n\n## Command reference\n\nFor a full breakdown of every command, flag, argument, and example, see **[COMMANDS.md](./COMMANDS.md)**.\n\n---\n\n## Troubleshooting\n\n### `Missing .uncjs.json`\n\nYou are not inside an initialized project. Run `unc init` first, or `cd` into the generated app directory.\n\n### `Base service not found`\n\nBaseService is generated during `init`. Re-run `unc generate base-service` only if you need to regenerate it.\n\n### `Directory is not empty`\n\n`init` will prompt for confirmation if the target folder already has files. Use `--force` to skip the prompt:\n\n```bash\nunc init my-api --force\n```\n\n### Wrong ORM templates\n\nThe ORM is set at `init` time and stored in `.uncjs.json`. To switch ORMs, create a new project or manually replace the base service and models.\n\n---\n\n## License\n\nISC\n","readmeFilename":"README.md"}