@nest-arch/tui 0.1.39 → 0.1.45
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/cli.js +1 -1
- package/dist/index-BUgQzcBt.js +4 -0
- package/dist/index-E3XHqeRi.js +117 -0
- package/dist/index.js +1 -1
- package/dist/templates/base/.env.hbs +17 -0
- package/dist/templates/base/.gitignore.hbs +3 -0
- package/dist/templates/base/README.md.hbs +37 -0
- package/dist/templates/base/pnpm-workspace.yaml.hbs +4 -0
- package/dist/templates/base/prisma.config.ts.hbs +11 -0
- package/dist/templates/base/src/app.controller.spec.ts.hbs +21 -2
- package/dist/templates/base/src/app.controller.ts.hbs +6 -1
- package/dist/templates/base/src/app.module.ts.hbs +20 -1
- package/dist/templates/base/src/app.service.ts.hbs +7 -0
- package/dist/templates/base/src/database/adapters/interfaces/db-adapter.interface.ts.hbs +14 -0
- package/dist/templates/base/src/database/adapters/mongo/prisma-mongo.adapter.ts.hbs +25 -0
- package/dist/templates/base/src/database/adapters/mongo/raw-mongo.adapter.ts.hbs +17 -0
- package/dist/templates/base/src/database/adapters/sql/drizzle-sql.adapter.ts.hbs +24 -0
- package/dist/templates/base/src/database/adapters/sql/prisma-sql.adapter.ts.hbs +29 -0
- package/dist/templates/base/src/database/adapters/sql/raw-sql.adapter.ts.hbs +49 -0
- package/dist/templates/base/src/database/adapters/sql/typeorm-sql.adapter.ts.hbs +23 -0
- package/dist/templates/base/src/database/db.module.ts.hbs +244 -0
- package/dist/templates/base/src/database/db.service.ts.hbs +88 -0
- package/dist/templates/base/src/database/entities/todo.entity.ts.hbs +32 -0
- package/dist/templates/base/src/database/index.ts.hbs +10 -0
- package/dist/templates/base/src/database/orm/drizzle/schema.ts.hbs +30 -0
- package/dist/templates/base/src/database/orm/typeorm/data-source.ts.hbs +24 -0
- package/dist/templates/base/src/database/schema/index.ts.hbs +32 -0
- package/dist/templates/base/src/main.ts.hbs +1 -1
- package/dist/templates/base/tsconfig.json.hbs +1 -1
- package/dist/templates/extras/docker/Dockerfile.hbs +22 -2
- package/dist/templates/extras/docker/docker-compose.yml.hbs +11 -3
- package/dist/templates/monorepo/apps/api-gateway/src/app.controller.spec.ts.hbs +21 -2
- package/dist/templates/monorepo/apps/api-gateway/src/app.module.ts.hbs +20 -1
- package/dist/templates/monorepo/apps/api-gateway/src/app.service.ts.hbs +7 -0
- package/dist/templates/monorepo/packages/db/package.json.hbs +21 -0
- package/dist/templates/monorepo/packages/db/tsconfig.json.hbs +4 -0
- package/dist/templates/monorepo/packages/env/src/api-gateway.ts.hbs +12 -0
- package/dist/templates/monorepo/root/.gitignore.hbs +3 -0
- package/dist/templates/monorepo/root/README.md.hbs +37 -0
- package/dist/templates/single-project/architecture/nest-gateway/src/app.module.ts.hbs +20 -1
- package/dist/templates/single-project/architecture/nest-gateway/src/app.service.ts.hbs +7 -1
- package/dist/templates/single-project/architecture/nest-microservice/src/app.module.ts.hbs +20 -1
- package/dist/templates/single-project/architecture/nest-microservice/src/app.service.ts.hbs +7 -0
- package/dist/templates/single-project/shared/config/env.ts.hbs +16 -0
- package/package.json +2 -2
- package/dist/index--w1UOCDp.js +0 -4
- package/dist/index-DuMVjfjC.js +0 -51
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// oxlint-disable typescript/no-explicit-any
|
|
2
|
+
{{#if hasPostgres}}
|
|
3
|
+
import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
|
|
4
|
+
|
|
5
|
+
export const users = pgTable('users', {
|
|
6
|
+
id: serial('id').primaryKey(),
|
|
7
|
+
name: text('name'),
|
|
8
|
+
email: text('email').unique(),
|
|
9
|
+
createdAt: timestamp('created_at').defaultNow(),
|
|
10
|
+
});
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if hasMysql}}
|
|
13
|
+
import { mysqlTable, serial, text, timestamp } from 'drizzle-orm/mysql-core';
|
|
14
|
+
|
|
15
|
+
export const users = mysqlTable('users', {
|
|
16
|
+
id: serial('id').primaryKey(),
|
|
17
|
+
name: text('name'),
|
|
18
|
+
email: text('email').unique(),
|
|
19
|
+
createdAt: timestamp('created_at').defaultNow(),
|
|
20
|
+
});
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if hasSqlite}}
|
|
23
|
+
import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
|
|
24
|
+
|
|
25
|
+
export const users = sqliteTable('users', {
|
|
26
|
+
id: integer('id').primaryKey({ autoIncrement: true }),
|
|
27
|
+
name: text('name'),
|
|
28
|
+
email: text('email').unique(),
|
|
29
|
+
});
|
|
30
|
+
{{/if}}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// oxlint-disable typescript/no-non-null-assertion
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import "reflect-metadata";
|
|
4
|
+
import { DataSource } from "typeorm";
|
|
5
|
+
|
|
6
|
+
const databaseUrl =
|
|
7
|
+
process.env.{{#if hasPostgres}}POSTGRES_URL{{/if}}{{#if hasMysql}}MYSQL_URL{{/if}}{{#if hasSqlite}}SQLITE_PATH{{/if}}!;
|
|
8
|
+
|
|
9
|
+
{{#unless hasSqlite}}
|
|
10
|
+
const parsedUrl = new URL(databaseUrl);
|
|
11
|
+
{{/unless}}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export const AppDataSource = new DataSource({
|
|
15
|
+
entities: [join(import.meta.dirname, "..", "..", "entities", "*.entity.js")],
|
|
16
|
+
migrations: [{{#if isMonorepo}}"migrations/*.{ts,js}"{{else}}"migrations/*.{ts,js}"{{/if}}],
|
|
17
|
+
synchronize: true,
|
|
18
|
+
type: "{{#if hasPostgres}}postgres{{/if}}{{#if hasMysql}}mysql{{/if}}{{#if hasSqlite}}better-sqlite3{{/if}}",
|
|
19
|
+
url: databaseUrl,
|
|
20
|
+
{{#unless hasSqlite}}
|
|
21
|
+
...(parsedUrl.username ? { username: decodeURIComponent(parsedUrl.username) } : {}),
|
|
22
|
+
...(parsedUrl.password ? { password: decodeURIComponent(parsedUrl.password) } : {}),
|
|
23
|
+
{{/unless}}
|
|
24
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// oxlint-disable typescript/no-explicit-any
|
|
2
|
+
// Define your database schema here.
|
|
3
|
+
// See: https://orm.drizzle.team/docs/sql-schema-declaration
|
|
4
|
+
{{#if hasPostgres}}
|
|
5
|
+
// import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
|
|
6
|
+
//
|
|
7
|
+
// export const users = pgTable('users', {
|
|
8
|
+
// id: serial('id').primaryKey(),
|
|
9
|
+
// name: text('name'),
|
|
10
|
+
// email: text('email').unique(),
|
|
11
|
+
// createdAt: timestamp('created_at').defaultNow(),
|
|
12
|
+
// });
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if hasMysql}}
|
|
15
|
+
// import { mysqlTable, serial, text, timestamp } from 'drizzle-orm/mysql-core';
|
|
16
|
+
//
|
|
17
|
+
// export const users = mysqlTable('users', {
|
|
18
|
+
// id: serial('id').primaryKey(),
|
|
19
|
+
// name: text('name'),
|
|
20
|
+
// email: text('email').unique(),
|
|
21
|
+
// createdAt: timestamp('created_at').defaultNow(),
|
|
22
|
+
// });
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if hasSqlite}}
|
|
25
|
+
// import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
|
|
26
|
+
//
|
|
27
|
+
// export const users = sqliteTable('users', {
|
|
28
|
+
// id: integer('id').primaryKey({ autoIncrement: true }),
|
|
29
|
+
// name: text('name'),
|
|
30
|
+
// email: text('email').unique(),
|
|
31
|
+
// });
|
|
32
|
+
{{/if}}
|
|
@@ -7,7 +7,7 @@ import { AppModule } from "./app.module.js";
|
|
|
7
7
|
import { env } from "./config/env.js";
|
|
8
8
|
|
|
9
9
|
async function bootstrap() {
|
|
10
|
-
const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter()
|
|
10
|
+
const app = await NestFactory.create{{#if (eq httpProvider "fastify")}}<NestFastifyApplication>(AppModule, new FastifyAdapter(){{else}}(AppModule{{/if}}{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}, { bodyParser: false }{{/if}});
|
|
11
11
|
app.enableCors({
|
|
12
12
|
origin: env.CORS_ORIGIN,
|
|
13
13
|
});
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
FROM node:
|
|
2
|
-
|
|
1
|
+
FROM node:22-alpine
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
{{#if (eq packageManager "pnpm")}}
|
|
6
|
+
RUN corepack enable && corepack prepare pnpm@latest --activate
|
|
7
|
+
COPY package.json pnpm-lock.yaml ./
|
|
8
|
+
RUN pnpm install --frozen-lockfile
|
|
9
|
+
{{else if (eq packageManager "yarn")}}
|
|
10
|
+
COPY package.json yarn.lock ./
|
|
11
|
+
RUN yarn install --frozen-lockfile
|
|
12
|
+
{{else}}
|
|
13
|
+
COPY package*.json ./
|
|
14
|
+
RUN npm ci
|
|
15
|
+
{{/if}}
|
|
16
|
+
|
|
17
|
+
COPY . .
|
|
18
|
+
RUN {{packageManager}} run build
|
|
19
|
+
|
|
20
|
+
EXPOSE 3000
|
|
21
|
+
|
|
22
|
+
CMD ["{{packageManager}}", "run", "start:prod"]
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
{{projectName}}:
|
|
3
|
-
|
|
1
|
+
services:
|
|
2
|
+
{{projectName}}:
|
|
3
|
+
build: .
|
|
4
|
+
ports:
|
|
5
|
+
- "3000:3000"
|
|
6
|
+
environment:
|
|
7
|
+
NODE_ENV: development
|
|
8
|
+
PORT: 3000
|
|
9
|
+
volumes:
|
|
10
|
+
- .:/app
|
|
11
|
+
- /app/node_modules
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
// oxlint-disable vitest/require-mock-type-parameters
|
|
1
2
|
import type { TestingModule } from "@nestjs/testing";
|
|
2
3
|
import { Test } from "@nestjs/testing";
|
|
3
|
-
import { beforeEach, describe, expect, it } from "vitest";
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
5
|
|
|
5
6
|
import { AppController } from "./app.controller.js";
|
|
6
7
|
import { AppService } from "./app.service.js";
|
|
8
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
9
|
+
import type { ISqlAdapter } from "./database/adapters/interfaces/db-adapter.interface.js";
|
|
10
|
+
import { DbService } from "./database/db.service.js";
|
|
11
|
+
{{/if}}
|
|
12
|
+
|
|
13
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
14
|
+
const mockSqlAdapter: ISqlAdapter = {
|
|
15
|
+
execute: vi.fn().mockResolvedValue(null),
|
|
16
|
+
getClient: vi.fn().mockReturnValue({}),
|
|
17
|
+
query: vi.fn().mockResolvedValue([]),
|
|
18
|
+
};
|
|
19
|
+
{{/if}}
|
|
7
20
|
|
|
8
21
|
describe(AppController, () => {
|
|
9
22
|
let appController: AppController;
|
|
@@ -11,7 +24,13 @@ describe(AppController, () => {
|
|
|
11
24
|
beforeEach(async () => {
|
|
12
25
|
const app: TestingModule = await Test.createTestingModule({
|
|
13
26
|
controllers: [AppController],
|
|
14
|
-
providers: [
|
|
27
|
+
providers: [
|
|
28
|
+
AppService,
|
|
29
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
30
|
+
DbService,
|
|
31
|
+
{ provide: "SQL_ADAPTER", useValue: mockSqlAdapter },
|
|
32
|
+
{{/if}}
|
|
33
|
+
],
|
|
15
34
|
}).compile();
|
|
16
35
|
|
|
17
36
|
appController = app.get<AppController>(AppController);
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { Module } from "@nestjs/common";
|
|
2
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
3
|
+
import { DbModule } from "./database/db.module.js";
|
|
4
|
+
import { env } from "./config/env.js";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
7
|
+
import { AuthModule } from "./auth/auth.module.js";
|
|
8
|
+
{{/if}}
|
|
2
9
|
|
|
3
10
|
import { AppController } from "./app.controller.js";
|
|
4
11
|
import { AppService } from "./app.service.js";
|
|
5
12
|
|
|
6
13
|
@Module({
|
|
7
14
|
controllers: [AppController],
|
|
8
|
-
imports: [
|
|
15
|
+
imports: [
|
|
16
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
17
|
+
DbModule.forRoot({
|
|
18
|
+
{{#if hasPostgres}}postgresUrl: env.POSTGRES_URL,{{/if}}
|
|
19
|
+
{{#if hasMysql}}mysqlUrl: env.MYSQL_URL,{{/if}}
|
|
20
|
+
{{#if hasSqlite}}sqlitePath: env.SQLITE_PATH,{{/if}}
|
|
21
|
+
{{#if hasMongodb}}mongodbUrl: env.MONGODB_URL,{{/if}}
|
|
22
|
+
}),
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
25
|
+
AuthModule,
|
|
26
|
+
{{/if}}
|
|
27
|
+
],
|
|
9
28
|
providers: [AppService],
|
|
10
29
|
})
|
|
11
30
|
export class AppModule {}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
3
|
+
import { DbService } from "./database/db.service.js";
|
|
4
|
+
{{/if}}
|
|
2
5
|
|
|
3
6
|
@Injectable()
|
|
4
7
|
export class AppService {
|
|
8
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
9
|
+
constructor(private readonly db: DbService) {}
|
|
10
|
+
|
|
11
|
+
{{/if}}
|
|
5
12
|
getHello(): string {
|
|
6
13
|
return "Hello World!";
|
|
7
14
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@repo/db",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./src/index.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.ts"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"@nestjs/common": "catalog:",
|
|
12
|
+
"@nestjs/core": "catalog:",
|
|
13
|
+
"reflect-metadata": "catalog:",
|
|
14
|
+
"rxjs": "catalog:"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@repo/config": "workspace:*",
|
|
18
|
+
"@types/node": "catalog:",
|
|
19
|
+
"typescript": "catalog:"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -33,5 +33,17 @@ export const env = createEnv({
|
|
|
33
33
|
.string()
|
|
34
34
|
.transform((val) => Number.parseInt(val, 10))
|
|
35
35
|
.default(3000),
|
|
36
|
+
{{#if hasPostgres}}
|
|
37
|
+
POSTGRES_URL: z.url(),
|
|
38
|
+
{{/if}}
|
|
39
|
+
{{#if hasMysql}}
|
|
40
|
+
MYSQL_URL: z.url(),
|
|
41
|
+
{{/if}}
|
|
42
|
+
{{#if hasSqlite}}
|
|
43
|
+
SQLITE_PATH: z.string().default("sqlite.db"),
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if hasMongodb}}
|
|
46
|
+
MONGODB_URL: z.url(),
|
|
47
|
+
{{/if}}
|
|
36
48
|
},
|
|
37
49
|
});
|
|
@@ -31,3 +31,40 @@
|
|
|
31
31
|
# test coverage
|
|
32
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
33
|
```
|
|
34
|
+
|
|
35
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
36
|
+
## Auth Setup
|
|
37
|
+
|
|
38
|
+
This project uses **Better Auth**. Generate the database schema by running:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
{{#if isPnpm}}pnpm dlx auth@latest generate --config src/auth/auth.ts --output src/database/orm/prisma/schema.prisma -y{{else if isYarn}}yarn dlx auth@latest generate --config src/auth/auth.ts --output src/database/orm/prisma/schema.prisma -y{{else if isBun}}bun x auth@latest generate --config src/auth/auth.ts --output src/database/orm/prisma/schema.prisma -y{{else}}npx auth@latest generate --config src/auth/auth.ts --output src/database/orm/prisma/schema.prisma -y{{/if}}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
{{#if useDrizzle}}Then run Drizzle migrations:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
{{#if isPnpm}}pnpm drizzle-kit generate && pnpm drizzle-kit migrate{{else if isYarn}}yarn drizzle-kit generate && yarn drizzle-kit migrate{{else}}npx drizzle-kit generate && npx drizzle-kit migrate{{/if}}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
{{/if}}
|
|
51
|
+
See https://better-auth.com/docs/adapters/prisma for more details.
|
|
52
|
+
|
|
53
|
+
### Usage
|
|
54
|
+
|
|
55
|
+
Access the authenticated user's session in any controller with full type safety (including better-auth plugins):
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Controller, Get } from "@nestjs/common";
|
|
59
|
+
import { Session } from "@thallesp/nestjs-better-auth";
|
|
60
|
+
import type { UserSession } from "./auth/auth.js";
|
|
61
|
+
|
|
62
|
+
@Controller()
|
|
63
|
+
export class AppController {
|
|
64
|
+
@Get()
|
|
65
|
+
getSession(@Session() session: UserSession): UserSession {
|
|
66
|
+
return session;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
{{/if}}
|
|
@@ -1,12 +1,31 @@
|
|
|
1
1
|
import { Module } from "@nestjs/common";
|
|
2
2
|
import { HttpModule } from "@nestjs/axios";
|
|
3
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
4
|
+
import { DbModule } from "./database/db.module.js";
|
|
5
|
+
import { env } from "./config/env.js";
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
8
|
+
import { AuthModule } from "./auth/auth.module.js";
|
|
9
|
+
{{/if}}
|
|
3
10
|
|
|
4
11
|
import { AppController } from "./app.controller.js";
|
|
5
12
|
import { AppService } from "./app.service.js";
|
|
6
13
|
|
|
7
14
|
@Module({
|
|
8
15
|
controllers: [AppController],
|
|
9
|
-
imports: [
|
|
16
|
+
imports: [
|
|
17
|
+
HttpModule{{#if (or hasDatabase hasOrm)}},
|
|
18
|
+
DbModule.forRoot({
|
|
19
|
+
{{#if hasPostgres}}postgresUrl: env.POSTGRES_URL,{{/if}}
|
|
20
|
+
{{#if hasMysql}}mysqlUrl: env.MYSQL_URL,{{/if}}
|
|
21
|
+
{{#if hasSqlite}}sqlitePath: env.SQLITE_PATH,{{/if}}
|
|
22
|
+
{{#if hasMongodb}}mongodbUrl: env.MONGODB_URL,{{/if}}
|
|
23
|
+
}),
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
26
|
+
AuthModule,
|
|
27
|
+
{{/if}}
|
|
28
|
+
],
|
|
10
29
|
providers: [AppService],
|
|
11
30
|
})
|
|
12
31
|
export class AppModule {}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
2
|
import { HttpService } from "@nestjs/axios";
|
|
3
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
4
|
+
import { DbService } from "./database/db.service.js";
|
|
5
|
+
{{/if}}
|
|
3
6
|
{{#if (eq httpProvider "fastify")}}
|
|
4
7
|
import type { FastifyRequest as Request, FastifyReply as Response } from "fastify";
|
|
5
8
|
{{else}}
|
|
@@ -8,7 +11,10 @@ import type { Request, Response } from "express";
|
|
|
8
11
|
|
|
9
12
|
@Injectable()
|
|
10
13
|
export class AppService {
|
|
11
|
-
constructor(
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly httpService: HttpService,
|
|
16
|
+
{{#if (or hasDatabase hasOrm)}}private readonly db: DbService,{{/if}}
|
|
17
|
+
) {}
|
|
12
18
|
|
|
13
19
|
getHello(): string {
|
|
14
20
|
return "Hello World!";
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { Module } from "@nestjs/common";
|
|
2
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
3
|
+
import { DbModule } from "./database/db.module.js";
|
|
4
|
+
import { env } from "./config/env.js";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
7
|
+
import { AuthModule } from "./auth/auth.module.js";
|
|
8
|
+
{{/if}}
|
|
2
9
|
|
|
3
10
|
import { AppController } from "./app.controller.js";
|
|
4
11
|
import { AppService } from "./app.service.js";
|
|
5
12
|
|
|
6
13
|
@Module({
|
|
7
14
|
controllers: [AppController],
|
|
8
|
-
imports: [
|
|
15
|
+
imports: [
|
|
16
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
17
|
+
DbModule.forRoot({
|
|
18
|
+
{{#if hasPostgres}}postgresUrl: env.POSTGRES_URL,{{/if}}
|
|
19
|
+
{{#if hasMysql}}mysqlUrl: env.MYSQL_URL,{{/if}}
|
|
20
|
+
{{#if hasSqlite}}sqlitePath: env.SQLITE_PATH,{{/if}}
|
|
21
|
+
{{#if hasMongodb}}mongodbUrl: env.MONGODB_URL,{{/if}}
|
|
22
|
+
}),
|
|
23
|
+
{{/if}}
|
|
24
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
25
|
+
AuthModule,
|
|
26
|
+
{{/if}}
|
|
27
|
+
],
|
|
9
28
|
providers: [AppService],
|
|
10
29
|
})
|
|
11
30
|
export class AppModule {}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { Injectable } from "@nestjs/common";
|
|
2
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
3
|
+
import { DbService } from "./database/db.service.js";
|
|
4
|
+
{{/if}}
|
|
2
5
|
|
|
3
6
|
@Injectable()
|
|
4
7
|
export class AppService {
|
|
8
|
+
{{#if (or hasDatabase hasOrm)}}
|
|
9
|
+
constructor(private readonly db: DbService) {}
|
|
10
|
+
|
|
11
|
+
{{/if}}
|
|
5
12
|
handlePing(): string {
|
|
6
13
|
return "pong";
|
|
7
14
|
}
|
|
@@ -33,5 +33,21 @@ export const env = createEnv({
|
|
|
33
33
|
.string()
|
|
34
34
|
.transform((val) => Number.parseInt(val, 10))
|
|
35
35
|
.default(3000),
|
|
36
|
+
{{#if hasPostgres}}
|
|
37
|
+
POSTGRES_URL: z.url(),
|
|
38
|
+
{{/if}}
|
|
39
|
+
{{#if hasMysql}}
|
|
40
|
+
MYSQL_URL: z.url(),
|
|
41
|
+
{{/if}}
|
|
42
|
+
{{#if hasSqlite}}
|
|
43
|
+
SQLITE_PATH: z.string().default("sqlite.db"),
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{#if hasMongodb}}
|
|
46
|
+
MONGODB_URL: z.url(),
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{#if (or (eq auth "better-auth") (eq auth "better-auth:stateless"))}}
|
|
49
|
+
BETTER_AUTH_SECRET: z.string().min(32),
|
|
50
|
+
BETTER_AUTH_URL: z.url(),
|
|
51
|
+
{{/if}}
|
|
36
52
|
},
|
|
37
53
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-arch/tui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Interactive terminal UI for generating NestJS projects",
|
|
6
6
|
"keywords": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"pkgroll": "^2.5.2",
|
|
49
49
|
"tsx": "^4.19.2",
|
|
50
50
|
"vitest": "^4.1.7",
|
|
51
|
-
"@nest-arch/core": "0.1.
|
|
51
|
+
"@nest-arch/core": "0.1.45",
|
|
52
52
|
"@nest-arch/env": "0.0.0",
|
|
53
53
|
"@nest-arch/shared": "0.0.0"
|
|
54
54
|
},
|
package/dist/index--w1UOCDp.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var r=(e,a)=>i(e,"name",{value:a,configurable:!0});import{e as t}from"./index-DuMVjfjC.js";import"react/jsx-runtime";import"ink";import"react";import"ink-text-input";import"@t3-oss/env-nextjs";import"zod";import"node:fs";import"node:os";import"node:path";import"node:child_process";import"node:fs/promises";import"node:util";import"handlebars";import"ts-morph";import"open";function s(e){return[`pnpm create nest-arch@latest ${e.projectName}`,`--package-manager ${e.packageManager}`,`--http-provider ${e.httpProvider}`,`--project-type ${e.projectType}`,`--architecture ${e.architecture}`,`--database ${e.database.length>0?e.database.join(" "):"none"}`,`--orm ${e.orm.length>0?e.orm.join(" "):"none"}`,`--api ${e.api.length>0?e.api.join(" "):"none"}`,`--auth ${e.auth}`,`--extras ${e.extras.length>0?e.extras.join(" "):"none"}`,`--microservices ${e.microservices.length>0?e.microservices.join(" "):"none"}`,`--addons ${e.addons.length>0?e.addons.join(" "):"none"}`,e.initGit?"--git":"--no-git"].join(" ")}r(s,"buildReproducibleCommand");function p(e){return{$schema:t.NEST_ARCH_SCHEMA_URL,addons:e.addons,api:e.api,architecture:e.architecture,auth:e.auth,createdAt:new Date().toISOString(),database:e.database,description:e.description,extras:e.extras,httpProvider:e.httpProvider,initGit:e.initGit,microservices:e.microservices,orm:e.orm,packageManager:e.packageManager,projectName:e.projectName,projectType:e.projectType,reproducibleCommand:s(e),version:t.NEST_ARCH_VERSION}}r(p,"buildMetadata");function o(e){return`${["// nest-arch","//","// Project scaffolding tool for NestJS applications","//","// This file records the options used to generate this project.","// It can be used to reproduce the exact same project setup.","// This file is safe to delete.",""].join(`
|
|
2
|
-
`)+JSON.stringify(e,null,2)}
|
|
3
|
-
`}r(o,"serializeMetadata");function n(){return`${JSON.stringify({$schema:"http://json-schema.org/draft-07/schema#",description:"NestArch project configuration metadata file schema",properties:{$schema:{type:"string"},addons:{items:{enum:["agent-skills","husky","ultracite","nestjs-zod","scalar-ui"]},type:"array"},api:{items:{enum:["rest","trpc","graphql"]},type:"array"},architecture:{enum:["nest-api","nest-gateway","nest-microservice"]},auth:{enum:["jwt","passport","better-auth","none"]},createdAt:{format:"date-time",type:"string"},database:{items:{enum:["postgresql","mysql","sqlite","mongodb"]},type:"array"},description:{type:"string"},extras:{items:{enum:["docker","health-check","rate-limiting","swagger","packages/shared"]},type:"array"},httpProvider:{enum:["express","fastify"]},initGit:{type:"boolean"},microservices:{items:{enum:["redis","mqtt","nats","rabbitmq","kafka","grpc"]},type:"array"},orm:{items:{enum:["prisma","typeorm","drizzle"]},type:"array"},packageManager:{enum:["pnpm","npm","yarn","bun"]},projectName:{type:"string"},projectType:{enum:["single","monorepo"]},reproducibleCommand:{type:"string"},version:{type:"string"}},required:["version","createdAt","reproducibleCommand","projectName","packageManager","httpProvider","projectType","architecture","database","orm","api","auth","extras","microservices","addons","initGit"],title:"NestArchMetadata",type:"object"},null,2)}
|
|
4
|
-
`}r(n,"buildSchemaContent");export{p as buildMetadata,n as buildSchemaContent,o as serializeMetadata};
|