@igniter-js/cli 0.2.72 → 0.4.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 +213 -27
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +3556 -19993
- package/dist/index.mjs.map +1 -1
- package/package.json +38 -53
- package/templates/add-ons/auth/better-auth/auth.hbs +37 -0
- package/templates/add-ons/bots/nextjs/route-handler.hbs +10 -0
- package/templates/add-ons/bots/sample-bot.hbs +26 -0
- package/templates/add-ons/bots/tanstack-start/route-handler.hbs +15 -0
- package/templates/add-ons/database/prisma/lib.hbs +11 -0
- package/templates/add-ons/database/prisma/prisma.config.hbs +13 -0
- package/templates/add-ons/database/prisma/schema.hbs +15 -0
- package/templates/add-ons/jobs/jobs.ts.hbs +32 -0
- package/templates/add-ons/jobs/redis.ts.hbs +13 -0
- package/templates/add-ons/jobs/store.ts.hbs +12 -0
- package/templates/add-ons/logging/logger.ts.hbs +14 -0
- package/templates/add-ons/mcp/mcp.ts.hbs +21 -0
- package/templates/add-ons/mcp/nextjs/route-handler.hbs +11 -0
- package/templates/add-ons/mcp/tanstack-start/route-handler.hbs +19 -0
- package/templates/add-ons/store/redis.ts.hbs +13 -0
- package/templates/add-ons/store/store.ts.hbs +12 -0
- package/templates/add-ons/telemetry/telemetry.ts.hbs +20 -0
- package/templates/generate/feature/empty.controller.hbs +20 -0
- package/templates/generate/feature/empty.interfaces.hbs +5 -0
- package/templates/generate/feature/procedure.hbs +23 -0
- package/templates/generate/feature/schema.controller.hbs +73 -0
- package/templates/generate/feature/schema.interfaces.hbs +23 -0
- package/templates/generate/feature/schema.procedure.hbs +23 -0
- package/templates/scaffold/example-feature/example.controller.hbs +23 -0
- package/templates/scaffold/example-feature/example.interfaces.hbs +14 -0
- package/templates/scaffold/example-feature/example.procedure.hbs +28 -0
- package/templates/scaffold/igniter.schema.hbs +21 -0
- package/templates/starters/igniter.client.hbs +52 -0
- package/templates/starters/igniter.context.hbs +10 -0
- package/templates/starters/igniter.hbs +43 -0
- package/templates/starters/igniter.router.hbs +14 -0
- package/templates/starters/nextjs/route-handler.hbs +8 -0
- package/templates/starters/nextjs/tsconfig.hbs +35 -0
- package/templates/starters/open-api.hbs +45 -0
- package/templates/starters/tanstack-start/route-handler.hbs +13 -0
- package/templates/starters/tanstack-start/tsconfig.hbs +15 -0
- package/bin/igniter +0 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -20309
- package/dist/index.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,68 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igniter-js/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"main": "dist/index.js",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "The next-generation command-line interface for Igniter.js",
|
|
6
5
|
"bin": {
|
|
7
|
-
"igniter": "./
|
|
6
|
+
"igniter": "./dist/index.mjs"
|
|
8
7
|
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"bin"
|
|
12
|
-
],
|
|
13
8
|
"scripts": {
|
|
14
|
-
"build": "tsup",
|
|
15
9
|
"dev": "tsup --watch",
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"lint:fix": "eslint src --ext .ts --fix",
|
|
20
|
-
"typecheck": "tsc --noEmit",
|
|
21
|
-
"clean": "rm -rf dist"
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"start": "node dist/index.js",
|
|
12
|
+
"typecheck": "tsc --noEmit"
|
|
22
13
|
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"igniter",
|
|
25
|
-
"cli",
|
|
26
|
-
"typescript",
|
|
27
|
-
"code-generation",
|
|
28
|
-
"api"
|
|
29
|
-
],
|
|
30
|
-
"author": "Felipe Barcelos <felipebarcelospro@gmail.com>",
|
|
31
|
-
"license": "MIT",
|
|
32
14
|
"dependencies": {
|
|
33
|
-
"@
|
|
15
|
+
"@clack/prompts": "^0.7.0",
|
|
34
16
|
"@mrleebo/prisma-ast": "^0.5.0",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"tsx": "^4.7.0"
|
|
17
|
+
"chokidar": "^4.0.3",
|
|
18
|
+
"commander": "^12.0.0",
|
|
19
|
+
"esbuild": "^0.25.12",
|
|
20
|
+
"esbuild-node-externals": "^1.20.1",
|
|
21
|
+
"execa": "^9.6.0",
|
|
22
|
+
"handlebars": "^4.7.8",
|
|
23
|
+
"ink": "^6.5.0",
|
|
24
|
+
"js-yaml": "^4.1.0",
|
|
25
|
+
"picocolors": "^1.0.0",
|
|
26
|
+
"react": "^19.2.0",
|
|
27
|
+
"webpack-node-externals": "^3.0.0",
|
|
28
|
+
"zod": "^3.22.4",
|
|
29
|
+
"zod-to-json-schema": "^3.24.6"
|
|
49
30
|
},
|
|
50
31
|
"devDependencies": {
|
|
51
32
|
"@igniter-js/eslint-config": "*",
|
|
52
33
|
"@igniter-js/typescript-config": "*",
|
|
53
|
-
"@types/
|
|
54
|
-
"@types/
|
|
55
|
-
"@types/
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"typescript": "^5.6.3",
|
|
60
|
-
"vitest": "^2.1.4"
|
|
61
|
-
},
|
|
62
|
-
"peerDependencies": {
|
|
63
|
-
"typescript": "^5.0.0"
|
|
34
|
+
"@types/handlebars": "^4.1.0",
|
|
35
|
+
"@types/js-yaml": "^4.0.9",
|
|
36
|
+
"@types/node": "^20.11.24",
|
|
37
|
+
"@types/react": "^19.2.3",
|
|
38
|
+
"tsup": "^8.0.2",
|
|
39
|
+
"typescript": "^5.3.3"
|
|
64
40
|
},
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
41
|
+
"keywords": [
|
|
42
|
+
"igniterjs",
|
|
43
|
+
"cli",
|
|
44
|
+
"scaffolding",
|
|
45
|
+
"codegeneration"
|
|
46
|
+
],
|
|
47
|
+
"author": "Felipe Barcelos",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"templates"
|
|
52
|
+
]
|
|
68
53
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { betterAuth } from "better-auth"
|
|
2
|
+
import { database } from "@/lib/database"
|
|
3
|
+
{{#if (eq addOnOptions.database.orm "prisma")}}
|
|
4
|
+
import { prismaAdapter } from "better-auth/adapters/prisma";
|
|
5
|
+
{{/if}}
|
|
6
|
+
{{#if (eq addOnOptions.database.orm "drizzle")}}
|
|
7
|
+
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{{generatePluginImports addOnOptions.auth.plugins}}}
|
|
10
|
+
|
|
11
|
+
export const auth = betterAuth({
|
|
12
|
+
appName: process.env.IGNITER_APP_NAME,
|
|
13
|
+
appSecret: process.env.IGNITER_APP_SECRET,
|
|
14
|
+
baseURL: process.env.IGNITER_API_URL,
|
|
15
|
+
basePath: process.env.IGNITER_API_BASE_PATH,
|
|
16
|
+
|
|
17
|
+
{{#if addOnOptions.database.orm}}
|
|
18
|
+
// enable database adapter
|
|
19
|
+
database: {{#if (eq addOnOptions.database.orm "prisma")}}prismaAdapter{{/if}}{{#if (eq addOnOptions.database.orm "drizzle")}}drizzleAdapter{{/if}}(database, {
|
|
20
|
+
provider: "{{addOnOptions.database.provider}}", // or "mysql", "postgresql", ...etc
|
|
21
|
+
}),
|
|
22
|
+
{{/if}}
|
|
23
|
+
|
|
24
|
+
// enable email and password authentication
|
|
25
|
+
emailAndPassword: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
{{#if addOnOptions.auth.plugins}}
|
|
30
|
+
// enable selected authentication plugins
|
|
31
|
+
plugins: [
|
|
32
|
+
{{#each addOnOptions.auth.plugins}}
|
|
33
|
+
{{camelCase this}}(){{#unless @last}},{{/unless}}
|
|
34
|
+
{{/each}}
|
|
35
|
+
]
|
|
36
|
+
{{/if}}
|
|
37
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { sampleBot } from '@/bots/sample-bot';
|
|
2
|
+
import { nextRouteHandlerAdapter } from '@igniter-js/bot/adapters';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description Next.js route handler for Igniter.js Bots
|
|
6
|
+
* @see https://igniterjs.com/docs/bots
|
|
7
|
+
*/
|
|
8
|
+
export const { GET, POST } = nextRouteHandlerAdapter({
|
|
9
|
+
'sample-bot': sampleBot,
|
|
10
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IgniterBot } from '@igniter-js/bot'
|
|
2
|
+
import { telegram } from '@igniter-js/bot/adapters'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create the bot using IgniterBot.
|
|
6
|
+
* This provides full type inference and a fluent API.
|
|
7
|
+
*
|
|
8
|
+
* @see https://igniterjs.com/docs/bots
|
|
9
|
+
*/
|
|
10
|
+
export const sampleBot = IgniterBot
|
|
11
|
+
.create()
|
|
12
|
+
.withHandle('@my-bot') // ← Your bot's handle (ID and name auto-derived)
|
|
13
|
+
.addAdapter('telegram', telegram())
|
|
14
|
+
.addCommand('start', {
|
|
15
|
+
name: 'start',
|
|
16
|
+
aliases: ['hello'],
|
|
17
|
+
description: 'Start the bot',
|
|
18
|
+
help: 'Use /start to begin',
|
|
19
|
+
async handle(ctx) {
|
|
20
|
+
await ctx.reply('👋 Welcome! I am your bot.')
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
.onMessage(async (ctx) => {
|
|
24
|
+
await ctx.reply('👋 Welcome! I am your bot.')
|
|
25
|
+
})
|
|
26
|
+
.build()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router'
|
|
2
|
+
import { tanstackStartRouteHandlerAdapter } from '@igniter-js/bot/adapters'
|
|
3
|
+
import { sampleBot } from '@/bots/sample-bot'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @description TanStack Start route handler for Igniter.js Bots
|
|
7
|
+
* @see https://igniterjs.com/docs/bots
|
|
8
|
+
*/
|
|
9
|
+
export const Route = createFileRoute('/api/bots/$provider/$botId')({
|
|
10
|
+
server: {
|
|
11
|
+
handlers: tanstackStartRouteHandlerAdapter({
|
|
12
|
+
'sample-bot': sampleBot,
|
|
13
|
+
}),
|
|
14
|
+
},
|
|
15
|
+
})
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PrismaClient } from '../../prisma/client/client'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Prisma client instance for database operations.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides type-safe database access with Prisma ORM.
|
|
8
|
+
*
|
|
9
|
+
* @see https://www.prisma.io/docs/concepts/components/prisma-client
|
|
10
|
+
*/
|
|
11
|
+
export const database = new PrismaClient()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineConfig, env } from "prisma/config";
|
|
2
|
+
import 'dotenv/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
schema: "prisma/schema.prisma",
|
|
6
|
+
migrations: {
|
|
7
|
+
path: "prisma/migrations",
|
|
8
|
+
},
|
|
9
|
+
engine: "classic",
|
|
10
|
+
datasource: {
|
|
11
|
+
url: env("DATABASE_URL"),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
|
|
5
|
+
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
|
|
6
|
+
|
|
7
|
+
generator client {
|
|
8
|
+
provider = "prisma-client"
|
|
9
|
+
output = "../prisma/client"
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
datasource db {
|
|
13
|
+
provider = "postgresql"
|
|
14
|
+
url = env("DATABASE_URL")
|
|
15
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { store } from './store'
|
|
2
|
+
import { createBullMQAdapter } from '@igniter-js/adapter-bullmq'
|
|
3
|
+
import { z } from 'zod'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Job queue adapter for background processing.
|
|
7
|
+
*
|
|
8
|
+
* @see https://igniterjs.com/docs/jobs
|
|
9
|
+
*/
|
|
10
|
+
export const jobs = createBullMQAdapter({
|
|
11
|
+
store,
|
|
12
|
+
autoStartWorker: {
|
|
13
|
+
concurrency: 1,
|
|
14
|
+
queues: ['*']
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
export const REGISTERED_JOBS = jobs.merge({
|
|
19
|
+
system: jobs.router({
|
|
20
|
+
jobs: {
|
|
21
|
+
sampleJob: jobs.register({
|
|
22
|
+
name: 'sampleJob',
|
|
23
|
+
input: z.object({
|
|
24
|
+
message: z.string()
|
|
25
|
+
}),
|
|
26
|
+
handler: async ({ input }) => {
|
|
27
|
+
console.log(input.message)
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Redis } from 'ioredis'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Redis client instance for caching, session storage, and pub/sub.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Used for caching, session management, and real-time messaging.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/luin/ioredis
|
|
10
|
+
*/
|
|
11
|
+
export const redis = new Redis(process.env.REDIS_URL!, {
|
|
12
|
+
maxRetriesPerRequest: null,
|
|
13
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRedisStoreAdapter } from '@igniter-js/adapter-redis'
|
|
2
|
+
import { redis } from './redis'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Store adapter for data persistence.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Provides a unified interface for data storage operations using Redis.
|
|
9
|
+
*
|
|
10
|
+
* @see https://igniterjs.com/docs/store
|
|
11
|
+
*/
|
|
12
|
+
export const store = createRedisStoreAdapter(redis)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createConsoleLogger, IgniterLogLevel } from '@igniter-js/core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Logger instance for application logging.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Provides structured logging with configurable log levels.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/felipebarcelospro/igniter-js/tree/main/packages/core
|
|
10
|
+
*/
|
|
11
|
+
export const logger = createConsoleLogger({
|
|
12
|
+
level: IgniterLogLevel.INFO,
|
|
13
|
+
showTimestamp: true,
|
|
14
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IgniterMcpServer } from '@igniter-js/adapter-mcp-server';
|
|
2
|
+
import { AppRouter } from '@/igniter.router';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Create the MCP server using the builder pattern.
|
|
6
|
+
* This provides full type inference and a fluent API.
|
|
7
|
+
*
|
|
8
|
+
* @see https://igniterjs.com/docs/mcp-server
|
|
9
|
+
*/
|
|
10
|
+
export const mcpServer = IgniterMcpServer
|
|
11
|
+
.create()
|
|
12
|
+
.router(AppRouter)
|
|
13
|
+
.withServerInfo({
|
|
14
|
+
name: '{{capitalizeSlug projectName}} MCP Server',
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
})
|
|
17
|
+
.withAdapter({
|
|
18
|
+
redisUrl: process.env.REDIS_URL!,
|
|
19
|
+
basePath: process.env.IGNITER_MCP_SERVER_BASE_PATH || '/mcp'
|
|
20
|
+
})
|
|
21
|
+
.build();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { mcpServer } from '@/igniter.mcp';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Export the handler for Next.js to handle both GET and POST requests,
|
|
5
|
+
* which are used by different MCP transport methods (like SSE and WebSockets).
|
|
6
|
+
*/
|
|
7
|
+
export const GET = mcpServer.handler;
|
|
8
|
+
export const POST = mcpServer.handler;
|
|
9
|
+
export const PUT = mcpServer.handler;
|
|
10
|
+
export const DELETE = mcpServer.handler;
|
|
11
|
+
export const PATCH = mcpServer.handler;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createFileRoute } from '@tanstack/react-router';
|
|
2
|
+
import { mcpServer } from '@/igniter.mcp';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description TanStack Start route handler adapter for Igniter.js
|
|
6
|
+
* @see https://igniterjs.com/docs/core/tanstack-start
|
|
7
|
+
*/
|
|
8
|
+
export const Route = createFileRoute('/mcp/$')({
|
|
9
|
+
server: {
|
|
10
|
+
handlers: {
|
|
11
|
+
GET: ({ request }) => mcpServer.handler(request),
|
|
12
|
+
POST: ({ request }) => mcpServer.handler(request),
|
|
13
|
+
PUT: ({ request }) => mcpServer.handler(request),
|
|
14
|
+
DELETE: ({ request }) => mcpServer.handler(request),
|
|
15
|
+
PATCH: ({ request }) => mcpServer.handler(request),
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Redis } from 'ioredis'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Redis client instance for caching, session storage, and pub/sub.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Used for caching, session management, and real-time messaging.
|
|
8
|
+
*
|
|
9
|
+
* @see https://github.com/luin/ioredis
|
|
10
|
+
*/
|
|
11
|
+
export const redis = new Redis(process.env.REDIS_URL!, {
|
|
12
|
+
maxRetriesPerRequest: null,
|
|
13
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createRedisStoreAdapter } from '@igniter-js/adapter-redis'
|
|
2
|
+
import { redis } from './redis'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Store adapter for data persistence.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Provides a unified interface for data storage operations using Redis.
|
|
9
|
+
*
|
|
10
|
+
* @see https://igniterjs.com/docs/store
|
|
11
|
+
*/
|
|
12
|
+
export const store = createRedisStoreAdapter(redis)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createConsoleTelemetryAdapter } from '@igniter-js/core/adapters'
|
|
2
|
+
import { store } from './store'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Telemetry service for tracking requests and errors.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* Provides telemetry tracking with configurable options.
|
|
9
|
+
*
|
|
10
|
+
* @see https://github.com/felipebarcelospro/igniter-js/tree/main/packages/core
|
|
11
|
+
*/
|
|
12
|
+
export const telemetry = createConsoleTelemetryAdapter({
|
|
13
|
+
serviceName: '{{capitalizeSlug projectName}}',
|
|
14
|
+
enableEvents: process.env.IGNITER_TELEMETRY_ENABLE_EVENTS === 'true',
|
|
15
|
+
enableMetrics: process.env.IGNITER_TELEMETRY_ENABLE_METRICS === 'true',
|
|
16
|
+
enableTracing: process.env.IGNITER_TELEMETRY_ENABLE_TRACING === 'true',
|
|
17
|
+
}, {
|
|
18
|
+
enableCliIntegration: process.env.IGNITER_TELEMETRY_ENABLE_CLI_INTEGRATION === 'true',
|
|
19
|
+
store: store
|
|
20
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
@generated by @igniter-js/new-cli
|
|
3
|
+
@description Basic controller scaffold for a new feature
|
|
4
|
+
--}}
|
|
5
|
+
import { igniter } from '@/igniter'
|
|
6
|
+
|
|
7
|
+
export const {{controllerExport}} = igniter.controller({
|
|
8
|
+
name: '{{controllerDisplayName}}',
|
|
9
|
+
path: '/{{controllerRoute}}',
|
|
10
|
+
actions: {
|
|
11
|
+
hello: igniter.query({
|
|
12
|
+
name: 'Hello',
|
|
13
|
+
description: 'Demonstration endpoint',
|
|
14
|
+
path: '/hello',
|
|
15
|
+
handler: async ({ response }) => {
|
|
16
|
+
return response.success({ message: 'Hello from {{controllerDisplayName}}!' })
|
|
17
|
+
},
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
@generated by @igniter-js/new-cli
|
|
3
|
+
@description Basic procedure scaffold for the {{featureName}} feature
|
|
4
|
+
--}}
|
|
5
|
+
import { igniter } from '@/igniter'
|
|
6
|
+
|
|
7
|
+
export const {{procedureExport}} = igniter.procedure({
|
|
8
|
+
name: '{{procedureDisplayName}}',
|
|
9
|
+
handler: async () => {
|
|
10
|
+
return {
|
|
11
|
+
{{procedureExport}}: {
|
|
12
|
+
services: {
|
|
13
|
+
example: () => {
|
|
14
|
+
return {
|
|
15
|
+
message: 'Hello from {{procedureDisplayName}}!',
|
|
16
|
+
timestamp: new Date().toISOString(),
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
@generated by @igniter-js/new-cli
|
|
3
|
+
@description CRUD controller generated from the {{modelName}} Prisma model
|
|
4
|
+
--}}
|
|
5
|
+
import { igniter } from '@/igniter'
|
|
6
|
+
import { {{procedureExport}} } from '../procedures/{{featureName}}.procedure'
|
|
7
|
+
import { Create{{modelName}}InputSchema, Update{{modelName}}InputSchema } from '../{{featureName}}.interfaces'
|
|
8
|
+
|
|
9
|
+
export const {{controllerExport}} = igniter.controller({
|
|
10
|
+
name: '{{controllerDisplayName}}',
|
|
11
|
+
description: 'REST endpoints for {{modelNamePlural}}',
|
|
12
|
+
path: '/{{resourcePath}}',
|
|
13
|
+
actions: {
|
|
14
|
+
list: igniter.query({
|
|
15
|
+
name: 'List',
|
|
16
|
+
description: 'List {{modelNamePlural}}',
|
|
17
|
+
path: '/',
|
|
18
|
+
use: [{{procedureExport}}()],
|
|
19
|
+
handler: async ({ context, response }) => {
|
|
20
|
+
const records = await context.{{procedureExport}}.services.findAll()
|
|
21
|
+
return response.success(records)
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
getById: igniter.query({
|
|
25
|
+
name: 'Get By Id',
|
|
26
|
+
description: 'Get {{modelName}} by id',
|
|
27
|
+
path: '/:id' as const,
|
|
28
|
+
use: [{{procedureExport}}()],
|
|
29
|
+
handler: async ({ request, context, response }) => {
|
|
30
|
+
const record = await context.{{procedureExport}}.services.findById(request.params.id)
|
|
31
|
+
if (!record) {
|
|
32
|
+
return response.notFound('{{modelName}} not found')
|
|
33
|
+
}
|
|
34
|
+
return response.success(record)
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
create: igniter.mutation({
|
|
38
|
+
name: 'Create',
|
|
39
|
+
description: 'Create {{modelName}}',
|
|
40
|
+
path: '/',
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: Create{{modelName}}InputSchema,
|
|
43
|
+
use: [{{procedureExport}}()],
|
|
44
|
+
handler: async ({ request, context, response }) => {
|
|
45
|
+
const created = await context.{{procedureExport}}.services.create(request.body)
|
|
46
|
+
return response.created(created)
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
update: igniter.mutation({
|
|
50
|
+
name: 'Update',
|
|
51
|
+
description: 'Update {{modelName}}',
|
|
52
|
+
path: '/:id' as const,
|
|
53
|
+
method: 'PUT',
|
|
54
|
+
body: Update{{modelName}}InputSchema,
|
|
55
|
+
use: [{{procedureExport}}()],
|
|
56
|
+
handler: async ({ request, context, response }) => {
|
|
57
|
+
const updated = await context.{{procedureExport}}.services.update(request.params.id, request.body)
|
|
58
|
+
return response.success(updated)
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
delete: igniter.mutation({
|
|
62
|
+
name: 'Delete',
|
|
63
|
+
description: 'Delete {{modelName}}',
|
|
64
|
+
path: '/:id' as const,
|
|
65
|
+
method: 'DELETE',
|
|
66
|
+
use: [{{procedureExport}}()],
|
|
67
|
+
handler: async ({ request, context, response }) => {
|
|
68
|
+
await context.{{procedureExport}}.services.delete(request.params.id)
|
|
69
|
+
return response.noContent()
|
|
70
|
+
},
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
@generated by @igniter-js/new-cli
|
|
3
|
+
@description Zod schemas and TypeScript types generated from the {{modelName}} Prisma model
|
|
4
|
+
--}}
|
|
5
|
+
import { z } from 'zod'
|
|
6
|
+
|
|
7
|
+
export const {{modelName}}Schema = z.object({
|
|
8
|
+
{{#each fields}}
|
|
9
|
+
{{name}}: {{zodType}}{{#unless @last}},{{/unless}}
|
|
10
|
+
{{/each}}
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const Create{{modelName}}InputSchema = {{modelName}}Schema.omit({
|
|
14
|
+
{{#each createOmitFields}}
|
|
15
|
+
{{this}}: true{{#unless @last}},{{/unless}}
|
|
16
|
+
{{/each}}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export const Update{{modelName}}InputSchema = Create{{modelName}}InputSchema.partial()
|
|
20
|
+
|
|
21
|
+
export type {{modelName}} = z.infer<typeof {{modelName}}Schema>
|
|
22
|
+
export type Create{{modelName}}Input = z.infer<typeof Create{{modelName}}InputSchema>
|
|
23
|
+
export type Update{{modelName}}Input = z.infer<typeof Update{{modelName}}InputSchema>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{{!--
|
|
2
|
+
@generated by @igniter-js/new-cli
|
|
3
|
+
@description CRUD procedure generated from the {{modelName}} Prisma model
|
|
4
|
+
--}}
|
|
5
|
+
import { igniter } from '@/igniter'
|
|
6
|
+
import type { Create{{modelName}}Input, Update{{modelName}}Input } from '../{{featureName}}.interfaces'
|
|
7
|
+
|
|
8
|
+
export const {{procedureExport}} = igniter.procedure({
|
|
9
|
+
name: '{{procedureDisplayName}}',
|
|
10
|
+
handler: async (_options, { context }) => {
|
|
11
|
+
return {
|
|
12
|
+
{{procedureExport}}: {
|
|
13
|
+
services: {
|
|
14
|
+
findAll: () => context.services.database.{{prismaDelegate}}.findMany(),
|
|
15
|
+
findById: (id: {{idType}}) => context.services.database.{{prismaDelegate}}.findUnique({ where: { id } }),
|
|
16
|
+
create: (data: Create{{modelName}}Input) => context.services.database.{{prismaDelegate}}.create({ data }),
|
|
17
|
+
update: (id: {{idType}}, data: Update{{modelName}}Input) => context.services.database.{{prismaDelegate}}.update({ where: { id }, data }),
|
|
18
|
+
delete: (id: {{idType}}) => context.services.database.{{prismaDelegate}}.delete({ where: { id } }),
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { igniter } from '@/igniter'
|
|
2
|
+
import { ExampleProcedure } from '../procedures/example.procedure'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @description Example controller demonstrating Igniter.js features
|
|
6
|
+
* @see https://igniterjs.com/docs/core/controllers
|
|
7
|
+
*/
|
|
8
|
+
export const ExampleController = igniter.controller({
|
|
9
|
+
name: 'Example',
|
|
10
|
+
path: '/example',
|
|
11
|
+
actions: {
|
|
12
|
+
// Health check action
|
|
13
|
+
health: igniter.query({
|
|
14
|
+
name: 'health',
|
|
15
|
+
description: 'Health check',
|
|
16
|
+
path: '/',
|
|
17
|
+
use: [ExampleProcedure()],
|
|
18
|
+
handler: async ({ request, response, context }) => {
|
|
19
|
+
return response.success(context.example.hello())
|
|
20
|
+
}
|
|
21
|
+
}),
|
|
22
|
+
}
|
|
23
|
+
})
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example feature interfaces and types
|
|
3
|
+
* @description Define your feature's types here
|
|
4
|
+
*/
|
|
5
|
+
export interface ExampleHelloResponse {
|
|
6
|
+
status: string
|
|
7
|
+
timestamp: string
|
|
8
|
+
features: {
|
|
9
|
+
store: boolean
|
|
10
|
+
jobs: boolean
|
|
11
|
+
logging: boolean
|
|
12
|
+
telemetry: boolean
|
|
13
|
+
}
|
|
14
|
+
}
|