@gaman/kame 0.1.0

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 (52) hide show
  1. package/README.md +21 -0
  2. package/dist/commands/buntest-cmd.d.ts +1 -0
  3. package/dist/commands/buntest-cmd.js +23 -0
  4. package/dist/commands/buntest-cmd.mjs +24 -0
  5. package/dist/commands/fetch.d.ts +1 -0
  6. package/dist/commands/fetch.js +46 -0
  7. package/dist/commands/fetch.mjs +46 -0
  8. package/dist/commands/gen-controller.d.ts +1 -0
  9. package/dist/commands/gen-controller.js +21 -0
  10. package/dist/commands/gen-controller.mjs +24 -0
  11. package/dist/commands/gen-exception.d.ts +1 -0
  12. package/dist/commands/gen-exception.js +23 -0
  13. package/dist/commands/gen-exception.mjs +26 -0
  14. package/dist/commands/gen-middleware.d.ts +1 -0
  15. package/dist/commands/gen-middleware.js +23 -0
  16. package/dist/commands/gen-middleware.mjs +26 -0
  17. package/dist/commands/gen-module.d.ts +1 -0
  18. package/dist/commands/gen-module.js +40 -0
  19. package/dist/commands/gen-module.mjs +47 -0
  20. package/dist/commands/gen-router.d.ts +1 -0
  21. package/dist/commands/gen-router.js +19 -0
  22. package/dist/commands/gen-router.mjs +22 -0
  23. package/dist/commands/gen-service.d.ts +1 -0
  24. package/dist/commands/gen-service.js +55 -0
  25. package/dist/commands/gen-service.mjs +58 -0
  26. package/dist/commands/registry.d.ts +26 -0
  27. package/dist/commands/registry.js +75 -0
  28. package/dist/commands/registry.mjs +51 -0
  29. package/dist/compose/index.d.ts +5 -0
  30. package/dist/compose/index.js +33 -0
  31. package/dist/compose/index.mjs +15 -0
  32. package/dist/index.d.ts +3 -0
  33. package/dist/index.js +30 -0
  34. package/dist/index.mjs +10 -0
  35. package/dist/input-parser.d.ts +5 -0
  36. package/dist/input-parser.js +40 -0
  37. package/dist/input-parser.mjs +19 -0
  38. package/dist/repl.d.ts +9 -0
  39. package/dist/repl.js +63 -0
  40. package/dist/repl.mjs +45 -0
  41. package/dist/templates/module.d.ts +6 -0
  42. package/dist/templates/module.js +123 -0
  43. package/dist/templates/module.mjs +97 -0
  44. package/dist/templates/service.d.ts +1 -0
  45. package/dist/templates/service.js +41 -0
  46. package/dist/templates/service.mjs +20 -0
  47. package/dist/utils.d.ts +10 -0
  48. package/dist/utils.js +27 -0
  49. package/dist/utils.mjs +5 -0
  50. package/package.json +41 -0
  51. package/tsconfig.dts.json +60 -0
  52. package/tsconfig.json +8 -0
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var registry_exports = {};
17
+ __export(registry_exports, {
18
+ Command: () => Command,
19
+ getAllCommands: () => getAllCommands,
20
+ getCommand: () => getCommand,
21
+ registerCommand: () => registerCommand
22
+ });
23
+ module.exports = __toCommonJS(registry_exports);
24
+ class Command {
25
+ _name;
26
+ _handler;
27
+ _description = "";
28
+ _usage = "";
29
+ _aliases = [];
30
+ constructor(name, handler) {
31
+ this._name = name, this._handler = handler;
32
+ }
33
+ description(description) {
34
+ return this._description = description, this;
35
+ }
36
+ usage(usage) {
37
+ return this._usage = usage, this;
38
+ }
39
+ aliases(aliases2) {
40
+ return this._aliases = aliases2, this;
41
+ }
42
+ getName() {
43
+ return this._name;
44
+ }
45
+ getHandler() {
46
+ return this._handler;
47
+ }
48
+ getDescription() {
49
+ return this._description;
50
+ }
51
+ getUsage() {
52
+ return this._usage;
53
+ }
54
+ getAliases() {
55
+ return this._aliases;
56
+ }
57
+ }
58
+ const commands = /* @__PURE__ */ new Map(), aliases = /* @__PURE__ */ new Map(), registerCommand = (cmd) => {
59
+ let _cmd;
60
+ cmd instanceof Command ? _cmd = cmd : _cmd = new Command(cmd.name, cmd.handler).description(cmd.description ?? "").usage(cmd.usage ?? "").aliases(cmd.aliases ?? []), commands.set(_cmd.getName(), _cmd);
61
+ for (const alias of _cmd.getAliases())
62
+ aliases.set(alias, _cmd.getName());
63
+ }, getCommand = (name) => {
64
+ const cmd = commands.get(name);
65
+ if (cmd) return cmd;
66
+ const aliasCmdName = aliases.get(name);
67
+ if (aliasCmdName) return commands.get(aliasCmdName);
68
+ }, getAllCommands = () => Array.from(commands.values());
69
+ // Annotate the CommonJS export names for ESM import in node:
70
+ 0 && (module.exports = {
71
+ Command,
72
+ getAllCommands,
73
+ getCommand,
74
+ registerCommand
75
+ });
@@ -0,0 +1,51 @@
1
+ class Command {
2
+ _name;
3
+ _handler;
4
+ _description = "";
5
+ _usage = "";
6
+ _aliases = [];
7
+ constructor(name, handler) {
8
+ this._name = name, this._handler = handler;
9
+ }
10
+ description(description) {
11
+ return this._description = description, this;
12
+ }
13
+ usage(usage) {
14
+ return this._usage = usage, this;
15
+ }
16
+ aliases(aliases2) {
17
+ return this._aliases = aliases2, this;
18
+ }
19
+ getName() {
20
+ return this._name;
21
+ }
22
+ getHandler() {
23
+ return this._handler;
24
+ }
25
+ getDescription() {
26
+ return this._description;
27
+ }
28
+ getUsage() {
29
+ return this._usage;
30
+ }
31
+ getAliases() {
32
+ return this._aliases;
33
+ }
34
+ }
35
+ const commands = /* @__PURE__ */ new Map(), aliases = /* @__PURE__ */ new Map(), registerCommand = (cmd) => {
36
+ let _cmd;
37
+ cmd instanceof Command ? _cmd = cmd : _cmd = new Command(cmd.name, cmd.handler).description(cmd.description ?? "").usage(cmd.usage ?? "").aliases(cmd.aliases ?? []), commands.set(_cmd.getName(), _cmd);
38
+ for (const alias of _cmd.getAliases())
39
+ aliases.set(alias, _cmd.getName());
40
+ }, getCommand = (name) => {
41
+ const cmd = commands.get(name);
42
+ if (cmd) return cmd;
43
+ const aliasCmdName = aliases.get(name);
44
+ if (aliasCmdName) return commands.get(aliasCmdName);
45
+ }, getAllCommands = () => Array.from(commands.values());
46
+ export {
47
+ Command,
48
+ getAllCommands,
49
+ getCommand,
50
+ registerCommand
51
+ };
@@ -0,0 +1,5 @@
1
+ import { Command, type CommandHandler } from '../commands/registry';
2
+ export interface KameConsole {
3
+ command(name: string, handler: CommandHandler): Command;
4
+ }
5
+ export declare function composeConsole(handler: (kame: KameConsole) => Promise<void> | void): void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var compose_exports = {};
17
+ __export(compose_exports, {
18
+ composeConsole: () => composeConsole
19
+ });
20
+ module.exports = __toCommonJS(compose_exports);
21
+ var import_registry = require('../commands/registry.js');
22
+ function composeConsole(handler) {
23
+ handler({
24
+ command(name, handler2) {
25
+ const cmdClass = new import_registry.Command(name, handler2);
26
+ return (0, import_registry.registerCommand)(cmdClass), cmdClass;
27
+ }
28
+ });
29
+ }
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ composeConsole
33
+ });
@@ -0,0 +1,15 @@
1
+ import {
2
+ Command,
3
+ registerCommand
4
+ } from "../commands/registry.mjs";
5
+ function composeConsole(handler) {
6
+ handler({
7
+ command(name, handler2) {
8
+ const cmdClass = new Command(name, handler2);
9
+ return registerCommand(cmdClass), cmdClass;
10
+ }
11
+ });
12
+ }
13
+ export {
14
+ composeConsole
15
+ };
@@ -0,0 +1,3 @@
1
+ export { startKame } from './repl';
2
+ import { Gaman } from 'gaman';
3
+ export declare function startKameWithGaman(gaman: Gaman): void;
package/dist/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var index_exports = {};
17
+ __export(index_exports, {
18
+ startKame: () => import_repl.startKame,
19
+ startKameWithGaman: () => startKameWithGaman
20
+ });
21
+ module.exports = __toCommonJS(index_exports);
22
+ var import_repl = require('./repl.js'), import_gaman = require('gaman'), import_repl2 = require('./repl.js');
23
+ function startKameWithGaman(gaman) {
24
+ return (0, import_repl2.startKame)();
25
+ }
26
+ // Annotate the CommonJS export names for ESM import in node:
27
+ 0 && (module.exports = {
28
+ startKame,
29
+ startKameWithGaman
30
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,10 @@
1
+ import { startKame } from "./repl.mjs";
2
+ import { Gaman } from 'gaman';
3
+ import { startKame as startKame2 } from "./repl.mjs";
4
+ function startKameWithGaman(gaman) {
5
+ return startKame2();
6
+ }
7
+ export {
8
+ startKame,
9
+ startKameWithGaman
10
+ };
@@ -0,0 +1,5 @@
1
+ export interface ParsedInput {
2
+ args: string[];
3
+ flags: Record<string, string | boolean>;
4
+ }
5
+ export declare function parseInput(argv: string[]): ParsedInput;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var input_parser_exports = {};
17
+ __export(input_parser_exports, {
18
+ parseInput: () => parseInput
19
+ });
20
+ module.exports = __toCommonJS(input_parser_exports);
21
+ function parseInput(argv) {
22
+ const args = [], flags = {};
23
+ for (let i = 0; i < argv.length; i++) {
24
+ const token = argv[i];
25
+ if (token !== void 0)
26
+ if (token.startsWith("--")) {
27
+ const key = token.slice(2), next = argv[i + 1];
28
+ !next || next.startsWith("--") || next.startsWith("-") ? flags[key] = !0 : (flags[key] = next, i++);
29
+ } else if (token.startsWith("-") && token.length === 2) {
30
+ const key = token.slice(1), next = argv[i + 1];
31
+ !next || next.startsWith("--") || next.startsWith("-") ? flags[key] = !0 : (flags[key] = next, i++);
32
+ } else
33
+ args.push(token);
34
+ }
35
+ return { args, flags };
36
+ }
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ parseInput
40
+ });
@@ -0,0 +1,19 @@
1
+ function parseInput(argv) {
2
+ const args = [], flags = {};
3
+ for (let i = 0; i < argv.length; i++) {
4
+ const token = argv[i];
5
+ if (token !== void 0)
6
+ if (token.startsWith("--")) {
7
+ const key = token.slice(2), next = argv[i + 1];
8
+ !next || next.startsWith("--") || next.startsWith("-") ? flags[key] = !0 : (flags[key] = next, i++);
9
+ } else if (token.startsWith("-") && token.length === 2) {
10
+ const key = token.slice(1), next = argv[i + 1];
11
+ !next || next.startsWith("--") || next.startsWith("-") ? flags[key] = !0 : (flags[key] = next, i++);
12
+ } else
13
+ args.push(token);
14
+ }
15
+ return { args, flags };
16
+ }
17
+ export {
18
+ parseInput
19
+ };
package/dist/repl.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import './commands/gen-module';
2
+ import './commands/gen-router';
3
+ import './commands/gen-controller';
4
+ import './commands/gen-service';
5
+ import './commands/gen-middleware';
6
+ import './commands/gen-exception';
7
+ import './commands/buntest-cmd';
8
+ import './commands/fetch';
9
+ export declare function startKame(): void;
package/dist/repl.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var repl_exports = {};
25
+ __export(repl_exports, {
26
+ startKame: () => startKame
27
+ });
28
+ module.exports = __toCommonJS(repl_exports);
29
+ var readline = __toESM(require("node:readline")), import_utils = require('gaman/utils'), import_registry = require('./commands/registry.js'), import_input_parser = require('./input-parser.js'), import_gen_module = require('./commands/gen-module.js'), import_gen_router = require('./commands/gen-router.js'), import_gen_controller = require('./commands/gen-controller.js'), import_gen_service = require('./commands/gen-service.js'), import_gen_middleware = require('./commands/gen-middleware.js'), import_gen_exception = require('./commands/gen-exception.js'), import_buntest_cmd = require('./commands/buntest-cmd.js'), import_fetch = require('./commands/fetch.js');
30
+ function startKame() {
31
+ if (!process.env.KAME_CLI) return;
32
+ import_utils.Logger.info(
33
+ `${import_utils.TextFormat.BG_CYAN} ${import_utils.TextFormat.BOLD}Kame ${import_utils.TextFormat.RESET} System active. Type "help" for commands.`
34
+ );
35
+ const rl = readline.createInterface({
36
+ input: process.stdin,
37
+ output: process.stdout,
38
+ terminal: !0
39
+ });
40
+ rl.setPrompt("> "), rl.prompt(), rl.write("help"), rl.on("line", async (line) => {
41
+ const _argv = line.trim().split(" "), commandName = _argv[0];
42
+ if (commandName === void 0) return;
43
+ const { args, flags } = (0, import_input_parser.parseInput)(_argv.slice(1));
44
+ if (commandName === "help") {
45
+ const commands = (0, import_registry.getAllCommands)();
46
+ import_utils.Logger.info(`${import_utils.TextFormat.BOLD}Available commands:${import_utils.TextFormat.RESET}`);
47
+ for (const cmd2 of commands)
48
+ import_utils.Logger.info(
49
+ `${import_utils.TextFormat.YELLOW}- ${import_utils.TextFormat.RESET}${cmd2.getUsage().padEnd(40)} ${import_utils.TextFormat.GRAY}${cmd2.getDescription()}${import_utils.TextFormat.RESET}`
50
+ );
51
+ rl.prompt();
52
+ return;
53
+ }
54
+ const cmd = (0, import_registry.getCommand)(commandName);
55
+ cmd ? await cmd.getHandler()(args, flags) : import_utils.Logger.error(
56
+ `Unknown command: "${commandName}". Run "help" to see available commands.`
57
+ ), rl.prompt();
58
+ });
59
+ }
60
+ // Annotate the CommonJS export names for ESM import in node:
61
+ 0 && (module.exports = {
62
+ startKame
63
+ });
package/dist/repl.mjs ADDED
@@ -0,0 +1,45 @@
1
+ import * as readline from "node:readline";
2
+ import { Logger, TextFormat } from 'gaman/utils';
3
+ import { getAllCommands, getCommand } from "./commands/registry.mjs";
4
+ import { parseInput } from "./input-parser.mjs";
5
+ import "./commands/gen-module";
6
+ import "./commands/gen-router";
7
+ import "./commands/gen-controller";
8
+ import "./commands/gen-service";
9
+ import "./commands/gen-middleware";
10
+ import "./commands/gen-exception";
11
+ import "./commands/buntest-cmd";
12
+ import "./commands/fetch";
13
+ function startKame() {
14
+ if (!process.env.KAME_CLI) return;
15
+ Logger.info(
16
+ `${TextFormat.BG_CYAN} ${TextFormat.BOLD}Kame ${TextFormat.RESET} System active. Type "help" for commands.`
17
+ );
18
+ const rl = readline.createInterface({
19
+ input: process.stdin,
20
+ output: process.stdout,
21
+ terminal: !0
22
+ });
23
+ rl.setPrompt("> "), rl.prompt(), rl.write("help"), rl.on("line", async (line) => {
24
+ const _argv = line.trim().split(" "), commandName = _argv[0];
25
+ if (commandName === void 0) return;
26
+ const { args, flags } = parseInput(_argv.slice(1));
27
+ if (commandName === "help") {
28
+ const commands = getAllCommands();
29
+ Logger.info(`${TextFormat.BOLD}Available commands:${TextFormat.RESET}`);
30
+ for (const cmd2 of commands)
31
+ Logger.info(
32
+ `${TextFormat.YELLOW}- ${TextFormat.RESET}${cmd2.getUsage().padEnd(40)} ${TextFormat.GRAY}${cmd2.getDescription()}${TextFormat.RESET}`
33
+ );
34
+ rl.prompt();
35
+ return;
36
+ }
37
+ const cmd = getCommand(commandName);
38
+ cmd ? await cmd.getHandler()(args, flags) : Logger.error(
39
+ `Unknown command: "${commandName}". Run "help" to see available commands.`
40
+ ), rl.prompt();
41
+ });
42
+ }
43
+ export {
44
+ startKame
45
+ };
@@ -0,0 +1,6 @@
1
+ export declare const serviceTemplate: (name: string) => string;
2
+ export declare const controllerTemplate: (name: string) => string;
3
+ export declare const routerTemplate: (name: string) => string;
4
+ export declare const routerBlankTemplate: () => string;
5
+ export declare const middlewareTemplate: () => string;
6
+ export declare const exceptionTemplate: () => string;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
16
+ var module_exports = {};
17
+ __export(module_exports, {
18
+ controllerTemplate: () => controllerTemplate,
19
+ exceptionTemplate: () => exceptionTemplate,
20
+ middlewareTemplate: () => middlewareTemplate,
21
+ routerBlankTemplate: () => routerBlankTemplate,
22
+ routerTemplate: () => routerTemplate,
23
+ serviceTemplate: () => serviceTemplate
24
+ });
25
+ module.exports = __toCommonJS(module_exports);
26
+ var import_utils = require('../utils.js');
27
+ const serviceTemplate = (name) => {
28
+ const nameCapitalized = (0, import_utils.capitalize)(name);
29
+ return `
30
+ import { composeService } from './../compose/index.ts';
31
+ import type { RT } from './../types.ts';
32
+
33
+ export const ${nameCapitalized}Service = composeService(() => {
34
+
35
+ // TODO: Implement your service logic here
36
+
37
+ return {
38
+ WelcomeMessage() {
39
+ return 'Welcome to ${nameCapitalized} Service!';
40
+ },
41
+ };
42
+ });
43
+
44
+ export type ${nameCapitalized}Service = RT<typeof ${nameCapitalized}Service>;
45
+ `.trim();
46
+ }, controllerTemplate = (name) => {
47
+ const nameCapitalized = (0, import_utils.capitalize)(name);
48
+ return `
49
+ import { composeController } from './../compose/index.ts';
50
+ import { Res } from './../responder.ts';
51
+ import { ${nameCapitalized}Service } from '../services/${nameCapitalized}Service';
52
+
53
+ export type Deps = {
54
+ ${(0, import_utils.toCamelCase)(name)}Service: ${nameCapitalized}Service;
55
+ }
56
+
57
+ export default composeController(({ ${(0, import_utils.toCamelCase)(name)}Service }: Deps) => {
58
+
59
+ // TODO: Implement your controller logic here
60
+
61
+ return {
62
+ index(ctx) {
63
+ return Res.json({
64
+ message: ${(0, import_utils.toCamelCase)(name)}Service.WelcomeMessage(),
65
+ });
66
+ },
67
+ };
68
+ });
69
+ `.trim();
70
+ }, routerTemplate = (name) => {
71
+ const nameCapitalized = (0, import_utils.capitalize)(name), camelCaseName = (0, import_utils.toCamelCase)(name);
72
+ return `
73
+ import { composeRouter } from './../compose/index.ts';
74
+ import ${nameCapitalized}Controller from './controllers/${nameCapitalized}Controller';
75
+ import { ${nameCapitalized}Service } from './services/${nameCapitalized}Service';
76
+
77
+ export default composeRouter((r) => {
78
+ r.mountService({
79
+ ${camelCaseName}Service: ${nameCapitalized}Service(),
80
+ });
81
+
82
+ r.get('/', [${nameCapitalized}Controller, 'index']);
83
+ });
84
+ `.trim();
85
+ }, routerBlankTemplate = () => `
86
+ import { composeRouter } from './../compose/index.ts';
87
+
88
+ export default composeRouter((r) => {
89
+ r.mountService({
90
+
91
+ });
92
+
93
+ // TODO: Implement your routers
94
+ });
95
+ `.trim(), middlewareTemplate = () => `
96
+ import { composeMiddleware } from './../compose/index.ts';
97
+
98
+ export default composeMiddleware(async (ctx, next) => {
99
+
100
+ // TODO: Implement your middleware logic here
101
+
102
+ return next();
103
+ });
104
+ `.trim(), exceptionTemplate = () => `
105
+ import { composeException } from './../compose/index.ts';
106
+ import { Res } from './../responder.ts';
107
+
108
+ export default composeException((err, ctx) => {
109
+
110
+ // TODO: Implement your exception handler logic here
111
+
112
+ return Res.internalServerError();
113
+ });
114
+ `.trim();
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ controllerTemplate,
118
+ exceptionTemplate,
119
+ middlewareTemplate,
120
+ routerBlankTemplate,
121
+ routerTemplate,
122
+ serviceTemplate
123
+ });
@@ -0,0 +1,97 @@
1
+ import { capitalize, toCamelCase } from "../utils.mjs";
2
+ const serviceTemplate = (name) => {
3
+ const nameCapitalized = capitalize(name);
4
+ return `
5
+ import { composeService } from 'gaman/compose';
6
+ import type { RT } from 'gaman/types';
7
+
8
+ export const ${nameCapitalized}Service = composeService(() => {
9
+
10
+ // TODO: Implement your service logic here
11
+
12
+ return {
13
+ WelcomeMessage() {
14
+ return 'Welcome to ${nameCapitalized} Service!';
15
+ },
16
+ };
17
+ });
18
+
19
+ export type ${nameCapitalized}Service = RT<typeof ${nameCapitalized}Service>;
20
+ `.trim();
21
+ }, controllerTemplate = (name) => {
22
+ const nameCapitalized = capitalize(name);
23
+ return `
24
+ import { composeController } from 'gaman/compose';
25
+ import { Res } from 'gaman/responder';
26
+ import { ${nameCapitalized}Service } from '../services/${nameCapitalized}Service.mjs';
27
+
28
+ export type Deps = {
29
+ ${toCamelCase(name)}Service: ${nameCapitalized}Service;
30
+ }
31
+
32
+ export default composeController(({ ${toCamelCase(name)}Service }: Deps) => {
33
+
34
+ // TODO: Implement your controller logic here
35
+
36
+ return {
37
+ index(ctx) {
38
+ return Res.json({
39
+ message: ${toCamelCase(name)}Service.WelcomeMessage(),
40
+ });
41
+ },
42
+ };
43
+ });
44
+ `.trim();
45
+ }, routerTemplate = (name) => {
46
+ const nameCapitalized = capitalize(name), camelCaseName = toCamelCase(name);
47
+ return `
48
+ import { composeRouter } from 'gaman/compose';
49
+ import ${nameCapitalized}Controller from './controllers/${nameCapitalized}Controller.mjs';
50
+ import { ${nameCapitalized}Service } from './services/${nameCapitalized}Service.mjs';
51
+
52
+ export default composeRouter((r) => {
53
+ r.mountService({
54
+ ${camelCaseName}Service: ${nameCapitalized}Service(),
55
+ });
56
+
57
+ r.get('/', [${nameCapitalized}Controller, 'index']);
58
+ });
59
+ `.trim();
60
+ }, routerBlankTemplate = () => `
61
+ import { composeRouter } from 'gaman/compose';
62
+
63
+ export default composeRouter((r) => {
64
+ r.mountService({
65
+
66
+ });
67
+
68
+ // TODO: Implement your routers
69
+ });
70
+ `.trim(), middlewareTemplate = () => `
71
+ import { composeMiddleware } from 'gaman/compose';
72
+
73
+ export default composeMiddleware(async (ctx, next) => {
74
+
75
+ // TODO: Implement your middleware logic here
76
+
77
+ return next();
78
+ });
79
+ `.trim(), exceptionTemplate = () => `
80
+ import { composeException } from 'gaman/compose';
81
+ import { Res } from 'gaman/responder';
82
+
83
+ export default composeException((err, ctx) => {
84
+
85
+ // TODO: Implement your exception handler logic here
86
+
87
+ return Res.internalServerError();
88
+ });
89
+ `.trim();
90
+ export {
91
+ controllerTemplate,
92
+ exceptionTemplate,
93
+ middlewareTemplate,
94
+ routerBlankTemplate,
95
+ routerTemplate,
96
+ serviceTemplate
97
+ };
@@ -0,0 +1 @@
1
+ export declare const standaloneServiceTemplate: (name: string) => string;