nestforge-generator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +371 -0
  3. package/README.pt-BR.md +370 -0
  4. package/dist/features/auth-strategy.js +19 -0
  5. package/dist/features/auth-strategy.js.map +1 -0
  6. package/dist/features/database.js +59 -0
  7. package/dist/features/database.js.map +1 -0
  8. package/dist/features/dependencies.js +57 -0
  9. package/dist/features/dependencies.js.map +1 -0
  10. package/dist/features/language.js +172 -0
  11. package/dist/features/language.js.map +1 -0
  12. package/dist/features/markers.js +116 -0
  13. package/dist/features/markers.js.map +1 -0
  14. package/dist/generator.js +120 -0
  15. package/dist/generator.js.map +1 -0
  16. package/dist/index.js +59 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/prompts.js +137 -0
  19. package/dist/prompts.js.map +1 -0
  20. package/package.json +76 -0
  21. package/templates/drizzle/.env.example +45 -0
  22. package/templates/drizzle/.env.test +38 -0
  23. package/templates/drizzle/.github/workflows/ci.yml +119 -0
  24. package/templates/drizzle/ARCHITECTURE.md +227 -0
  25. package/templates/drizzle/ARCHITECTURE.pt-BR.md +225 -0
  26. package/templates/drizzle/CODE_OF_CONDUCT.md +29 -0
  27. package/templates/drizzle/CODE_OF_CONDUCT.pt-BR.md +27 -0
  28. package/templates/drizzle/CONTRIBUTING.md +57 -0
  29. package/templates/drizzle/CONTRIBUTING.pt-BR.md +54 -0
  30. package/templates/drizzle/Dockerfile +43 -0
  31. package/templates/drizzle/LICENSE +21 -0
  32. package/templates/drizzle/README.md +257 -0
  33. package/templates/drizzle/README.pt-BR.md +257 -0
  34. package/templates/drizzle/ROADMAP.md +143 -0
  35. package/templates/drizzle/ROADMAP.pt-BR.md +143 -0
  36. package/templates/drizzle/TESTING.md +136 -0
  37. package/templates/drizzle/TESTING.pt-BR.md +136 -0
  38. package/templates/drizzle/docker-compose.yml +82 -0
  39. package/templates/drizzle/docs/adding-a-module.md +585 -0
  40. package/templates/drizzle/docs/features-markers.md +457 -0
  41. package/templates/drizzle/drizzle.config.ts +49 -0
  42. package/templates/drizzle/nest-cli.json +8 -0
  43. package/templates/drizzle/package.json +96 -0
  44. package/templates/drizzle/src/app.module.ts +72 -0
  45. package/templates/drizzle/src/auth/auth.controller.ts +283 -0
  46. package/templates/drizzle/src/auth/auth.module.ts +81 -0
  47. package/templates/drizzle/src/auth/auth.service.spec.ts +111 -0
  48. package/templates/drizzle/src/auth/auth.service.ts +631 -0
  49. package/templates/drizzle/src/auth/drizzle-session.store.ts +263 -0
  50. package/templates/drizzle/src/auth/dto/forgot-password.dto.ts +9 -0
  51. package/templates/drizzle/src/auth/dto/login.dto.ts +10 -0
  52. package/templates/drizzle/src/auth/dto/refresh-token.dto.ts +9 -0
  53. package/templates/drizzle/src/auth/dto/register.dto.ts +11 -0
  54. package/templates/drizzle/src/auth/dto/reset-password.dto.ts +10 -0
  55. package/templates/drizzle/src/auth/guards/github-auth.guard.ts +10 -0
  56. package/templates/drizzle/src/auth/guards/google-auth.guard.ts +10 -0
  57. package/templates/drizzle/src/auth/guards/jwt-auth.guard.ts +25 -0
  58. package/templates/drizzle/src/auth/guards/session-auth.guard.spec.ts +77 -0
  59. package/templates/drizzle/src/auth/guards/session-auth.guard.ts +37 -0
  60. package/templates/drizzle/src/auth/session.service.spec.ts +74 -0
  61. package/templates/drizzle/src/auth/session.service.ts +96 -0
  62. package/templates/drizzle/src/auth/strategies/github.strategy.ts +41 -0
  63. package/templates/drizzle/src/auth/strategies/google.strategy.ts +43 -0
  64. package/templates/drizzle/src/auth/strategies/jwt.strategy.ts +25 -0
  65. package/templates/drizzle/src/auth/token.service.ts +175 -0
  66. package/templates/drizzle/src/common/constants/permissions.ts +8 -0
  67. package/templates/drizzle/src/common/constants/role-permissions.ts +9 -0
  68. package/templates/drizzle/src/common/constants/role.enum.ts +5 -0
  69. package/templates/drizzle/src/common/decorators/current-user.decorator.ts +8 -0
  70. package/templates/drizzle/src/common/decorators/permissions.decorator.ts +7 -0
  71. package/templates/drizzle/src/common/decorators/public.decorator.ts +4 -0
  72. package/templates/drizzle/src/common/decorators/roles.decorator.ts +6 -0
  73. package/templates/drizzle/src/common/filters/http-exception.filter.ts +34 -0
  74. package/templates/drizzle/src/common/guards/permissions.guard.spec.ts +54 -0
  75. package/templates/drizzle/src/common/guards/permissions.guard.ts +28 -0
  76. package/templates/drizzle/src/common/guards/roles.guard.spec.ts +37 -0
  77. package/templates/drizzle/src/common/guards/roles.guard.ts +24 -0
  78. package/templates/drizzle/src/common/interceptors/logging.interceptor.ts +23 -0
  79. package/templates/drizzle/src/common/middleware/csrf.middleware.spec.ts +97 -0
  80. package/templates/drizzle/src/common/middleware/csrf.middleware.ts +46 -0
  81. package/templates/drizzle/src/common/utils/avatar-storage.util.ts +32 -0
  82. package/templates/drizzle/src/common/utils/hash.util.ts +5 -0
  83. package/templates/drizzle/src/config/env.validation.ts +50 -0
  84. package/templates/drizzle/src/database/database-lifecycle.service.ts +30 -0
  85. package/templates/drizzle/src/database/database.constants.ts +2 -0
  86. package/templates/drizzle/src/database/database.decorators.ts +5 -0
  87. package/templates/drizzle/src/database/database.module.ts +96 -0
  88. package/templates/drizzle/src/database/database.types.ts +28 -0
  89. package/templates/drizzle/src/database/schema/index.ts +11 -0
  90. package/templates/drizzle/src/database/schema/mysql.schema.ts +215 -0
  91. package/templates/drizzle/src/database/schema/postgres.schema.ts +218 -0
  92. package/templates/drizzle/src/database/schema/sqlite.schema.ts +190 -0
  93. package/templates/drizzle/src/database/seed.ts +152 -0
  94. package/templates/drizzle/src/health/health.controller.ts +49 -0
  95. package/templates/drizzle/src/health/health.module.ts +19 -0
  96. package/templates/drizzle/src/health/indicators/drizzle-health.indicator.spec.ts +71 -0
  97. package/templates/drizzle/src/health/indicators/drizzle-health.indicator.ts +52 -0
  98. package/templates/drizzle/src/health/indicators/redis-health.indicator.spec.ts +54 -0
  99. package/templates/drizzle/src/health/indicators/redis-health.indicator.ts +33 -0
  100. package/templates/drizzle/src/mail/mail.module.ts +12 -0
  101. package/templates/drizzle/src/mail/mail.processor.ts +48 -0
  102. package/templates/drizzle/src/mail/mail.service.ts +24 -0
  103. package/templates/drizzle/src/mail/templates/email-templates.ts +28 -0
  104. package/templates/drizzle/src/main.ts +145 -0
  105. package/templates/drizzle/src/metrics/metrics.controller.ts +22 -0
  106. package/templates/drizzle/src/metrics/metrics.interceptor.ts +30 -0
  107. package/templates/drizzle/src/metrics/metrics.module.ts +12 -0
  108. package/templates/drizzle/src/metrics/metrics.service.ts +34 -0
  109. package/templates/drizzle/src/types/express-session.d.ts +13 -0
  110. package/templates/drizzle/src/users/dto/create-user.dto.ts +12 -0
  111. package/templates/drizzle/src/users/dto/find-users-query.dto.ts +12 -0
  112. package/templates/drizzle/src/users/dto/update-user.dto.ts +6 -0
  113. package/templates/drizzle/src/users/entities/user.entity.ts +23 -0
  114. package/templates/drizzle/src/users/users.controller.ts +165 -0
  115. package/templates/drizzle/src/users/users.module.ts +10 -0
  116. package/templates/drizzle/src/users/users.service.spec.ts +301 -0
  117. package/templates/drizzle/src/users/users.service.ts +213 -0
  118. package/templates/drizzle/test/auth.e2e-spec.ts +114 -0
  119. package/templates/drizzle/test/session-auth.e2e-spec.ts +163 -0
  120. package/templates/drizzle/test/users.e2e-spec.ts +212 -0
  121. package/templates/drizzle/test/utils/clean-database.ts +104 -0
  122. package/templates/drizzle/test/utils/e2e-setup.ts +77 -0
  123. package/templates/drizzle/tsconfig.build.json +4 -0
  124. package/templates/drizzle/tsconfig.json +25 -0
  125. package/templates/drizzle/vitest.config.ts +20 -0
  126. package/templates/drizzle/vitest.e2e.config.ts +19 -0
  127. package/templates/prisma/.env.example +44 -0
  128. package/templates/prisma/.env.test +37 -0
  129. package/templates/prisma/.github/workflows/ci.yml +109 -0
  130. package/templates/prisma/ARCHITECTURE.md +70 -0
  131. package/templates/prisma/ARCHITECTURE.pt-BR.md +63 -0
  132. package/templates/prisma/CODE_OF_CONDUCT.md +29 -0
  133. package/templates/prisma/CODE_OF_CONDUCT.pt-BR.md +27 -0
  134. package/templates/prisma/CONTRIBUTING.md +57 -0
  135. package/templates/prisma/CONTRIBUTING.pt-BR.md +54 -0
  136. package/templates/prisma/Dockerfile +33 -0
  137. package/templates/prisma/LICENSE +21 -0
  138. package/templates/prisma/README.md +267 -0
  139. package/templates/prisma/README.pt-BR.md +267 -0
  140. package/templates/prisma/ROADMAP.md +75 -0
  141. package/templates/prisma/ROADMAP.pt-BR.md +65 -0
  142. package/templates/prisma/TESTING.md +123 -0
  143. package/templates/prisma/TESTING.pt-BR.md +123 -0
  144. package/templates/prisma/docker-compose.yml +78 -0
  145. package/templates/prisma/docs/adding-a-module.md +230 -0
  146. package/templates/prisma/docs/features-markers.md +50 -0
  147. package/templates/prisma/nest-cli.json +8 -0
  148. package/templates/prisma/package.json +95 -0
  149. package/templates/prisma/prisma/schema.prisma +105 -0
  150. package/templates/prisma/prisma/seed.ts +46 -0
  151. package/templates/prisma/src/app.module.ts +72 -0
  152. package/templates/prisma/src/auth/auth.controller.ts +283 -0
  153. package/templates/prisma/src/auth/auth.module.ts +59 -0
  154. package/templates/prisma/src/auth/auth.service.spec.ts +53 -0
  155. package/templates/prisma/src/auth/auth.service.ts +224 -0
  156. package/templates/prisma/src/auth/dto/forgot-password.dto.ts +9 -0
  157. package/templates/prisma/src/auth/dto/login.dto.ts +10 -0
  158. package/templates/prisma/src/auth/dto/refresh-token.dto.ts +9 -0
  159. package/templates/prisma/src/auth/dto/register.dto.ts +11 -0
  160. package/templates/prisma/src/auth/dto/reset-password.dto.ts +10 -0
  161. package/templates/prisma/src/auth/guards/github-auth.guard.ts +10 -0
  162. package/templates/prisma/src/auth/guards/google-auth.guard.ts +10 -0
  163. package/templates/prisma/src/auth/guards/jwt-auth.guard.ts +25 -0
  164. package/templates/prisma/src/auth/guards/session-auth.guard.spec.ts +77 -0
  165. package/templates/prisma/src/auth/guards/session-auth.guard.ts +37 -0
  166. package/templates/prisma/src/auth/session.service.spec.ts +74 -0
  167. package/templates/prisma/src/auth/session.service.ts +96 -0
  168. package/templates/prisma/src/auth/strategies/github.strategy.ts +41 -0
  169. package/templates/prisma/src/auth/strategies/google.strategy.ts +43 -0
  170. package/templates/prisma/src/auth/strategies/jwt.strategy.ts +25 -0
  171. package/templates/prisma/src/auth/token.service.ts +84 -0
  172. package/templates/prisma/src/common/constants/permissions.ts +8 -0
  173. package/templates/prisma/src/common/constants/role-permissions.ts +9 -0
  174. package/templates/prisma/src/common/decorators/current-user.decorator.ts +8 -0
  175. package/templates/prisma/src/common/decorators/permissions.decorator.ts +7 -0
  176. package/templates/prisma/src/common/decorators/public.decorator.ts +4 -0
  177. package/templates/prisma/src/common/decorators/roles.decorator.ts +6 -0
  178. package/templates/prisma/src/common/filters/http-exception.filter.ts +34 -0
  179. package/templates/prisma/src/common/guards/permissions.guard.spec.ts +54 -0
  180. package/templates/prisma/src/common/guards/permissions.guard.ts +28 -0
  181. package/templates/prisma/src/common/guards/roles.guard.spec.ts +37 -0
  182. package/templates/prisma/src/common/guards/roles.guard.ts +24 -0
  183. package/templates/prisma/src/common/interceptors/logging.interceptor.ts +23 -0
  184. package/templates/prisma/src/common/middleware/csrf.middleware.spec.ts +97 -0
  185. package/templates/prisma/src/common/middleware/csrf.middleware.ts +46 -0
  186. package/templates/prisma/src/common/utils/avatar-storage.util.ts +32 -0
  187. package/templates/prisma/src/common/utils/hash.util.ts +5 -0
  188. package/templates/prisma/src/config/env.validation.ts +49 -0
  189. package/templates/prisma/src/database/prisma.module.ts +9 -0
  190. package/templates/prisma/src/database/prisma.service.ts +13 -0
  191. package/templates/prisma/src/health/health.controller.ts +49 -0
  192. package/templates/prisma/src/health/health.module.ts +19 -0
  193. package/templates/prisma/src/health/indicators/prisma-health.indicator.spec.ts +22 -0
  194. package/templates/prisma/src/health/indicators/prisma-health.indicator.ts +19 -0
  195. package/templates/prisma/src/health/indicators/redis-health.indicator.spec.ts +54 -0
  196. package/templates/prisma/src/health/indicators/redis-health.indicator.ts +33 -0
  197. package/templates/prisma/src/mail/mail.module.ts +12 -0
  198. package/templates/prisma/src/mail/mail.processor.ts +48 -0
  199. package/templates/prisma/src/mail/mail.service.ts +24 -0
  200. package/templates/prisma/src/mail/templates/email-templates.ts +28 -0
  201. package/templates/prisma/src/main.ts +92 -0
  202. package/templates/prisma/src/metrics/metrics.controller.ts +22 -0
  203. package/templates/prisma/src/metrics/metrics.interceptor.ts +30 -0
  204. package/templates/prisma/src/metrics/metrics.module.ts +12 -0
  205. package/templates/prisma/src/metrics/metrics.service.ts +34 -0
  206. package/templates/prisma/src/types/express-session.d.ts +13 -0
  207. package/templates/prisma/src/users/dto/create-user.dto.ts +12 -0
  208. package/templates/prisma/src/users/dto/find-users-query.dto.ts +12 -0
  209. package/templates/prisma/src/users/dto/update-user.dto.ts +6 -0
  210. package/templates/prisma/src/users/entities/user.entity.ts +20 -0
  211. package/templates/prisma/src/users/users.controller.ts +165 -0
  212. package/templates/prisma/src/users/users.module.ts +10 -0
  213. package/templates/prisma/src/users/users.service.spec.ts +104 -0
  214. package/templates/prisma/src/users/users.service.ts +114 -0
  215. package/templates/prisma/test/auth.e2e-spec.ts +75 -0
  216. package/templates/prisma/test/session-auth.e2e-spec.ts +163 -0
  217. package/templates/prisma/test/users.e2e-spec.ts +106 -0
  218. package/templates/prisma/test/utils/clean-database.ts +14 -0
  219. package/templates/prisma/test/utils/e2e-setup.ts +58 -0
  220. package/templates/prisma/tsconfig.build.json +4 -0
  221. package/templates/prisma/tsconfig.json +25 -0
  222. package/templates/prisma/vitest.config.ts +20 -0
  223. package/templates/prisma/vitest.e2e.config.ts +19 -0
  224. package/templates/typeorm/.env.example +45 -0
  225. package/templates/typeorm/.env.test +38 -0
  226. package/templates/typeorm/.github/workflows/ci.yml +116 -0
  227. package/templates/typeorm/ARCHITECTURE.md +158 -0
  228. package/templates/typeorm/ARCHITECTURE.pt-BR.md +156 -0
  229. package/templates/typeorm/CODE_OF_CONDUCT.md +29 -0
  230. package/templates/typeorm/CODE_OF_CONDUCT.pt-BR.md +27 -0
  231. package/templates/typeorm/CONTRIBUTING.md +57 -0
  232. package/templates/typeorm/CONTRIBUTING.pt-BR.md +54 -0
  233. package/templates/typeorm/Dockerfile +43 -0
  234. package/templates/typeorm/LICENSE +21 -0
  235. package/templates/typeorm/README.md +266 -0
  236. package/templates/typeorm/README.pt-BR.md +266 -0
  237. package/templates/typeorm/ROADMAP.md +79 -0
  238. package/templates/typeorm/ROADMAP.pt-BR.md +67 -0
  239. package/templates/typeorm/TESTING.md +114 -0
  240. package/templates/typeorm/TESTING.pt-BR.md +114 -0
  241. package/templates/typeorm/docker-compose.yml +78 -0
  242. package/templates/typeorm/docs/adding-a-module.md +369 -0
  243. package/templates/typeorm/docs/features-markers.md +50 -0
  244. package/templates/typeorm/nest-cli.json +8 -0
  245. package/templates/typeorm/package.json +98 -0
  246. package/templates/typeorm/src/app.module.ts +72 -0
  247. package/templates/typeorm/src/auth/auth.controller.ts +283 -0
  248. package/templates/typeorm/src/auth/auth.module.ts +86 -0
  249. package/templates/typeorm/src/auth/auth.service.spec.ts +111 -0
  250. package/templates/typeorm/src/auth/auth.service.ts +346 -0
  251. package/templates/typeorm/src/auth/dto/forgot-password.dto.ts +9 -0
  252. package/templates/typeorm/src/auth/dto/login.dto.ts +10 -0
  253. package/templates/typeorm/src/auth/dto/refresh-token.dto.ts +9 -0
  254. package/templates/typeorm/src/auth/dto/register.dto.ts +11 -0
  255. package/templates/typeorm/src/auth/dto/reset-password.dto.ts +10 -0
  256. package/templates/typeorm/src/auth/entities/email-verification-token.entity.ts +69 -0
  257. package/templates/typeorm/src/auth/entities/oauth-account.entity.ts +50 -0
  258. package/templates/typeorm/src/auth/entities/password-reset-token.entity.ts +69 -0
  259. package/templates/typeorm/src/auth/entities/refresh-token.entity.ts +69 -0
  260. package/templates/typeorm/src/auth/entities/session.entity.ts +50 -0
  261. package/templates/typeorm/src/auth/guards/github-auth.guard.ts +10 -0
  262. package/templates/typeorm/src/auth/guards/google-auth.guard.ts +10 -0
  263. package/templates/typeorm/src/auth/guards/jwt-auth.guard.ts +25 -0
  264. package/templates/typeorm/src/auth/guards/session-auth.guard.spec.ts +77 -0
  265. package/templates/typeorm/src/auth/guards/session-auth.guard.ts +37 -0
  266. package/templates/typeorm/src/auth/session.service.spec.ts +74 -0
  267. package/templates/typeorm/src/auth/session.service.ts +96 -0
  268. package/templates/typeorm/src/auth/strategies/github.strategy.ts +41 -0
  269. package/templates/typeorm/src/auth/strategies/google.strategy.ts +43 -0
  270. package/templates/typeorm/src/auth/strategies/jwt.strategy.ts +25 -0
  271. package/templates/typeorm/src/auth/token.service.ts +115 -0
  272. package/templates/typeorm/src/common/constants/permissions.ts +8 -0
  273. package/templates/typeorm/src/common/constants/role-permissions.ts +9 -0
  274. package/templates/typeorm/src/common/constants/role.enum.ts +5 -0
  275. package/templates/typeorm/src/common/decorators/current-user.decorator.ts +8 -0
  276. package/templates/typeorm/src/common/decorators/permissions.decorator.ts +7 -0
  277. package/templates/typeorm/src/common/decorators/public.decorator.ts +4 -0
  278. package/templates/typeorm/src/common/decorators/roles.decorator.ts +6 -0
  279. package/templates/typeorm/src/common/filters/http-exception.filter.ts +34 -0
  280. package/templates/typeorm/src/common/guards/permissions.guard.spec.ts +54 -0
  281. package/templates/typeorm/src/common/guards/permissions.guard.ts +28 -0
  282. package/templates/typeorm/src/common/guards/roles.guard.spec.ts +37 -0
  283. package/templates/typeorm/src/common/guards/roles.guard.ts +24 -0
  284. package/templates/typeorm/src/common/interceptors/logging.interceptor.ts +23 -0
  285. package/templates/typeorm/src/common/middleware/csrf.middleware.spec.ts +97 -0
  286. package/templates/typeorm/src/common/middleware/csrf.middleware.ts +46 -0
  287. package/templates/typeorm/src/common/utils/avatar-storage.util.ts +32 -0
  288. package/templates/typeorm/src/common/utils/hash.util.ts +5 -0
  289. package/templates/typeorm/src/config/env.validation.ts +50 -0
  290. package/templates/typeorm/src/database/data-source.ts +20 -0
  291. package/templates/typeorm/src/database/database.module.ts +39 -0
  292. package/templates/typeorm/src/database/seed.ts +81 -0
  293. package/templates/typeorm/src/database/typeorm-options.ts +49 -0
  294. package/templates/typeorm/src/health/health.controller.ts +49 -0
  295. package/templates/typeorm/src/health/health.module.ts +19 -0
  296. package/templates/typeorm/src/health/indicators/redis-health.indicator.spec.ts +54 -0
  297. package/templates/typeorm/src/health/indicators/redis-health.indicator.ts +33 -0
  298. package/templates/typeorm/src/health/indicators/typeorm-health.indicator.spec.ts +49 -0
  299. package/templates/typeorm/src/health/indicators/typeorm-health.indicator.ts +37 -0
  300. package/templates/typeorm/src/mail/mail.module.ts +12 -0
  301. package/templates/typeorm/src/mail/mail.processor.ts +48 -0
  302. package/templates/typeorm/src/mail/mail.service.ts +24 -0
  303. package/templates/typeorm/src/mail/templates/email-templates.ts +28 -0
  304. package/templates/typeorm/src/main.ts +107 -0
  305. package/templates/typeorm/src/metrics/metrics.controller.ts +22 -0
  306. package/templates/typeorm/src/metrics/metrics.interceptor.ts +30 -0
  307. package/templates/typeorm/src/metrics/metrics.module.ts +12 -0
  308. package/templates/typeorm/src/metrics/metrics.service.ts +34 -0
  309. package/templates/typeorm/src/types/express-session.d.ts +13 -0
  310. package/templates/typeorm/src/users/dto/create-user.dto.ts +12 -0
  311. package/templates/typeorm/src/users/dto/find-users-query.dto.ts +12 -0
  312. package/templates/typeorm/src/users/dto/update-user.dto.ts +6 -0
  313. package/templates/typeorm/src/users/entities/user.entity.ts +113 -0
  314. package/templates/typeorm/src/users/users.controller.ts +165 -0
  315. package/templates/typeorm/src/users/users.module.ts +13 -0
  316. package/templates/typeorm/src/users/users.service.spec.ts +183 -0
  317. package/templates/typeorm/src/users/users.service.ts +124 -0
  318. package/templates/typeorm/test/auth.e2e-spec.ts +111 -0
  319. package/templates/typeorm/test/session-auth.e2e-spec.ts +159 -0
  320. package/templates/typeorm/test/users.e2e-spec.ts +183 -0
  321. package/templates/typeorm/test/utils/clean-database.ts +65 -0
  322. package/templates/typeorm/test/utils/e2e-setup.ts +77 -0
  323. package/templates/typeorm/tsconfig.build.json +4 -0
  324. package/templates/typeorm/tsconfig.json +25 -0
  325. package/templates/typeorm/vitest.config.ts +20 -0
  326. package/templates/typeorm/vitest.e2e.config.ts +19 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jeiel Jedson Leão Alves
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,371 @@
1
+ # nestforge
2
+
3
+ **English** | [Português](README.pt-BR.md)
4
+
5
+ Interactive CLI that generates NestJS projects from NestForge's [Prisma](../../templates/prisma), [TypeORM](../../templates/typeorm), and [Drizzle](../../templates/drizzle) templates.
6
+
7
+ ```bash
8
+ npx nestforge-generator
9
+ ```
10
+
11
+ For the testing guide, CLI prompts, and complete checklist, see [`TESTING.md`](TESTING.md).
12
+
13
+ ## What already works
14
+
15
+ - Interactive prompts using `@clack/prompts`;
16
+ - TypeScript or JavaScript generation;
17
+ - Prisma, TypeORM, and Drizzle ORM;
18
+ - PostgreSQL, MySQL, and SQLite;
19
+ - JWT, Session/Cookies, OAuth-only, or no authentication;
20
+ - optional Docker;
21
+ - optional Swagger/OpenAPI;
22
+ - optional global validation with Zod;
23
+ - optional Redis, queues, and email;
24
+ - optional RBAC and Permissions;
25
+ - optional `.env` creation;
26
+ - automated tests for generated combinations.
27
+
28
+ Generated projects include features such as avatar upload, pagination, filters, health checks, metrics, unit tests, and E2E tests.
29
+
30
+ ## Languages
31
+
32
+ The CLI generates projects in:
33
+
34
+ - TypeScript;
35
+ - JavaScript.
36
+
37
+ The JavaScript option is produced automatically from the TypeScript templates during generation.
38
+
39
+ The transformation:
40
+
41
+ - transpiles `.ts` files;
42
+ - removes TypeScript files that should not remain;
43
+ - updates `package.json` scripts;
44
+ - updates Vitest configuration;
45
+ - updates migration configuration;
46
+ - adapts commands according to the selected ORM.
47
+
48
+ ## Available ORMs and databases
49
+
50
+ ### Prisma
51
+
52
+ Available with:
53
+
54
+ - PostgreSQL;
55
+ - MySQL;
56
+ - SQLite.
57
+
58
+ The CLI adjusts the `schema.prisma` provider, database URL, and provider-specific resources.
59
+
60
+ ### TypeORM
61
+
62
+ Available with:
63
+
64
+ - PostgreSQL using `pg`;
65
+ - MySQL using `mysql2`;
66
+ - SQLite using `better-sqlite3`.
67
+
68
+ The CLI adjusts:
69
+
70
+ - `DB_TYPE`;
71
+ - `DATABASE_URL`;
72
+ - column types;
73
+ - `DataSource` configuration;
74
+ - migration scripts;
75
+ - installed driver.
76
+
77
+ Only the required driver remains in the generated project.
78
+
79
+ ### Drizzle ORM
80
+
81
+ Available with:
82
+
83
+ - PostgreSQL using `pg`;
84
+ - MySQL using `mysql2`;
85
+ - SQLite using `better-sqlite3`.
86
+
87
+ The Drizzle template includes:
88
+
89
+ - a database-specific schema;
90
+ - Drizzle Kit configuration;
91
+ - SQL migrations;
92
+ - seed;
93
+ - typed database injection;
94
+ - health check based on the selected driver;
95
+ - `DrizzleSessionStore`;
96
+ - transactions adapted to SQLite.
97
+
98
+ After generation, only the schema and driver for the selected database remain in the project.
99
+
100
+ ## Authentication strategies
101
+
102
+ ### JWT
103
+
104
+ The JWT strategy keeps:
105
+
106
+ - registration;
107
+ - login;
108
+ - access tokens;
109
+ - refresh tokens;
110
+ - refresh token rotation;
111
+ - revocation;
112
+ - logout;
113
+ - Google and GitHub OAuth;
114
+ - password recovery;
115
+ - email verification.
116
+
117
+ Password recovery and email verification routes depend on the Redis, queues, and email feature.
118
+
119
+ ### Session/Cookies
120
+
121
+ The Session/Cookies strategy:
122
+
123
+ - keeps password registration and login;
124
+ - creates a session persisted in the database;
125
+ - sends an `httpOnly` cookie;
126
+ - regenerates the session after login;
127
+ - uses `SessionAuthGuard`;
128
+ - protects state-changing operations with CSRF;
129
+ - destroys the session on logout;
130
+ - starts a session after OAuth callbacks;
131
+ - removes JWT-only files, dependencies, and variables.
132
+
133
+ Each template uses an appropriate integration:
134
+
135
+ - Prisma uses `@quixo3/prisma-session-store`;
136
+ - TypeORM uses `connect-typeorm`;
137
+ - Drizzle uses the template's own `DrizzleSessionStore`.
138
+
139
+ ### OAuth-only
140
+
141
+ The OAuth-only strategy removes password-based flows:
142
+
143
+ - `register`;
144
+ - `login`;
145
+ - `forgot-password`;
146
+ - `reset-password`;
147
+ - `verify-email`.
148
+
149
+ The following remain available:
150
+
151
+ - Google OAuth;
152
+ - GitHub OAuth;
153
+ - access tokens;
154
+ - refresh tokens;
155
+ - logout;
156
+ - protection for authenticated routes.
157
+
158
+ ### No authentication
159
+
160
+ When “None” is selected, the CLI completely removes:
161
+
162
+ - `src/auth`;
163
+ - `src/users`;
164
+ - related DTOs;
165
+ - authentication guards;
166
+ - authentication tests;
167
+ - user tests.
168
+
169
+ The project keeps only the selected core, such as health checks, metrics, and infrastructure features.
170
+
171
+ ## Optional features
172
+
173
+ ### Docker
174
+
175
+ When Docker is disabled, the CLI removes:
176
+
177
+ - `Dockerfile`;
178
+ - `docker-compose.yml`.
179
+
180
+ ### Swagger/OpenAPI
181
+
182
+ When Swagger is disabled, the CLI removes:
183
+
184
+ - the Swagger bootstrap from `main.ts`;
185
+ - the `/docs` route;
186
+ - decorators such as `@ApiTags`;
187
+ - `@ApiOperation`;
188
+ - `@ApiResponse`;
189
+ - other documentation decorators.
190
+
191
+ The Swagger/OpenAPI prompt also controls API documentation. There is no separate second option.
192
+
193
+ ### Global validation
194
+
195
+ When global validation is disabled:
196
+
197
+ - `ZodValidationPipe` is not registered in `main.ts`;
198
+ - the pipe is not registered in the E2E setup.
199
+
200
+ DTOs remain as classes, but they are no longer automatically validated by the global pipe.
201
+
202
+ ### Redis, queues, and email
203
+
204
+ When enabled, the project includes:
205
+
206
+ - Redis;
207
+ - BullMQ;
208
+ - email queues;
209
+ - Nodemailer;
210
+ - Mailpit;
211
+ - password recovery;
212
+ - email verification;
213
+ - Redis health check.
214
+
215
+ When disabled, related modules, routes, and dependencies are removed.
216
+
217
+ ### RBAC and Permissions
218
+
219
+ When enabled, the project includes:
220
+
221
+ - `ADMIN`, `MANAGER`, and `USER` roles;
222
+ - granular permissions;
223
+ - `RolesGuard`;
224
+ - `PermissionsGuard`;
225
+ - authorization decorators.
226
+
227
+ When disabled, RBAC guards, decorators, and constants are removed. Routes still require authentication when an authentication strategy is active, but they no longer require specific permissions.
228
+
229
+ ### `.env` file
230
+
231
+ When requested, the CLI automatically creates `.env` from the already processed `.env.example`.
232
+
233
+ ## Option status
234
+
235
+ | Choice | Status |
236
+ | --- | --- |
237
+ | Language: TypeScript | ✅ Implemented |
238
+ | Language: JavaScript | ✅ Implemented |
239
+ | ORM: Prisma | ✅ Implemented |
240
+ | ORM: TypeORM | ✅ Implemented |
241
+ | ORM: Drizzle | ✅ Implemented |
242
+ | ORM: None | ❌ Not implemented |
243
+ | Database: PostgreSQL | ✅ Implemented |
244
+ | Database: MySQL | ✅ Implemented |
245
+ | Database: SQLite | ✅ Implemented |
246
+ | Database: MongoDB | ❌ Not implemented |
247
+ | Auth: JWT | ✅ Implemented |
248
+ | Auth: Session/Cookies | ✅ Implemented |
249
+ | Auth: OAuth-only | ✅ Implemented |
250
+ | Auth: None | ✅ Implemented |
251
+
252
+ The CLI rejects options that are not implemented before creating the project directory.
253
+
254
+ ## Automated tests
255
+
256
+ Generator tests are located at:
257
+
258
+ ```text
259
+ packages/cli/test/generator.test.ts
260
+ ```
261
+
262
+ Run them from `packages/cli`:
263
+
264
+ ```bash
265
+ npm test
266
+ ```
267
+
268
+ Coverage includes:
269
+
270
+ - Prisma with PostgreSQL;
271
+ - Prisma with MySQL;
272
+ - Prisma with SQLite;
273
+ - TypeORM with SQLite;
274
+ - Drizzle with PostgreSQL;
275
+ - Drizzle with MySQL;
276
+ - Drizzle with SQLite;
277
+ - JWT;
278
+ - Session/Cookies;
279
+ - OAuth-only;
280
+ - no authentication;
281
+ - TypeScript;
282
+ - JavaScript;
283
+ - Redis removal;
284
+ - removal of optional features;
285
+ - correct database drivers;
286
+ - migration scripts;
287
+ - generated schemas;
288
+ - rejection of unimplemented options.
289
+
290
+ ## Completed smoke tests
291
+
292
+ The following combinations were validated with installation, build, unit tests, migrations, seed, and E2E tests:
293
+
294
+ - TypeScript + TypeORM + SQLite + JWT;
295
+ - TypeScript + TypeORM + SQLite + Session/Cookies;
296
+ - TypeScript + Drizzle + SQLite + JWT;
297
+ - TypeScript + Drizzle + SQLite + Session/Cookies.
298
+
299
+ PostgreSQL and MySQL have automated generation, configuration, and unused-driver removal tests. Complete smoke tests for these databases still require local services or Docker.
300
+
301
+ ## Known limitations
302
+
303
+ ### Redis in earlier templates
304
+
305
+ In the Prisma and TypeORM templates, `docker-compose.yml` and environment files may still keep Redis and Mailpit services or variables when the feature is disabled.
306
+
307
+ This extra content does not prevent the project from compiling or running, but it can still be cleaned up to make generation completely minimal.
308
+
309
+ ### No authentication with Prisma
310
+
311
+ In the Prisma template, `schema.prisma` still keeps models such as `User`, `RefreshToken`, and `OAuthAccount` when no authentication is selected.
312
+
313
+ `prisma/seed.ts` may also remain related to the demonstration users.
314
+
315
+ The application code is removed correctly, but the schema may still create tables that are not used.
316
+
317
+ ### Administrative creation with OAuth-only
318
+
319
+ With OAuth-only, the administrative `POST /users` endpoint still allows a user to be created manually.
320
+
321
+ The CLI does not yet distinguish the strategy used for login from how an administrator registers users through a management interface.
322
+
323
+ ## Local development
324
+
325
+ From the monorepo root:
326
+
327
+ ```bash
328
+ npm install
329
+ cd packages/cli
330
+ npm run dev
331
+ ```
332
+
333
+ `npm run dev` runs the CLI directly from TypeScript using `tsx`.
334
+
335
+ To run the tests:
336
+
337
+ ```bash
338
+ npm test
339
+ ```
340
+
341
+ To test the CLI as an installed package:
342
+
343
+ ```bash
344
+ npm run build
345
+ npm link
346
+ nestforge
347
+ ```
348
+
349
+ ## Publishing
350
+
351
+ From `packages/cli`:
352
+
353
+ ```bash
354
+ npm run build
355
+ npm pack --dry-run
356
+ npm publish
357
+ ```
358
+
359
+ The build:
360
+
361
+ 1. compiles the CLI;
362
+ 2. copies the Prisma, TypeORM, and Drizzle templates;
363
+ 3. prepares the package published to npm.
364
+
365
+ ## Next steps
366
+
367
+ - an option without an ORM;
368
+ - MongoDB;
369
+ - more complete project and package name validation;
370
+ - expand the smoke-test matrix with real PostgreSQL and MySQL services;
371
+ - reduce the known limitations in the earlier templates.