@leo-h/create-nodejs-app 1.0.5 → 1.0.7
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.
- package/dist/package.json.js +1 -1
- package/dist/src/validations/framework.validation.js +1 -1
- package/package.json +2 -2
- package/templates/clean/package.json +1 -1
- package/templates/clean/src/env.ts +5 -5
- package/templates/clean/vitest.config.mts +2 -2
- package/templates/fastify/package.json +1 -1
- package/templates/fastify/src/app.ts +2 -2
- package/templates/fastify/src/env.ts +5 -5
- package/templates/fastify/vitest.config.mts +2 -2
- package/templates/nest/.env.example +11 -0
- package/templates/nest/.eslintignore +2 -0
- package/templates/nest/.eslintrc.json +22 -0
- package/templates/nest/.husky/pre-commit +1 -0
- package/templates/nest/.lintstagedrc.json +4 -0
- package/templates/nest/.prettierignore +7 -0
- package/templates/nest/.prettierrc.json +6 -0
- package/templates/nest/.swcrc +20 -0
- package/templates/nest/.vscode/settings.json +8 -0
- package/templates/nest/nest-cli.json +10 -0
- package/templates/nest/package.json +59 -0
- package/templates/nest/pnpm-lock.yaml +6372 -0
- package/templates/nest/src/core/errors/domain-error.ts +8 -0
- package/templates/nest/src/core/errors/errors.ts +9 -0
- package/templates/nest/src/infra/app.module.ts +7 -0
- package/templates/nest/src/infra/env.ts +22 -0
- package/templates/nest/src/infra/http/controllers/hello/hello-multipart.controller.e2e-spec.ts +58 -0
- package/templates/nest/src/infra/http/controllers/hello/hello-multipart.controller.ts +75 -0
- package/templates/nest/src/infra/http/controllers/hello/hello.controller.e2e-spec.ts +38 -0
- package/templates/nest/src/infra/http/controllers/hello/hello.controller.ts +51 -0
- package/templates/nest/src/infra/http/errors/upload-validation.error.ts +17 -0
- package/templates/nest/src/infra/http/events/fastify-multer.event.module.ts +15 -0
- package/templates/nest/src/infra/http/filters/domain-exception.filter.ts +53 -0
- package/templates/nest/src/infra/http/filters/http-exception.filter.ts +26 -0
- package/templates/nest/src/infra/http/http.module.ts +23 -0
- package/templates/nest/src/infra/http/middlewares/upload-interceptor.ts +365 -0
- package/templates/nest/src/infra/http/middlewares/zod-schema-pipe.ts +78 -0
- package/templates/nest/src/infra/http/middlewares/zod-validation-pipe.ts +33 -0
- package/templates/nest/src/infra/presenters/error.presenter.ts +14 -0
- package/templates/nest/src/infra/server.ts +45 -0
- package/templates/nest/test/e2e/sample-upload.jpg +0 -0
- package/templates/nest/tsconfig.json +17 -0
- package/templates/nest/vitest.config.e2e.mts +8 -0
- package/templates/nest/vitest.config.mts +6 -0
package/dist/package.json.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Object.defineProperty(exports,"__esModule",{value:!0});const name="@leo-h/create-nodejs-app",version="1.0.
|
1
|
+
Object.defineProperty(exports,"__esModule",{value:!0});const name="@leo-h/create-nodejs-app",version="1.0.7",packageManager="pnpm@9.1.1",author="Leonardo Henrique <leonardo0507.business@gmail.com>",description="Create a modern Node.js app with TypeScript using one command.",license="MIT",keywords=["node","node.js","typescript"],bin={"create-nodejs-app":"./dist/index.js"},files=["./dist","./templates"],repository={type:"git",url:"https://github.com/Leo-Henrique/create-nodejs-app"},scripts={prepare:"husky",start:"node ./dist/index.js","start:dev":"tsx ./src/index.ts","start:dev:watch":"tsx watch ./src/index.ts",typecheck:"tsc --noEmit",lint:"eslint . --ext .ts --max-warnings 0 --cache","lint:fix":"pnpm lint --fix",format:"prettier . --write --cache","test:unit":"vitest run","test:unit:watch":"vitest","test:e2e":"vitest run --config ./vitest.config.e2e.mts","test:e2e:watch":"vitest --config ./vitest.config.e2e.mts","test:coverage":"vitest run --coverage.enabled=true",template:"tsx ./scripts/template-cli.ts",prebuild:"rimraf ./dist",build:"unbuild",prepublishOnly:"pnpm build"},dependencies={commander:"12.1.0",picocolors:"1.0.1",prompts:"2.4.2","validate-npm-package-name":"5.0.1",zod:"3.23.8"},devDependencies={"@faker-js/faker":"8.4.1","@types/node":"20.12.12","@types/prompts":"2.4.9","@types/validate-npm-package-name":"4.0.2","@typescript-eslint/eslint-plugin":"7.10.0","@typescript-eslint/parser":"7.10.0","conventional-changelog-conventionalcommits":"8.0.0",eslint:"8.57.0","eslint-config-prettier":"9.1.0","eslint-plugin-vitest":"0.4.0",husky:"9.0.11","lint-staged":"15.2.2","npm-run-all":"4.1.5",prettier:"3.2.5",rimraf:"5.0.7",tsx:"4.10.5",typescript:"5.4.5",unbuild:"2.0.0","vite-tsconfig-paths":"4.3.2",vitest:"1.6.0"},f={name,version,packageManager,author,description,license,keywords,bin,files,repository,scripts,dependencies,devDependencies};exports.author=author;exports.bin=bin;exports.default=f;exports.dependencies=dependencies;exports.description=description;exports.devDependencies=devDependencies;exports.files=files;exports.keywords=keywords;exports.license=license;exports.name=name;exports.packageManager=packageManager;exports.repository=repository;exports.scripts=scripts;exports.version=version;
|
@@ -1 +1 @@
|
|
1
|
-
const validation=require("../core/validation.js"),getValidOptionsFromPrompt=require("../utils/get-valid-options-from-prompt.js"),frameworks=[{title:"Fastify",value:"fastify"},{title:"Nest",value:"nest"
|
1
|
+
const validation=require("../core/validation.js"),getValidOptionsFromPrompt=require("../utils/get-valid-options-from-prompt.js"),frameworks=[{title:"Fastify",value:"fastify"},{title:"Nest + SWC",value:"nest"},{title:"tRPC",value:"trpc",disabled:!0}],validFrameworks=getValidOptionsFromPrompt.getValidOptionsFromSelect(frameworks);class FrameworkValidation extends validation.Validation{static create(t){return new this().createValidation(t)}async validate(){let{framework:t}=this.params;return t=t.toLowerCase(),validFrameworks.includes(t)?{isValid:!0}:{isValid:!1,issue:`Invalid framework, consider the options: ${validFrameworks.map(e=>`"${e}"`).join(", ")}.`}}}exports.FrameworkValidation=FrameworkValidation;exports.frameworks=frameworks;exports.validFrameworks=validFrameworks;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@leo-h/create-nodejs-app",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.7",
|
4
4
|
"packageManager": "pnpm@9.1.1",
|
5
5
|
"author": "Leonardo Henrique <leonardo0507.business@gmail.com>",
|
6
6
|
"description": "Create a modern Node.js app with TypeScript using one command.",
|
@@ -34,7 +34,7 @@
|
|
34
34
|
"test:unit:watch": "vitest",
|
35
35
|
"test:e2e": "vitest run --config ./vitest.config.e2e.mts",
|
36
36
|
"test:e2e:watch": "vitest --config ./vitest.config.e2e.mts",
|
37
|
-
"test:coverage": "vitest run --coverage.enabled=true
|
37
|
+
"test:coverage": "vitest run --coverage.enabled=true",
|
38
38
|
"template": "tsx ./scripts/template-cli.ts",
|
39
39
|
"prebuild": "rimraf ./dist",
|
40
40
|
"build": "unbuild",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"format": "prettier . --write --cache",
|
13
13
|
"test:unit": "vitest run",
|
14
14
|
"test:unit:watch": "vitest",
|
15
|
-
"test:coverage": "vitest run --coverage.enabled=true
|
15
|
+
"test:coverage": "vitest run --coverage.enabled=true",
|
16
16
|
"prebuild": "rimraf ./dist",
|
17
17
|
"build": "unbuild"
|
18
18
|
},
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import "
|
1
|
+
import packageJson from "@/../package.json";
|
2
|
+
import { config } from "dotenv";
|
2
3
|
import { z } from "zod";
|
3
4
|
|
5
|
+
config({ override: true });
|
6
|
+
|
4
7
|
const schema = z.object({
|
5
8
|
NODE_ENV: z.enum(["test", "development", "production"]),
|
6
|
-
APP_NAME: z
|
7
|
-
.string()
|
8
|
-
.nullable()
|
9
|
-
.default(process.env.npm_package_name ?? null),
|
9
|
+
APP_NAME: z.string().default(packageJson.name),
|
10
10
|
});
|
11
11
|
|
12
12
|
const parsedEnv = schema.safeParse(process.env);
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"test:unit:watch": "vitest",
|
15
15
|
"test:e2e": "vitest run --config ./vitest.config.e2e.mts",
|
16
16
|
"test:e2e:watch": "vitest --config ./vitest.config.e2e.mts",
|
17
|
-
"test:coverage": "vitest run --coverage.enabled=true
|
17
|
+
"test:coverage": "vitest run --coverage.enabled=true",
|
18
18
|
"prebuild": "rimraf ./dist",
|
19
19
|
"build": "unbuild"
|
20
20
|
},
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import packageJson from "@/../package.json";
|
1
2
|
import fastifyCookie from "@fastify/cookie";
|
2
3
|
import fastifyCors from "@fastify/cors";
|
3
4
|
import fastifySwagger from "@fastify/swagger";
|
@@ -23,8 +24,7 @@ app.register(fastifySwagger, {
|
|
23
24
|
openapi: {
|
24
25
|
info: {
|
25
26
|
title: env.API_NAME ?? "",
|
26
|
-
|
27
|
-
version: process.env.npm_package_version ?? "",
|
27
|
+
version: packageJson.version,
|
28
28
|
},
|
29
29
|
servers: [],
|
30
30
|
},
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import "
|
1
|
+
import packageJson from "@/../package.json";
|
2
|
+
import { config } from "dotenv";
|
2
3
|
import { z } from "zod";
|
3
4
|
|
5
|
+
config({ override: true });
|
6
|
+
|
4
7
|
const schema = z.object({
|
5
8
|
NODE_ENV: z.enum(["test", "development", "production"]),
|
6
|
-
API_NAME: z
|
7
|
-
.string()
|
8
|
-
.nullable()
|
9
|
-
.default(process.env.npm_package_name ?? null),
|
9
|
+
API_NAME: z.string().default(packageJson.name),
|
10
10
|
API_PORT: z.coerce.number().default(3333),
|
11
11
|
API_ACCESS_PERMISSION_CLIENT_SIDE: z.string().default("*"),
|
12
12
|
});
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# example: "development" ("development" | "test" | "production")
|
2
|
+
NODE_ENV=
|
3
|
+
|
4
|
+
# example: "app-name"
|
5
|
+
API_NAME=
|
6
|
+
|
7
|
+
# example: "3333"
|
8
|
+
API_PORT=
|
9
|
+
|
10
|
+
# example: "https://my-client-app.com" (url - only constraint | regex - specific constraint | "*" - not constraint)
|
11
|
+
API_ACCESS_PERMISSION_CLIENT_SIDE=
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"root": true,
|
3
|
+
"env": {
|
4
|
+
"es2021": true,
|
5
|
+
"node": true
|
6
|
+
},
|
7
|
+
"extends": [
|
8
|
+
"eslint:recommended",
|
9
|
+
"plugin:@typescript-eslint/recommended",
|
10
|
+
"prettier",
|
11
|
+
"plugin:vitest/recommended"
|
12
|
+
],
|
13
|
+
"parser": "@typescript-eslint/parser",
|
14
|
+
"parserOptions": {
|
15
|
+
"ecmaVersion": "latest",
|
16
|
+
"sourceType": "module"
|
17
|
+
},
|
18
|
+
"plugins": ["@typescript-eslint"],
|
19
|
+
"rules": {
|
20
|
+
"@typescript-eslint/no-unused-vars": "warn"
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
pnpm lint-staged
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "https://json.schemastore.org/swcrc",
|
3
|
+
"module": {
|
4
|
+
"type": "commonjs",
|
5
|
+
"strictMode": true
|
6
|
+
},
|
7
|
+
"jsc": {
|
8
|
+
"target": "esnext",
|
9
|
+
"parser": {
|
10
|
+
"syntax": "typescript",
|
11
|
+
"decorators": true,
|
12
|
+
"dynamicImport": true
|
13
|
+
},
|
14
|
+
"baseUrl": ".",
|
15
|
+
"paths": {
|
16
|
+
"@/*": ["./src/*"]
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"minify": false
|
20
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "app-name",
|
3
|
+
"version": "1.0.0",
|
4
|
+
"private": true,
|
5
|
+
"scripts": {
|
6
|
+
"prepare": "husky",
|
7
|
+
"start": "node ./dist/infra/server.js",
|
8
|
+
"start:dev": "nest start --watch",
|
9
|
+
"typecheck": "tsc --noEmit",
|
10
|
+
"lint": "eslint . --ext .ts --max-warnings 0 --cache",
|
11
|
+
"lint:fix": "pnpm lint --fix",
|
12
|
+
"format": "prettier . --write --cache",
|
13
|
+
"test:unit": "vitest run",
|
14
|
+
"test:unit:watch": "vitest",
|
15
|
+
"test:e2e": "vitest run --config ./vitest.config.e2e.mts",
|
16
|
+
"test:e2e:watch": "vitest --config ./vitest.config.e2e.mts",
|
17
|
+
"test:coverage": "vitest run --coverage.enabled=true",
|
18
|
+
"build": "nest build"
|
19
|
+
},
|
20
|
+
"dependencies": {
|
21
|
+
"@anatine/zod-nestjs": "2.0.9",
|
22
|
+
"@anatine/zod-openapi": "2.2.6",
|
23
|
+
"@fastify/static": "7.0.4",
|
24
|
+
"@nestjs/common": "10.3.10",
|
25
|
+
"@nestjs/core": "10.3.10",
|
26
|
+
"@nestjs/platform-fastify": "10.3.10",
|
27
|
+
"@nestjs/swagger": "7.4.0",
|
28
|
+
"dotenv": "16.4.5",
|
29
|
+
"fastify": "4.28.0",
|
30
|
+
"fastify-multer": "2.0.3",
|
31
|
+
"mime-types": "2.1.35",
|
32
|
+
"pretty-bytes": "5.6.0",
|
33
|
+
"zod": "3.23.8"
|
34
|
+
},
|
35
|
+
"devDependencies": {
|
36
|
+
"@faker-js/faker": "8.4.1",
|
37
|
+
"@nestjs/cli": "10.4.2",
|
38
|
+
"@nestjs/schematics": "10.1.2",
|
39
|
+
"@nestjs/testing": "10.3.10",
|
40
|
+
"@swc/cli": "0.4.0",
|
41
|
+
"@swc/core": "1.7.0",
|
42
|
+
"@types/mime-types": "2.1.4",
|
43
|
+
"@types/node": "20.12.12",
|
44
|
+
"@types/supertest": "6.0.2",
|
45
|
+
"@typescript-eslint/eslint-plugin": "7.10.0",
|
46
|
+
"@typescript-eslint/parser": "7.10.0",
|
47
|
+
"eslint": "8.57.0",
|
48
|
+
"eslint-config-prettier": "9.1.0",
|
49
|
+
"eslint-plugin-vitest": "0.4.0",
|
50
|
+
"husky": "9.0.11",
|
51
|
+
"lint-staged": "15.2.5",
|
52
|
+
"prettier": "3.2.5",
|
53
|
+
"supertest": "7.0.0",
|
54
|
+
"type-fest": "4.23.0",
|
55
|
+
"typescript": "5.4.5",
|
56
|
+
"unplugin-swc": "1.5.1",
|
57
|
+
"vitest": "1.6.0"
|
58
|
+
}
|
59
|
+
}
|