@absterr/nestkit 0.0.0-stage → 0.1.1

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 (119) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +92 -2
  3. package/dist/args.js +37 -0
  4. package/dist/choices/compat.js +15 -0
  5. package/dist/choices/preset.js +40 -0
  6. package/dist/choices/stack.js +111 -0
  7. package/dist/choices/testing.js +110 -0
  8. package/dist/choices/types.js +1 -0
  9. package/dist/cli.js +10 -0
  10. package/dist/new.js +114 -0
  11. package/dist/options.js +21 -0
  12. package/dist/overlays.js +61 -0
  13. package/dist/package-managers.js +23 -0
  14. package/dist/rules.js +19 -0
  15. package/dist/scaffold/esm.js +30 -0
  16. package/dist/scaffold/files.js +44 -0
  17. package/dist/scaffold/generate.js +24 -0
  18. package/dist/scaffold/install.js +33 -0
  19. package/dist/scaffold/json.js +4 -0
  20. package/dist/scaffold/package-json.js +62 -0
  21. package/dist/settings.js +52 -0
  22. package/dist/ui.js +24 -0
  23. package/dist/versions.js +33 -0
  24. package/package.json +53 -4
  25. package/templates/agent-files/11/AGENTS.md +24 -0
  26. package/templates/agent-files/12/AGENTS.md +39 -0
  27. package/templates/agent-files/common/CLAUDE.md +1 -0
  28. package/templates/base/README.md +70 -0
  29. package/templates/base/gitattributes +1 -0
  30. package/templates/base/gitignore +8 -0
  31. package/templates/base/nest-cli.json +11 -0
  32. package/templates/base/package.json +32 -0
  33. package/templates/base/src/app.controller.ts +12 -0
  34. package/templates/base/src/app.module.ts +10 -0
  35. package/templates/base/src/app.service.ts +8 -0
  36. package/templates/base/src/main.ts +13 -0
  37. package/templates/code-quality/biome/biome.json +47 -0
  38. package/templates/code-quality/biome/package.json +14 -0
  39. package/templates/code-quality/eslint/eslint.config.mjs +35 -0
  40. package/templates/code-quality/eslint/package.json +14 -0
  41. package/templates/code-quality/oxlint/.oxlintrc.json +8 -0
  42. package/templates/code-quality/oxlint/package.json +10 -0
  43. package/templates/code-quality/prettier/.prettierignore +10 -0
  44. package/templates/code-quality/prettier/.prettierrc +7 -0
  45. package/templates/code-quality/prettier/package.json +9 -0
  46. package/templates/e2e-tests/cypress/gitignore +2 -0
  47. package/templates/e2e-tests/cypress/package.json +12 -0
  48. package/templates/e2e-tests/cypress/test/app.cy.ts +10 -0
  49. package/templates/e2e-tests/cypress/test/cypress.config.mjs +9 -0
  50. package/templates/e2e-tests/cypress/test/tsconfig.json +8 -0
  51. package/templates/e2e-tests/e2e-scripts/package.json +5 -0
  52. package/templates/e2e-tests/e2e-scripts/scripts/test-e2e.mjs +48 -0
  53. package/templates/e2e-tests/playwright/gitignore +2 -0
  54. package/templates/e2e-tests/playwright/package.json +8 -0
  55. package/templates/e2e-tests/playwright/test/app.e2e-spec.ts +8 -0
  56. package/templates/e2e-tests/playwright/test/playwright.config.mjs +9 -0
  57. package/templates/e2e-tests/runner-configs/jest/test/jest-e2e.json +9 -0
  58. package/templates/e2e-tests/runner-configs/mocha/cjs-mocha/test/.mocharc.e2e.json +5 -0
  59. package/templates/e2e-tests/runner-configs/mocha/esm-mocha/test/.mocharc.e2e.json +5 -0
  60. package/templates/e2e-tests/runner-configs/vitest/test/vitest.config.e2e.mjs +15 -0
  61. package/templates/e2e-tests/selenium/jest-selenium/package.json +5 -0
  62. package/templates/e2e-tests/selenium/jest-selenium/test/app.e2e-spec.ts +25 -0
  63. package/templates/e2e-tests/selenium/mocha-selenium/package.json +5 -0
  64. package/templates/e2e-tests/selenium/mocha-selenium/test/app.e2e-spec.ts +28 -0
  65. package/templates/e2e-tests/selenium/package.json +6 -0
  66. package/templates/e2e-tests/selenium/vitest-selenium/package.json +5 -0
  67. package/templates/e2e-tests/selenium/vitest-selenium/test/app.e2e-spec.ts +26 -0
  68. package/templates/e2e-tests/supertest/jest-supertest/package.json +5 -0
  69. package/templates/e2e-tests/supertest/jest-supertest/test/app.e2e-spec.ts +29 -0
  70. package/templates/e2e-tests/supertest/mocha-supertest/package.json +5 -0
  71. package/templates/e2e-tests/supertest/mocha-supertest/test/app.e2e-spec.ts +30 -0
  72. package/templates/e2e-tests/supertest/package.json +6 -0
  73. package/templates/e2e-tests/supertest/vitest-supertest/package.json +5 -0
  74. package/templates/e2e-tests/supertest/vitest-supertest/test/app.e2e-spec.ts +30 -0
  75. package/templates/environment/arktype/package.json +5 -0
  76. package/templates/environment/arktype/src/config/env/env.schema.ts +12 -0
  77. package/templates/environment/arktype/src/config/env/validate.ts +12 -0
  78. package/templates/environment/class-validator/package.json +6 -0
  79. package/templates/environment/class-validator/src/config/env/env.schema.ts +15 -0
  80. package/templates/environment/class-validator/src/config/env/validate.ts +15 -0
  81. package/templates/environment/common/package.json +5 -0
  82. package/templates/environment/common/src/app.module.ts +11 -0
  83. package/templates/environment/common/src/config/env/env.module.ts +17 -0
  84. package/templates/environment/common/src/config/env/env.provider.ts +17 -0
  85. package/templates/environment/common/src/main.ts +15 -0
  86. package/templates/environment/joi/package.json +5 -0
  87. package/templates/environment/joi/src/config/env/env.schema.ts +16 -0
  88. package/templates/environment/joi/src/config/env/validate.ts +16 -0
  89. package/templates/environment/valibot/package.json +5 -0
  90. package/templates/environment/valibot/src/config/env/env.schema.ts +20 -0
  91. package/templates/environment/valibot/src/config/env/validate.ts +16 -0
  92. package/templates/environment/vanilla/src/config/env/env.schema.ts +26 -0
  93. package/templates/environment/vanilla/src/config/env/validate.ts +18 -0
  94. package/templates/environment/zod/package.json +5 -0
  95. package/templates/environment/zod/src/config/env/env.schema.ts +11 -0
  96. package/templates/environment/zod/src/config/env/validate.ts +19 -0
  97. package/templates/test-runners/common/package.json +5 -0
  98. package/templates/test-runners/jest/eslint-jest/eslint.config.mjs +36 -0
  99. package/templates/test-runners/jest/package.json +7 -0
  100. package/templates/test-runners/mocha/package.json +8 -0
  101. package/templates/test-runners/vitest/eslint-vitest/eslint.config.mjs +43 -0
  102. package/templates/test-runners/vitest/package.json +7 -0
  103. package/templates/unit-tests/common/gitignore +1 -0
  104. package/templates/unit-tests/common/nest-cli.json +8 -0
  105. package/templates/unit-tests/jest/jest.config.json +10 -0
  106. package/templates/unit-tests/jest/package.json +7 -0
  107. package/templates/unit-tests/jest/src/app.controller.spec.ts +22 -0
  108. package/templates/unit-tests/mocha/cjs-mocha/.mocharc.json +5 -0
  109. package/templates/unit-tests/mocha/cjs-mocha/package.json +5 -0
  110. package/templates/unit-tests/mocha/esm-mocha/.mocharc.json +5 -0
  111. package/templates/unit-tests/mocha/package.json +9 -0
  112. package/templates/unit-tests/mocha/src/app.controller.spec.ts +23 -0
  113. package/templates/unit-tests/vitest/package.json +10 -0
  114. package/templates/unit-tests/vitest/src/app.controller.spec.ts +23 -0
  115. package/templates/unit-tests/vitest/vitest.config.mjs +14 -0
  116. package/templates/versions/11/tsconfig.build.json +4 -0
  117. package/templates/versions/11/tsconfig.json +26 -0
  118. package/templates/versions/12/tsconfig.build.json +8 -0
  119. package/templates/versions/12/tsconfig.json +27 -0
@@ -0,0 +1,47 @@
1
+ {
2
+ "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "includes": ["src/**/*.ts", "test/**/*.ts"]
10
+ },
11
+ "formatter": {
12
+ "enabled": true,
13
+ "indentStyle": "space",
14
+ "indentWidth": 2,
15
+ "lineWidth": 80
16
+ },
17
+ "linter": {
18
+ "enabled": true,
19
+ "rules": {
20
+ "preset": "recommended",
21
+ "style": {
22
+ "useImportType": "off"
23
+ },
24
+ "suspicious": {
25
+ "noExplicitAny": "warn"
26
+ }
27
+ }
28
+ },
29
+ "javascript": {
30
+ "formatter": {
31
+ "quoteStyle": "double",
32
+ "semicolons": "always",
33
+ "trailingCommas": "all"
34
+ },
35
+ "parser": {
36
+ "unsafeParameterDecoratorsEnabled": true
37
+ }
38
+ },
39
+ "assist": {
40
+ "enabled": true,
41
+ "actions": {
42
+ "source": {
43
+ "organizeImports": "on"
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "scripts": {
3
+ "biome:migrate": "biome migrate --write",
4
+ "lint": "biome lint",
5
+ "lint:fix": "biome lint --write",
6
+ "format": "biome format --write",
7
+ "format:check": "biome format",
8
+ "check": "biome check",
9
+ "check:fix": "biome check --write"
10
+ },
11
+ "devDependencies": {
12
+ "@biomejs/biome": "^2.6.6"
13
+ }
14
+ }
@@ -0,0 +1,35 @@
1
+ // @ts-check
2
+ import eslint from "@eslint/js";
3
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
4
+ import { defineConfig } from "eslint/config";
5
+ import globals from "globals";
6
+ import tseslint from "typescript-eslint";
7
+
8
+ export default defineConfig(
9
+ {
10
+ ignores: ["eslint.config.mjs", "**/*.mjs", "dist/**"],
11
+ },
12
+ eslint.configs.recommended,
13
+ ...tseslint.configs.recommendedTypeChecked,
14
+ eslintPluginPrettierRecommended,
15
+ {
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.node,
19
+ },
20
+ sourceType: "commonjs",
21
+ parserOptions: {
22
+ projectService: true,
23
+ tsconfigRootDir: import.meta.dirname,
24
+ },
25
+ },
26
+ },
27
+ {
28
+ rules: {
29
+ "@typescript-eslint/no-explicit-any": "warn",
30
+ "@typescript-eslint/no-floating-promises": "warn",
31
+ "@typescript-eslint/no-unsafe-argument": "warn",
32
+ "prettier/prettier": ["error", { endOfLine: "auto" }],
33
+ },
34
+ }
35
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "scripts": {
3
+ "lint": "eslint \"{src,test}/**/*.{js,ts}\"",
4
+ "lint:fix": "eslint \"{src,test}/**/*.{js,ts}\" --fix"
5
+ },
6
+ "devDependencies": {
7
+ "@eslint/js": "^9.18.0",
8
+ "eslint": "^9.18.0",
9
+ "eslint-config-prettier": "^10.0.1",
10
+ "eslint-plugin-prettier": "^5.2.2",
11
+ "globals": "^16.0.0",
12
+ "typescript-eslint": "^8.20.0"
13
+ }
14
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
3
+ "plugins": ["typescript", "oxc"],
4
+ "rules": {
5
+ "typescript/no-explicit-any": "warn",
6
+ "typescript/no-floating-promises": "error"
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "scripts": {
3
+ "lint": "oxlint --type-aware",
4
+ "lint:fix": "oxlint --type-aware --fix"
5
+ },
6
+ "devDependencies": {
7
+ "oxlint": "^1.90.0",
8
+ "oxlint-tsgolint": "^7.0.2001"
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ # Dependencies
2
+ node_modules
3
+
4
+ # Build output
5
+ dist
6
+ build
7
+ coverage
8
+
9
+ # Generated files
10
+ *.generated.*
@@ -0,0 +1,7 @@
1
+ {
2
+ "semi": true,
3
+ "singleQuote": false,
4
+ "tabWidth": 2,
5
+ "trailingComma": "all",
6
+ "printWidth": 80
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "scripts": {
3
+ "format": "prettier \"{src,test}/**/*.{js,ts,json}\" --write",
4
+ "format:check": "prettier \"{src,test}/**/*.{js,ts,json}\" --check"
5
+ },
6
+ "devDependencies": {
7
+ "prettier": "^3.4.2"
8
+ }
9
+ }
@@ -0,0 +1,2 @@
1
+ /cypress/screenshots
2
+ /cypress/videos
@@ -0,0 +1,12 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "node scripts/test-e2e.mjs \"cypress run --config-file test/cypress.config.mjs\"",
4
+ "test:e2e:cypress:open": "node scripts/test-e2e.mjs \"cypress open --config-file test/cypress.config.mjs\""
5
+ },
6
+ "devDependencies": {
7
+ "cypress": "^16.3.0"
8
+ },
9
+ "trustedDependencies": [
10
+ "cypress"
11
+ ]
12
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="cypress" />
2
+
3
+ describe("GET /", () => {
4
+ it("returns Hello World!", () => {
5
+ cy.request("/").then((response) => {
6
+ expect(response.status).to.eq(200);
7
+ expect(response.body).to.eq("Hello World!");
8
+ });
9
+ });
10
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "cypress";
2
+
3
+ export default defineConfig({
4
+ e2e: {
5
+ baseUrl: process.env.BASE_URL,
6
+ specPattern: "test/**/*.cy.ts",
7
+ supportFile: false,
8
+ },
9
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": ["cypress", "node"],
5
+ "noEmit": true
6
+ },
7
+ "include": ["./**/*.ts"]
8
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "devDependencies": {
3
+ "start-server-and-test": "^3.0.13"
4
+ }
5
+ }
@@ -0,0 +1,48 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, resolve } from "node:path";
4
+
5
+ let binPath;
6
+ try {
7
+ const require = createRequire(import.meta.url);
8
+ const pkgPath = require.resolve("start-server-and-test/package.json");
9
+ const pkg = require(pkgPath);
10
+ binPath = resolve(dirname(pkgPath), pkg.bin["start-server-and-test"]);
11
+ } catch {
12
+ console.error('Error: "start-server-and-test" is not installed.');
13
+ process.exit(1);
14
+ }
15
+
16
+ const testCmd = process.argv.slice(2).join(" ");
17
+ if (!testCmd) {
18
+ console.error("Error: No test command provided.");
19
+ process.exit(1);
20
+ }
21
+
22
+ const port = process.env.PORT ?? "3000";
23
+ const baseUrl = process.env.BASE_URL ?? `http://127.0.0.1:${port}`;
24
+ const probeUrl = baseUrl.replace(/^http(s?):\/\//, "http$1-get://");
25
+ const isWin = process.platform === "win32";
26
+
27
+ /**
28
+ * Spawns a test server and executes E2E tests against dynamic ports.
29
+ * NOTE: Fails if the app or test command hardcodes a different port instead of using BASE_URL/PORT.
30
+ */
31
+
32
+ try {
33
+ execFileSync(
34
+ process.execPath,
35
+ [binPath, "start", probeUrl, isWin ? `"${testCmd}"` : testCmd],
36
+ {
37
+ stdio: "inherit",
38
+ shell: isWin,
39
+ env: {
40
+ ...process.env,
41
+ PORT: port,
42
+ BASE_URL: baseUrl,
43
+ },
44
+ }
45
+ );
46
+ } catch (error) {
47
+ process.exit(error.status ?? 1);
48
+ }
@@ -0,0 +1,2 @@
1
+ /test-results
2
+ /playwright-report
@@ -0,0 +1,8 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "node scripts/test-e2e.mjs \"playwright test -c test/playwright.config.mjs\""
4
+ },
5
+ "devDependencies": {
6
+ "@playwright/test": "^1.65.1"
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ import { expect, test } from "@playwright/test";
2
+
3
+ test("GET /", async ({ request }) => {
4
+ const response = await request.get("/");
5
+
6
+ expect(response.status()).toBe(200);
7
+ expect(await response.text()).toBe("Hello World!");
8
+ });
@@ -0,0 +1,9 @@
1
+ import { defineConfig } from "@playwright/test";
2
+
3
+ export default defineConfig({
4
+ testDir: ".",
5
+ testMatch: "**/*.e2e-spec.ts",
6
+ use: {
7
+ baseURL: process.env.BASE_URL,
8
+ },
9
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "moduleFileExtensions": ["js", "json", "ts"],
3
+ "rootDir": ".",
4
+ "testEnvironment": "node",
5
+ "testRegex": ".e2e-spec.ts$",
6
+ "transform": {
7
+ "^.+\\.(t|j)s$": "ts-jest"
8
+ }
9
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "require": ["reflect-metadata", "@swc-node/register"],
3
+ "extension": ["ts"],
4
+ "spec": ["test/**/*.e2e-spec.ts"]
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "node-option": ["import=@swc-node/register/esm-register"],
3
+ "extension": ["ts"],
4
+ "spec": ["test/**/*.e2e-spec.ts"]
5
+ }
@@ -0,0 +1,15 @@
1
+ import swc from "unplugin-swc";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ plugins: [
6
+ swc.vite({
7
+ module: { type: "es6" },
8
+ }),
9
+ ],
10
+ test: {
11
+ root: "./",
12
+ environment: "node",
13
+ include: ["test/**/*.e2e-spec.ts"],
14
+ },
15
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "node scripts/test-e2e.mjs \"jest --config ./test/jest-e2e.json\""
4
+ }
5
+ }
@@ -0,0 +1,25 @@
1
+ import { Browser, Builder, By, type WebDriver } from "selenium-webdriver";
2
+
3
+ describe("App (Selenium E2E)", () => {
4
+ let driver: WebDriver | undefined;
5
+
6
+ beforeAll(async () => {
7
+ driver = await new Builder().forBrowser(Browser.CHROME).build();
8
+ }, 60_000);
9
+
10
+ afterAll(async () => {
11
+ await driver?.quit();
12
+ });
13
+
14
+ it("GET /", async () => {
15
+ if (!driver) throw new Error("WebDriver was not initialized");
16
+
17
+ const baseURL =
18
+ process.env.BASE_URL ?? `http://127.0.0.1:${process.env.PORT ?? "3000"}`;
19
+ await driver.get(baseURL);
20
+
21
+ const body = await driver.findElement(By.css("body")).getText();
22
+
23
+ expect(body).toBe("Hello World!");
24
+ });
25
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "node scripts/test-e2e.mjs \"mocha --config ./test/.mocharc.e2e.json\""
4
+ }
5
+ }
@@ -0,0 +1,28 @@
1
+ import { Browser, Builder, By, type WebDriver } from "selenium-webdriver";
2
+ import { strict as assert } from "node:assert";
3
+
4
+ describe("App (Selenium E2E)", function () {
5
+ let driver: WebDriver | undefined;
6
+
7
+ this.timeout(60_000);
8
+
9
+ before(async () => {
10
+ driver = await new Builder().forBrowser(Browser.CHROME).build();
11
+ });
12
+
13
+ after(async () => {
14
+ await driver?.quit();
15
+ });
16
+
17
+ it("GET /", async () => {
18
+ if (!driver) throw new Error("WebDriver was not initialized");
19
+
20
+ const baseURL =
21
+ process.env.BASE_URL ?? `http://127.0.0.1:${process.env.PORT ?? "3000"}`;
22
+ await driver.get(baseURL);
23
+
24
+ const body = await driver.findElement(By.css("body")).getText();
25
+
26
+ assert.equal(body, "Hello World!");
27
+ });
28
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "devDependencies": {
3
+ "@types/selenium-webdriver": "^4.35.7",
4
+ "selenium-webdriver": "^4.51.0"
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "node scripts/test-e2e.mjs \"vitest run --config ./test/vitest.config.e2e.mjs\""
4
+ }
5
+ }
@@ -0,0 +1,26 @@
1
+ import { Browser, Builder, By, type WebDriver } from "selenium-webdriver";
2
+ import { afterAll, beforeAll, describe, expect, it } from "vitest";
3
+
4
+ describe("App (Selenium E2E)", () => {
5
+ let driver: WebDriver | undefined;
6
+
7
+ beforeAll(async () => {
8
+ driver = await new Builder().forBrowser(Browser.CHROME).build();
9
+ }, 60_000);
10
+
11
+ afterAll(async () => {
12
+ await driver?.quit();
13
+ });
14
+
15
+ it("GET /", async () => {
16
+ if (!driver) throw new Error("WebDriver was not initialized");
17
+
18
+ const baseURL =
19
+ process.env.BASE_URL ?? `http://127.0.0.1:${process.env.PORT ?? "3000"}`;
20
+ await driver.get(baseURL);
21
+
22
+ const body = await driver.findElement(By.css("body")).getText();
23
+
24
+ expect(body).toBe("Hello World!");
25
+ });
26
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "jest --config ./test/jest-e2e.json"
4
+ }
5
+ }
@@ -0,0 +1,29 @@
1
+ import { Test, TestingModule } from "@nestjs/testing";
2
+ import { INestApplication } from "@nestjs/common";
3
+ import request from "supertest";
4
+ import { App } from "supertest/types";
5
+ import { AppModule } from "../src/app.module";
6
+
7
+ describe("AppController (e2e)", () => {
8
+ let app: INestApplication<App>;
9
+
10
+ beforeAll(async () => {
11
+ const moduleFixture: TestingModule = await Test.createTestingModule({
12
+ imports: [AppModule],
13
+ }).compile();
14
+
15
+ app = moduleFixture.createNestApplication();
16
+ await app.init();
17
+ });
18
+
19
+ afterAll(async () => {
20
+ await app.close();
21
+ });
22
+
23
+ it("GET /", async () => {
24
+ await request(app.getHttpServer())
25
+ .get("/")
26
+ .expect(200)
27
+ .expect("Hello World!");
28
+ });
29
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "mocha --config ./test/.mocharc.e2e.json"
4
+ }
5
+ }
@@ -0,0 +1,30 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { Test, TestingModule } from "@nestjs/testing";
3
+ import { after, before, describe, it } from "mocha";
4
+ import request from "supertest";
5
+ import { App } from "supertest/types";
6
+ import { AppModule } from "../src/app.module";
7
+
8
+ describe("AppController (e2e)", () => {
9
+ let app: INestApplication<App>;
10
+
11
+ before(async () => {
12
+ const moduleFixture: TestingModule = await Test.createTestingModule({
13
+ imports: [AppModule],
14
+ }).compile();
15
+
16
+ app = moduleFixture.createNestApplication();
17
+ await app.init();
18
+ });
19
+
20
+ after(async () => {
21
+ await app.close();
22
+ });
23
+
24
+ it("GET /", async () => {
25
+ await request(app.getHttpServer())
26
+ .get("/")
27
+ .expect(200)
28
+ .expect("Hello World!");
29
+ });
30
+ });
@@ -0,0 +1,6 @@
1
+ {
2
+ "devDependencies": {
3
+ "@types/supertest": "^7.2.1",
4
+ "supertest": "^7.3.2"
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:e2e": "vitest run --config ./test/vitest.config.e2e.mjs"
4
+ }
5
+ }
@@ -0,0 +1,30 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { Test, TestingModule } from "@nestjs/testing";
3
+ import request from "supertest";
4
+ import { App } from "supertest/types";
5
+ import { afterAll, beforeAll, describe, it } from "vitest";
6
+ import { AppModule } from "../src/app.module";
7
+
8
+ describe("AppController (e2e)", () => {
9
+ let app: INestApplication<App>;
10
+
11
+ beforeAll(async () => {
12
+ const moduleFixture: TestingModule = await Test.createTestingModule({
13
+ imports: [AppModule],
14
+ }).compile();
15
+
16
+ app = moduleFixture.createNestApplication();
17
+ await app.init();
18
+ });
19
+
20
+ afterAll(async () => {
21
+ await app.close();
22
+ });
23
+
24
+ it("GET /", async () => {
25
+ await request(app.getHttpServer())
26
+ .get("/")
27
+ .expect(200)
28
+ .expect("Hello World!");
29
+ });
30
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "arktype": "^2.2.10"
4
+ }
5
+ }
@@ -0,0 +1,12 @@
1
+ import { type } from "arktype";
2
+
3
+ // Add environment variables types here
4
+ export const envSchema = type({
5
+ "+": "delete",
6
+ NODE_ENV: "'development' | 'production' | 'test' = 'development'",
7
+ PORT: type("string.integer.parse")
8
+ .to("1 <= number.integer <= 65535")
9
+ .default("3000"),
10
+ });
11
+
12
+ export type EnvironmentVariables = typeof envSchema.infer;
@@ -0,0 +1,12 @@
1
+ import { type } from "arktype";
2
+ import { envSchema } from "./env.schema";
3
+
4
+ export default function validate(config: Record<string, unknown>) {
5
+ const parsed = envSchema(config);
6
+
7
+ if (parsed instanceof type.errors) {
8
+ throw new Error(`Config validation error:\n${parsed.summary}`);
9
+ }
10
+
11
+ return parsed;
12
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "dependencies": {
3
+ "class-transformer": "^0.5.1",
4
+ "class-validator": "^0.15.1"
5
+ }
6
+ }
@@ -0,0 +1,15 @@
1
+ import { Type } from "class-transformer";
2
+ import { IsIn, IsNumber, IsOptional, Max, Min } from "class-validator";
3
+
4
+ // Add environment variables types here
5
+ export class EnvironmentVariables {
6
+ @IsIn(["development", "production", "test"])
7
+ NODE_ENV: "development" | "production" | "test" = "development";
8
+
9
+ @Type(() => Number)
10
+ @IsNumber()
11
+ @IsOptional()
12
+ @Min(1)
13
+ @Max(65535)
14
+ PORT: number = 3000;
15
+ }
@@ -0,0 +1,15 @@
1
+ import { plainToInstance } from "class-transformer";
2
+ import { validateSync } from "class-validator";
3
+ import { EnvironmentVariables } from "./env.schema";
4
+
5
+ export default function validate(config: Record<string, unknown>) {
6
+ const validatedConfig = plainToInstance(EnvironmentVariables, config, {
7
+ enableImplicitConversion: true,
8
+ });
9
+ const errors = validateSync(validatedConfig, {
10
+ skipMissingProperties: false,
11
+ });
12
+
13
+ if (errors.length > 0) throw new Error(errors.toString());
14
+ return validatedConfig;
15
+ }