@nest-arch/tui 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.
- package/README.md +53 -0
- package/dist/cli.js +2 -0
- package/dist/index-BEmiTZdl.js +31157 -0
- package/dist/index-CAPJ7KZy.js +4 -0
- package/dist/index.js +1 -0
- package/dist/templates/addons/husky/pre-commit.hbs +31 -0
- package/dist/templates/base/.env.hbs +2 -0
- package/dist/templates/base/.gitignore.hbs +56 -0
- package/dist/templates/base/.yarnrc.yml.hbs +6 -0
- package/dist/templates/base/README.md.hbs +37 -0
- package/dist/templates/base/nest-cli.json.hbs +8 -0
- package/dist/templates/base/pnpm-workspace.yaml.hbs +2 -0
- package/dist/templates/base/src/app.controller.spec.ts.hbs +25 -0
- package/dist/templates/base/src/app.controller.ts.hbs +13 -0
- package/dist/templates/base/src/app.module.ts.hbs +11 -0
- package/dist/templates/base/src/app.service.ts.hbs +8 -0
- package/dist/templates/base/src/main.ts.hbs +14 -0
- package/dist/templates/base/test/app.e2e-spec.ts.hbs +22 -0
- package/dist/templates/base/tsconfig.build.json.hbs +12 -0
- package/dist/templates/base/tsconfig.json.hbs +27 -0
- package/dist/templates/base/vitest.config.e2e.ts.hbs +9 -0
- package/dist/templates/base/vitest.config.ts.hbs +9 -0
- package/dist/templates/extras/docker/.dockerignore.hbs +1 -0
- package/dist/templates/extras/docker/Dockerfile.hbs +2 -0
- package/dist/templates/extras/docker/docker-compose.yml.hbs +3 -0
- package/dist/templates/extras/swagger/dependencies.hbs +1 -0
- package/dist/templates/monorepo/apps/api-gateway/nest-cli.json.hbs +8 -0
- package/dist/templates/monorepo/apps/api-gateway/package.json.hbs +49 -0
- package/dist/templates/monorepo/apps/api-gateway/src/app.controller.spec.ts.hbs +25 -0
- package/dist/templates/monorepo/apps/api-gateway/src/app.controller.ts.hbs +13 -0
- package/dist/templates/monorepo/apps/api-gateway/src/app.module.ts.hbs +11 -0
- package/dist/templates/monorepo/apps/api-gateway/src/app.service.ts.hbs +8 -0
- package/dist/templates/monorepo/apps/api-gateway/src/main.ts.hbs +13 -0
- package/dist/templates/monorepo/apps/api-gateway/test/app.e2e-spec.ts.hbs +22 -0
- package/dist/templates/monorepo/apps/api-gateway/tsconfig.build.json.hbs +9 -0
- package/dist/templates/monorepo/apps/api-gateway/tsconfig.json.hbs +4 -0
- package/dist/templates/monorepo/apps/api-gateway/vitest.config.e2e.ts.hbs +9 -0
- package/dist/templates/monorepo/apps/api-gateway/vitest.config.ts.hbs +9 -0
- package/dist/templates/monorepo/packages/config/package.json.hbs +5 -0
- package/dist/templates/monorepo/packages/config/tsconfig.base.json.hbs +22 -0
- package/dist/templates/monorepo/packages/config/tsconfig.nestjs.json.hbs +24 -0
- package/dist/templates/monorepo/packages/env/package.json.hbs +19 -0
- package/dist/templates/monorepo/packages/env/src/api-gateway.ts.hbs +37 -0
- package/dist/templates/monorepo/packages/env/tsconfig.json.hbs +4 -0
- package/dist/templates/monorepo/packages/shared/package.json.hbs +17 -0
- package/dist/templates/monorepo/packages/shared/tsconfig.json.hbs +4 -0
- package/dist/templates/monorepo/root/.gitignore.hbs +48 -0
- package/dist/templates/monorepo/root/.yarnrc.yml.hbs +6 -0
- package/dist/templates/monorepo/root/README.md.hbs +33 -0
- package/dist/templates/monorepo/root/package.json.hbs +35 -0
- package/dist/templates/monorepo/root/pnpm-workspace.yaml.hbs +11 -0
- package/dist/templates/monorepo/root/tsconfig.json.hbs +3 -0
- package/dist/templates/monorepo/root/turbo.json.hbs +21 -0
- package/dist/templates/single-project/architecture/nest-api/.env.hbs +2 -0
- package/dist/templates/single-project/architecture/nest-api/package.json.hbs +49 -0
- package/dist/templates/single-project/architecture/nest-api/pnpm-workspace.yaml.hbs +4 -0
- package/dist/templates/single-project/architecture/nest-api/src/main.ts.hbs +15 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/app.controller.ts.hbs +19 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/app.module.ts.hbs +12 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/app.service.ts.hbs +26 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/main.ts.hbs +15 -0
- package/dist/templates/single-project/architecture/nest-microservice/.env.hbs +3 -0
- package/dist/templates/single-project/architecture/nest-microservice/src/app.controller.ts.hbs +18 -0
- package/dist/templates/single-project/architecture/nest-microservice/src/app.module.ts.hbs +11 -0
- package/dist/templates/single-project/architecture/nest-microservice/src/app.service.ts.hbs +12 -0
- package/dist/templates/single-project/architecture/nest-microservice/src/main.ts.hbs +21 -0
- package/dist/templates/single-project/shared/config/env.ts.hbs +37 -0
- package/package.json +63 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
|
|
5
|
+
export const env = createEnv({
|
|
6
|
+
/**
|
|
7
|
+
* By default, this library will feed the environment variables directly to
|
|
8
|
+
* the Zod validator.
|
|
9
|
+
*
|
|
10
|
+
* This means that if you have an empty string for a value that is supposed
|
|
11
|
+
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
|
|
12
|
+
* it as a type mismatch violation. Additionally, if you have an empty string
|
|
13
|
+
* for a value that is supposed to be a string with a default value (e.g.
|
|
14
|
+
* `DOMAIN=` in an ".env" file), the default value will never be applied.
|
|
15
|
+
*
|
|
16
|
+
* In order to solve these issues, we recommend that all new projects
|
|
17
|
+
* explicitly specify this option as true.
|
|
18
|
+
*/
|
|
19
|
+
emptyStringAsUndefined: true,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* What object holds the environment variables at runtime. This is usually
|
|
23
|
+
* `process.env` or `import.meta.env`.
|
|
24
|
+
*/
|
|
25
|
+
runtimeEnv: process.env,
|
|
26
|
+
|
|
27
|
+
server: {
|
|
28
|
+
CORS_ORIGIN: z.string().default("*"),
|
|
29
|
+
NODE_ENV: z
|
|
30
|
+
.enum(["development", "production", "test"])
|
|
31
|
+
.default("development"),
|
|
32
|
+
PORT: z
|
|
33
|
+
.string()
|
|
34
|
+
.transform((val) => Number.parseInt(val, 10))
|
|
35
|
+
.default(3000),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repo/shared",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./*": "./src/*"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"zod": "catalog:"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@repo/config": "workspace:*",
|
|
14
|
+
"@types/node": "catalog:",
|
|
15
|
+
"typescript": "catalog:"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
|
|
6
|
+
# Build outputs
|
|
7
|
+
dist
|
|
8
|
+
build
|
|
9
|
+
*.tsbuildinfo
|
|
10
|
+
|
|
11
|
+
# Environment variables
|
|
12
|
+
.env
|
|
13
|
+
.env*.local
|
|
14
|
+
|
|
15
|
+
# IDEs and editors
|
|
16
|
+
.vscode/*
|
|
17
|
+
!.vscode/settings.json
|
|
18
|
+
!.vscode/tasks.json
|
|
19
|
+
!.vscode/launch.json
|
|
20
|
+
!.vscode/extensions.json
|
|
21
|
+
.idea
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
*~
|
|
25
|
+
.DS_Store
|
|
26
|
+
|
|
27
|
+
# Logs
|
|
28
|
+
logs
|
|
29
|
+
*.log
|
|
30
|
+
npm-debug.log*
|
|
31
|
+
yarn-debug.log*
|
|
32
|
+
yarn-error.log*
|
|
33
|
+
lerna-debug.log*
|
|
34
|
+
.pnpm-debug.log*
|
|
35
|
+
|
|
36
|
+
# Turbo
|
|
37
|
+
.turbo
|
|
38
|
+
.nx
|
|
39
|
+
|
|
40
|
+
# Testing
|
|
41
|
+
coverage
|
|
42
|
+
.nyc_output
|
|
43
|
+
|
|
44
|
+
# Misc
|
|
45
|
+
*.tgz
|
|
46
|
+
.cache
|
|
47
|
+
tmp
|
|
48
|
+
temp
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# {{projectName}}
|
|
2
|
+
|
|
3
|
+
{{description}}
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install dependencies
|
|
9
|
+
{{#if isPnpm}}pnpm install{{else if isYarn}}yarn install{{else if isBun}}bun install{{else}}npm install{{/if}}
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Running the App
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
# development mode (live reload)
|
|
16
|
+
{{#if isPnpm}}pnpm dev{{else if isYarn}}yarn dev{{else if isBun}}bun run dev{{else}}npm run dev{{/if}}
|
|
17
|
+
|
|
18
|
+
# build and production mode
|
|
19
|
+
{{#if isPnpm}}pnpm build{{else if isYarn}}yarn build{{else if isBun}}bun run build{{else}}npm run build{{/if}}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Testing
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# unit tests
|
|
26
|
+
{{#if isPnpm}}pnpm test{{else if isYarn}}yarn test{{else if isBun}}bun run test{{else}}npm test{{/if}}
|
|
27
|
+
|
|
28
|
+
# e2e tests
|
|
29
|
+
{{#if isPnpm}}pnpm test:e2e{{else if isYarn}}yarn test:e2e{{else if isBun}}bun run test:e2e{{else}}npm run test:e2e{{/if}}
|
|
30
|
+
|
|
31
|
+
# test coverage
|
|
32
|
+
{{#if isPnpm}}pnpm test:cov{{else if isYarn}}yarn test:cov{{else if isBun}}bun run test:cov{{else}}npm run test:cov{{/if}}
|
|
33
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"workspaces": [
|
|
5
|
+
"apps/*",
|
|
6
|
+
"packages/*"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "turbo dev",
|
|
11
|
+
"build": "turbo build",
|
|
12
|
+
"check-types": "turbo check-types"{{#if hasUltracite}},
|
|
13
|
+
"check": "ultracite check"{{/if}}{{#if hasHusky}},
|
|
14
|
+
"prepare": "husky"{{/if}}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@repo/env": "workspace:*",
|
|
18
|
+
"dotenv": "catalog:",
|
|
19
|
+
"zod": "catalog:"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@repo/config": "workspace:*",
|
|
23
|
+
"@types/node": "catalog:",
|
|
24
|
+
{{#if hasHusky}}"husky": "^9.1.7",{{/if}}
|
|
25
|
+
"turbo": "^2.8.12",
|
|
26
|
+
"typescript": "catalog:"
|
|
27
|
+
}{{#if hasHusky}},
|
|
28
|
+
"lint-staged": {
|
|
29
|
+
"*": [
|
|
30
|
+
"oxlint",
|
|
31
|
+
"oxfmt --write"
|
|
32
|
+
]
|
|
33
|
+
}{{/if}},
|
|
34
|
+
"packageManager": {{#if isPnpm}}"pnpm@10.33.0"{{else if isYarn}}"yarn@4.6.0"{{else if isBun}}"bun@1.3.14"{{else}}undefined{{/if}}
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://turbo.build/schema.json",
|
|
3
|
+
"ui": "tui",
|
|
4
|
+
"tasks": {
|
|
5
|
+
"build": {
|
|
6
|
+
"dependsOn": ["^build"],
|
|
7
|
+
"inputs": ["$TURBO_DEFAULT$", ".env*"],
|
|
8
|
+
"outputs": ["dist/**"]
|
|
9
|
+
},
|
|
10
|
+
"lint": {
|
|
11
|
+
"dependsOn": ["^lint"]
|
|
12
|
+
},
|
|
13
|
+
"check-types": {
|
|
14
|
+
"dependsOn": ["^check-types"]
|
|
15
|
+
},
|
|
16
|
+
"dev": {
|
|
17
|
+
"cache": false,
|
|
18
|
+
"persistent": true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{projectName}}",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "{{description}}",
|
|
6
|
+
"license": "UNLICENSED",
|
|
7
|
+
"author": "",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "nest build",
|
|
11
|
+
"dev": "nest start --watch",
|
|
12
|
+
"start": "nest start",
|
|
13
|
+
"start:dev": "nest start --watch",
|
|
14
|
+
"start:debug": "nest start --debug --watch",
|
|
15
|
+
"start:prod": "node dist/main",
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"test:cov": "vitest run --coverage",
|
|
19
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism",
|
|
20
|
+
"test:e2e": "vitest run --config ./vitest.config.e2e.ts"{{#if hasUltracite}},
|
|
21
|
+
"check": "ultracite check",
|
|
22
|
+
"fix": "ultracite fix"{{/if}}{{#if hasHusky}},
|
|
23
|
+
"prepare": "husky"{{/if}}
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@nestjs/common": "next",
|
|
27
|
+
"@nestjs/core": "next",
|
|
28
|
+
"@nestjs/platform-{{httpProvider}}": "next",
|
|
29
|
+
"@t3-oss/env-core": "^0.13.11",
|
|
30
|
+
"dotenv": "^17.2.2",
|
|
31
|
+
"reflect-metadata": "^0.2.2",
|
|
32
|
+
"rxjs": "^7.8.1",
|
|
33
|
+
"zod": "^4.4.3"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@nestjs/cli": "next",
|
|
37
|
+
"@nestjs/schematics": "next",
|
|
38
|
+
"@nestjs/testing": "next",
|
|
39
|
+
"@types/express": "^5.0.0",
|
|
40
|
+
"@types/node": "^22.13.14",
|
|
41
|
+
"@types/supertest": "^7.0.0",
|
|
42
|
+
"@vitest/coverage-v8": "4.1.6",
|
|
43
|
+
{{#if hasHusky}}"husky": "^9.1.7",{{/if}}
|
|
44
|
+
"source-map-support": "^0.5.21",
|
|
45
|
+
"supertest": "^7.0.0",
|
|
46
|
+
"typescript": "^6.0.2",
|
|
47
|
+
"vitest": "^4.1.2"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NestFactory } from "@nestjs/core";
|
|
2
|
+
|
|
3
|
+
import { AppModule } from "./app.module.js";
|
|
4
|
+
import { env } from "./config/env.js";
|
|
5
|
+
|
|
6
|
+
async function bootstrap() {
|
|
7
|
+
const app = await NestFactory.create(AppModule);
|
|
8
|
+
app.enableCors({
|
|
9
|
+
origin: env.CORS_ORIGIN,
|
|
10
|
+
});
|
|
11
|
+
app.setGlobalPrefix("api");
|
|
12
|
+
|
|
13
|
+
await app.listen(env.PORT ?? 3000);
|
|
14
|
+
}
|
|
15
|
+
await bootstrap();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Controller, Get, Req, Res } from "@nestjs/common";
|
|
2
|
+
import type { Request, Response } from "express";
|
|
3
|
+
|
|
4
|
+
import { AppService } from "./app.service.js";
|
|
5
|
+
|
|
6
|
+
@Controller()
|
|
7
|
+
export class AppController {
|
|
8
|
+
constructor(private readonly appService: AppService) {}
|
|
9
|
+
|
|
10
|
+
@Get()
|
|
11
|
+
getHello(): string {
|
|
12
|
+
return this.appService.getHello();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Get("*")
|
|
16
|
+
proxy(@Req() req: Request, @Res() res: Response): void {
|
|
17
|
+
this.appService.proxyRequest(req, res);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Module } from "@nestjs/common";
|
|
2
|
+
import { HttpModule } from "@nestjs/axios";
|
|
3
|
+
|
|
4
|
+
import { AppController } from "./app.controller.js";
|
|
5
|
+
import { AppService } from "./app.service.js";
|
|
6
|
+
|
|
7
|
+
@Module({
|
|
8
|
+
controllers: [AppController],
|
|
9
|
+
imports: [HttpModule],
|
|
10
|
+
providers: [AppService],
|
|
11
|
+
})
|
|
12
|
+
export class AppModule {}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Injectable } from "@nestjs/common";
|
|
2
|
+
import { HttpService } from "@nestjs/axios";
|
|
3
|
+
import type { Request, Response } from "express";
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class AppService {
|
|
7
|
+
constructor(private readonly httpService: HttpService) {}
|
|
8
|
+
|
|
9
|
+
getHello(): string {
|
|
10
|
+
return "Hello World!";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async proxyRequest(req: Request, res: Response): Promise<void> {
|
|
14
|
+
try {
|
|
15
|
+
const response = await this.httpService.axiosRef({
|
|
16
|
+
data: req.body,
|
|
17
|
+
headers: req.headers,
|
|
18
|
+
method: req.method,
|
|
19
|
+
url: `http://localhost:3001${req.url}`,
|
|
20
|
+
});
|
|
21
|
+
res.status(response.status).json(response.data);
|
|
22
|
+
} catch {
|
|
23
|
+
res.status(502).json({ message: "Bad Gateway" });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NestFactory } from "@nestjs/core";
|
|
2
|
+
|
|
3
|
+
import { AppModule } from "./app.module.js";
|
|
4
|
+
import { env } from "./config/env.js";
|
|
5
|
+
|
|
6
|
+
async function bootstrap() {
|
|
7
|
+
const app = await NestFactory.create(AppModule);
|
|
8
|
+
app.enableCors({
|
|
9
|
+
origin: env.CORS_ORIGIN,
|
|
10
|
+
});
|
|
11
|
+
app.setGlobalPrefix("api");
|
|
12
|
+
|
|
13
|
+
await app.listen(env.PORT ?? 3000);
|
|
14
|
+
}
|
|
15
|
+
await bootstrap();
|
package/dist/templates/single-project/architecture/nest-microservice/src/app.controller.ts.hbs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Controller, EventPattern, MessagePattern } from "@nestjs/common";
|
|
2
|
+
|
|
3
|
+
import { AppService } from "./app.service.js";
|
|
4
|
+
|
|
5
|
+
@Controller()
|
|
6
|
+
export class AppController {
|
|
7
|
+
constructor(private readonly appService: AppService) {}
|
|
8
|
+
|
|
9
|
+
@MessagePattern("ping")
|
|
10
|
+
handlePing(): string {
|
|
11
|
+
return this.appService.handlePing();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@EventPattern("log")
|
|
15
|
+
handleLog(data: Record<string, unknown>): void {
|
|
16
|
+
this.appService.handleLog(data);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Module } from "@nestjs/common";
|
|
2
|
+
|
|
3
|
+
import { AppController } from "./app.controller.js";
|
|
4
|
+
import { AppService } from "./app.service.js";
|
|
5
|
+
|
|
6
|
+
@Module({
|
|
7
|
+
controllers: [AppController],
|
|
8
|
+
imports: [],
|
|
9
|
+
providers: [AppService],
|
|
10
|
+
})
|
|
11
|
+
export class AppModule {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NestFactory } from "@nestjs/core";
|
|
2
|
+
import { Transport, type MicroserviceOptions } from "@nestjs/microservices";
|
|
3
|
+
|
|
4
|
+
import { AppModule } from "./app.module.js";
|
|
5
|
+
import { env } from "./config/env.js";
|
|
6
|
+
|
|
7
|
+
async function bootstrap() {
|
|
8
|
+
const app = await NestFactory.create(AppModule);
|
|
9
|
+
|
|
10
|
+
app.connectMicroservice<MicroserviceOptions>({
|
|
11
|
+
transport: Transport.TCP,
|
|
12
|
+
options: {
|
|
13
|
+
host: "0.0.0.0",
|
|
14
|
+
port: env.MICROSERVICE_PORT ?? 3001,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
await app.startAllMicroservices();
|
|
19
|
+
await app.listen(env.PORT ?? 3000);
|
|
20
|
+
}
|
|
21
|
+
await bootstrap();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
|
|
5
|
+
export const env = createEnv({
|
|
6
|
+
/**
|
|
7
|
+
* By default, this library will feed the environment variables directly to
|
|
8
|
+
* the Zod validator.
|
|
9
|
+
*
|
|
10
|
+
* This means that if you have an empty string for a value that is supposed
|
|
11
|
+
* to be a number (e.g. `PORT=` in a ".env" file), Zod will incorrectly flag
|
|
12
|
+
* it as a type mismatch violation. Additionally, if you have an empty string
|
|
13
|
+
* for a value that is supposed to be a string with a default value (e.g.
|
|
14
|
+
* `DOMAIN=` in an ".env" file), the default value will never be applied.
|
|
15
|
+
*
|
|
16
|
+
* In order to solve these issues, we recommend that all new projects
|
|
17
|
+
* explicitly specify this option as true.
|
|
18
|
+
*/
|
|
19
|
+
emptyStringAsUndefined: true,
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* What object holds the environment variables at runtime. This is usually
|
|
23
|
+
* `process.env` or `import.meta.env`.
|
|
24
|
+
*/
|
|
25
|
+
runtimeEnv: process.env,
|
|
26
|
+
|
|
27
|
+
server: {
|
|
28
|
+
CORS_ORIGIN: z.string().default("*"),
|
|
29
|
+
NODE_ENV: z
|
|
30
|
+
.enum(["development", "production", "test"])
|
|
31
|
+
.default("development"),
|
|
32
|
+
PORT: z
|
|
33
|
+
.string()
|
|
34
|
+
.transform((val) => Number.parseInt(val, 10))
|
|
35
|
+
.default(3000),
|
|
36
|
+
},
|
|
37
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nest-arch/tui",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "Interactive terminal UI for generating NestJS projects",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"cli",
|
|
8
|
+
"generator",
|
|
9
|
+
"nestjs",
|
|
10
|
+
"scaffolding",
|
|
11
|
+
"terminal",
|
|
12
|
+
"tui"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/Angel-Mario/nest-arch#readme",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Angel-Mario/nest-arch/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "https://github.com/Angel-Mario/nest-arch",
|
|
22
|
+
"directory": "apps/tui"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"nest-arch": "./dist/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"type": "module",
|
|
32
|
+
"main": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "tsx src/index.tsx",
|
|
38
|
+
"dev:watch": "tsx watch src/index.tsx",
|
|
39
|
+
"build": "pkgroll --minify --target=node18 && node scripts/copy-templates.js",
|
|
40
|
+
"copy-templates": "node -e \"import('node:fs').then(({cpSync})=>cpSync('../../packages/core/templates','dist/templates',{recursive:true}))\"",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"check-types": "tsc --noEmit",
|
|
43
|
+
"prepublishOnly": "pnpm run build"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"ink": "^5.0.1",
|
|
47
|
+
"ink-text-input": "^6.0.0",
|
|
48
|
+
"open": "^11.0.0",
|
|
49
|
+
"react": "^18.3.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@nest-arch/core": "workspace:*",
|
|
53
|
+
"@nest-arch/env": "workspace:*",
|
|
54
|
+
"@nest-arch/shared": "workspace:*",
|
|
55
|
+
"@types/react": "^18.3.12",
|
|
56
|
+
"pkgroll": "^2.5.2",
|
|
57
|
+
"tsx": "^4.19.2",
|
|
58
|
+
"vitest": "^4.1.7"
|
|
59
|
+
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"typescript": "^5"
|
|
62
|
+
}
|
|
63
|
+
}
|