@gasket/preset-api 0.0.0-canary-20250922152503

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/EXAMPLES.md ADDED
@@ -0,0 +1,210 @@
1
+ # @gasket/preset-api Examples
2
+
3
+ This document provides examples of using the `@gasket/preset-api` preset and understanding its hooks.
4
+
5
+ ## Using the Preset
6
+
7
+ ### Creating a new API project
8
+
9
+ ```bash
10
+ # Create a new API project using the preset
11
+ npx create-gasket-app@latest my-api --presets @gasket/preset-api
12
+
13
+ # Or with yarn
14
+ yarn create gasket-app my-api --presets @gasket/preset-api
15
+
16
+ # With config to skip prompts
17
+ npx create-gasket-app@latest my-api \
18
+ --presets @gasket/preset-api \
19
+ --config '{"server": "express", "typescript": true, "useSwagger": true}'
20
+ ```
21
+
22
+ ## Generated Project Structure
23
+
24
+ ### JavaScript Project
25
+
26
+ ```
27
+ my-api/
28
+ ├── server.js # Server entry point
29
+ ├── gasket.js # Gasket configuration
30
+ ├── package.json # Project configuration
31
+ └── README.md # Project documentation
32
+ ```
33
+
34
+ ### TypeScript Project
35
+
36
+ ```
37
+ my-api/
38
+ ├── gasket.ts # Gasket configuration (TypeScript)
39
+ ├── package.json # Project configuration
40
+ └── README.md # Project documentation
41
+ ```
42
+
43
+ ## Server Framework Examples
44
+
45
+ ### Express Server
46
+
47
+ ```js
48
+ // When server: 'express' is selected
49
+ // gasket.js
50
+ import { makeGasket } from '@gasket/core';
51
+ import pluginExpress from '@gasket/plugin-express';
52
+ import pluginHttps from '@gasket/plugin-https';
53
+
54
+ export default makeGasket({
55
+ plugins: [
56
+ pluginExpress,
57
+ pluginHttps,
58
+ // ... other plugins
59
+ ]
60
+ });
61
+
62
+ // Your route definitions
63
+ export default {
64
+ name: 'my-routes',
65
+ hooks: {
66
+ express(gasket, app) {
67
+ app.get('/api/health', (req, res) => {
68
+ res.json({ status: 'healthy' });
69
+ });
70
+
71
+ app.get('/api/users', (req, res) => {
72
+ res.json({ users: [] });
73
+ });
74
+ }
75
+ }
76
+ };
77
+ ```
78
+
79
+ ### Fastify Server
80
+
81
+ ```js
82
+ // When server: 'fastify' is selected
83
+ // gasket.js
84
+ import { makeGasket } from '@gasket/core';
85
+ import pluginFastify from '@gasket/plugin-fastify';
86
+ import pluginHttps from '@gasket/plugin-https';
87
+
88
+ export default makeGasket({
89
+ plugins: [
90
+ pluginFastify,
91
+ pluginHttps,
92
+ // ... other plugins
93
+ ]
94
+ });
95
+
96
+ // Your route definitions
97
+ export default {
98
+ name: 'my-routes',
99
+ hooks: {
100
+ fastify(gasket, app) {
101
+ app.get('/api/health', async (request, reply) => {
102
+ return { status: 'healthy' };
103
+ });
104
+
105
+ app.get('/api/users', async (request, reply) => {
106
+ return { users: [] };
107
+ });
108
+ }
109
+ }
110
+ };
111
+ ```
112
+
113
+ ## Integration Examples
114
+
115
+ ### With TypeScript
116
+
117
+ ```typescript
118
+ // gasket.ts
119
+ import { makeGasket } from '@gasket/core';
120
+ import pluginExpress from '@gasket/plugin-express';
121
+ import pluginTypescript from '@gasket/plugin-typescript';
122
+
123
+ export default makeGasket({
124
+ plugins: [
125
+ pluginExpress
126
+ // ... other plugins
127
+ ]
128
+ });
129
+
130
+ // types/api.ts
131
+ export interface User {
132
+ id: number;
133
+ name: string;
134
+ email: string;
135
+ }
136
+
137
+ // routes/users.ts
138
+ import type { User } from '../types/api.js';
139
+
140
+ export default {
141
+ name: 'user-routes',
142
+ hooks: {
143
+ express(gasket, app) {
144
+ app.get('/api/users', (req, res) => {
145
+ const users: User[] = [
146
+ { id: 1, name: 'John', email: 'john@example.com' }
147
+ ];
148
+ res.json({ users });
149
+ });
150
+ }
151
+ }
152
+ };
153
+ ```
154
+
155
+ ### With Swagger
156
+
157
+ ```js
158
+ // gasket.js - when useSwagger: true
159
+ import { makeGasket } from '@gasket/core';
160
+ import pluginSwagger from '@gasket/plugin-swagger';
161
+
162
+ export default makeGasket({
163
+ plugins: [
164
+ pluginSwagger,
165
+ // ... other plugins
166
+ ],
167
+ swagger: {
168
+ jsdoc: {
169
+ definition: {
170
+ openapi: '3.0.0',
171
+ info: {
172
+ title: 'My API',
173
+ version: '1.0.0'
174
+ }
175
+ },
176
+ apis: ['./routes/*.js']
177
+ }
178
+ }
179
+ });
180
+
181
+ // routes/users.js
182
+ /**
183
+ * @swagger
184
+ * /api/users:
185
+ * get:
186
+ * summary: Get all users
187
+ * responses:
188
+ * 200:
189
+ * description: List of users
190
+ * content:
191
+ * application/json:
192
+ * schema:
193
+ * type: object
194
+ * properties:
195
+ * users:
196
+ * type: array
197
+ * items:
198
+ * type: object
199
+ */
200
+ export default {
201
+ name: 'user-routes',
202
+ hooks: {
203
+ express(gasket, app) {
204
+ app.get('/api/users', (req, res) => {
205
+ res.json({ users: [] });
206
+ });
207
+ }
208
+ }
209
+ };
210
+ ```
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 GoDaddy Operating Company, LLC.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @gasket/preset-api
2
+
3
+ Framework for building API's using Gasket.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npx create-gasket-app@latest <app-name> --presets @gasket/preset-api
9
+ ```
10
+
11
+ ## Docs
12
+
13
+ To see complete the list of plugins configured in your app, and what commands, lifecycles, and structures are available, run the new `gasket docs` command in your app.
14
+
15
+ ## Plugins
16
+
17
+ - [@gasket/plugin-swagger](/packages/gasket-plugin-swagger/README.md)
18
+ - [@gasket/plugin-docs](/packages/gasket-plugin-docs/README.md)
19
+ - [@gasket/plugin-docusaurus](/packages/gasket-plugin-docusaurus/README.md)
20
+ - [@gasket/plugin-express](/packages/gasket-plugin-express/README.md)
21
+ - [@gasket/plugin-https](/packages/gasket-plugin-https/README.md)
22
+ - [@gasket/plugin-lint](/packages/gasket-plugin-lint/README.md)
23
+
24
+ ## License
25
+
26
+ [MIT](./LICENSE.md)
package/cjs/create.cjs ADDED
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ Object.defineProperty(exports, /** @type {import('@gasket/core').HookHandler<'create'>} */ "default", {
5
+ enumerable: true,
6
+ get: function() {
7
+ return create;
8
+ }
9
+ });
10
+ const _path = /*#__PURE__*/ _interop_require_default(require("path"));
11
+ const _module = require("module");
12
+ const _url = require("url");
13
+ function _interop_require_default(obj) {
14
+ return obj && obj.__esModule ? obj : {
15
+ default: obj
16
+ };
17
+ }
18
+ const require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
19
+ const { devDependencies } = require1('../package.json');
20
+ function create(gasket, context) {
21
+ const { pkg, files, packageManager } = context;
22
+ let runCmd;
23
+ if (packageManager === 'yarn') {
24
+ runCmd = 'yarn';
25
+ } else if (packageManager === 'pnpm') {
26
+ runCmd = 'pnpm';
27
+ } else {
28
+ runCmd = 'npm run';
29
+ }
30
+ const __dirname = (0, _url.fileURLToPath)(require("url").pathToFileURL(__filename).toString());
31
+ const generatorDir = _path.default.join(__dirname, '..', '..', 'generator');
32
+ files.add(`${generatorDir}/*.md`);
33
+ if (!context.typescript) {
34
+ files.add(`${generatorDir}/*.js`);
35
+ pkg.add('devDependencies', {
36
+ nodemon: devDependencies.nodemon
37
+ });
38
+ pkg.add('scripts', {
39
+ start: 'node server.js',
40
+ local: 'nodemon server.js',
41
+ preview: `${runCmd} start`
42
+ });
43
+ }
44
+ }
package/cjs/index.cjs ADDED
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ Object.defineProperty(exports, /** @type {import('@gasket/core').Preset} */ "default", {
5
+ enumerable: true,
6
+ get: function() {
7
+ return _default;
8
+ }
9
+ });
10
+ const _module = require("module");
11
+ const _presetprompt = /*#__PURE__*/ _interop_require_default(require("./preset-prompt.cjs"));
12
+ const _presetconfig = /*#__PURE__*/ _interop_require_default(require("./preset-config.cjs"));
13
+ const _create = /*#__PURE__*/ _interop_require_default(require("./create.cjs"));
14
+ function _interop_require_default(obj) {
15
+ return obj && obj.__esModule ? obj : {
16
+ default: obj
17
+ };
18
+ }
19
+ const require1 = (0, _module.createRequire)(require("url").pathToFileURL(__filename).toString());
20
+ const { name, version, description } = require1('../package.json');
21
+ const _default = {
22
+ name,
23
+ version,
24
+ description,
25
+ hooks: {
26
+ presetPrompt: _presetprompt.default,
27
+ presetConfig: _presetconfig.default,
28
+ create: _create.default
29
+ }
30
+ };
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,102 @@
1
+ // Default Plugins - included by default for all presets
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, /**
6
+ * presetConfig hook
7
+ * @param {Gasket} gasket - Gasket API
8
+ * @param {Create} context - Create context
9
+ * @returns {Promise<CreateContext.presetConfig>} config
10
+ */ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return presetConfig;
14
+ }
15
+ });
16
+ const _plugincommand = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-command"));
17
+ const _plugindocs = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-docs"));
18
+ const _plugindocusaurus = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-docusaurus"));
19
+ const _plugindynamicplugins = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-dynamic-plugins"));
20
+ const _plugingit = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-git"));
21
+ const _pluginlogger = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-logger"));
22
+ const _pluginhttps = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-https"));
23
+ const _pluginwinston = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-winston"));
24
+ const _pluginlint = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-lint"));
25
+ function _interop_require_default(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ function _getRequireWildcardCache(nodeInterop) {
31
+ if (typeof WeakMap !== "function") return null;
32
+ var cacheBabelInterop = new WeakMap();
33
+ var cacheNodeInterop = new WeakMap();
34
+ return (_getRequireWildcardCache = function(nodeInterop) {
35
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
+ })(nodeInterop);
37
+ }
38
+ function _interop_require_wildcard(obj, nodeInterop) {
39
+ if (!nodeInterop && obj && obj.__esModule) {
40
+ return obj;
41
+ }
42
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
+ return {
44
+ default: obj
45
+ };
46
+ }
47
+ var cache = _getRequireWildcardCache(nodeInterop);
48
+ if (cache && cache.has(obj)) {
49
+ return cache.get(obj);
50
+ }
51
+ var newObj = {
52
+ __proto__: null
53
+ };
54
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
+ for(var key in obj){
56
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
+ if (desc && (desc.get || desc.set)) {
59
+ Object.defineProperty(newObj, key, desc);
60
+ } else {
61
+ newObj[key] = obj[key];
62
+ }
63
+ }
64
+ }
65
+ newObj.default = obj;
66
+ if (cache) {
67
+ cache.set(obj, newObj);
68
+ }
69
+ return newObj;
70
+ }
71
+ async function presetConfig(gasket, context) {
72
+ const plugins = new Set([
73
+ _plugincommand.default,
74
+ _plugindocs.default,
75
+ _plugindocusaurus.default,
76
+ _plugindynamicplugins.default,
77
+ _plugingit.default,
78
+ _pluginhttps.default,
79
+ _pluginlint.default,
80
+ _pluginlogger.default,
81
+ _pluginwinston.default
82
+ ]);
83
+ const frameworkPlugin = context.server === 'express' ? await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-express"))) : await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-fastify")));
84
+ plugins.add(frameworkPlugin.default || frameworkPlugin);
85
+ if ('testPlugins' in context && context.testPlugins.length > 0) {
86
+ await Promise.all(context.testPlugins.map(async (testPlugin)=>{
87
+ const plugin = await Promise.resolve(testPlugin).then((p)=>/*#__PURE__*/ _interop_require_wildcard(require(p)));
88
+ plugins.add(plugin ? plugin.default || plugin : null);
89
+ }));
90
+ }
91
+ if (context.typescript) {
92
+ const typescriptPlugin = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-typescript")));
93
+ plugins.add(typescriptPlugin.default || typescriptPlugin);
94
+ }
95
+ if (context.useSwagger) {
96
+ const swaggerPlugin = await Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("@gasket/plugin-swagger")));
97
+ plugins.add(swaggerPlugin.default || swaggerPlugin);
98
+ }
99
+ return {
100
+ plugins: Array.from(plugins)
101
+ };
102
+ }
@@ -0,0 +1,50 @@
1
+ Object.defineProperty(exports, "__esModule", {
2
+ value: true
3
+ });
4
+ Object.defineProperty(exports, /**
5
+ * presetPrompt hook
6
+ * @param {Gasket} gasket - Gasket API
7
+ * @param {Create} context - Create context
8
+ * @param {object} utils - Prompt utils
9
+ * @param {Function} utils.prompt - Inquirer prompt
10
+ */ "default", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return presetPrompt;
14
+ }
15
+ });
16
+ const _prompts = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-typescript/prompts"));
17
+ const _prompts1 = /*#__PURE__*/ _interop_require_default(require("@gasket/plugin-swagger/prompts"));
18
+ function _interop_require_default(obj) {
19
+ return obj && obj.__esModule ? obj : {
20
+ default: obj
21
+ };
22
+ }
23
+ async function presetPrompt(gasket, context, { prompt }) {
24
+ context.apiApp = true;
25
+ await _prompts.default.promptTypescript(context, prompt);
26
+ await _prompts1.default.promptSwagger(context, prompt);
27
+ if (!('server' in context)) {
28
+ const { server } = await prompt([
29
+ {
30
+ name: 'server',
31
+ message: 'Which server framework would you like to use?',
32
+ type: 'list',
33
+ choices: [
34
+ {
35
+ name: 'Express',
36
+ value: 'express'
37
+ },
38
+ {
39
+ name: 'Fastify',
40
+ value: 'fastify'
41
+ }
42
+ ]
43
+ }
44
+ ]);
45
+ Object.assign(context, {
46
+ server
47
+ });
48
+ return context;
49
+ }
50
+ }
@@ -0,0 +1,43 @@
1
+ # {{{appName}}}
2
+
3
+ {{{appDescription}}}
4
+
5
+ ## Overview
6
+
7
+ This API is built with {{{server}}}.js framework and [Gasket](https://gasket.dev/). This application utilizes [EcmaScript Modules] and requires Node.js v20 or higher.
8
+
9
+ ## Getting Started
10
+
11
+ ### Development
12
+
13
+ To start the API locally, run:
14
+
15
+ ```bash
16
+ cd {{{appName}}}
17
+ {{{installCmd}}}
18
+ {{{localCmd}}}
19
+ ```
20
+
21
+ ### Debugging
22
+
23
+ To start the API locally with debugging enabled, run:
24
+
25
+ ```bash
26
+ DEBUG=* {{{localCmd}}}
27
+ ```
28
+
29
+ Extended filtering of the debug output can be achieved by adding to the `DEBUG` environment variable:
30
+
31
+ ```bash
32
+ DEBUG=gasket:* {{{localCmd}}} // gasket operations only
33
+ DEBUG={{{server}}}:* {{{localCmd}}} // {{{server}}} operations only
34
+ ```
35
+
36
+ {{#each readme.markdown}}
37
+ {{{markdownCompile this}}}
38
+ {{/each}}
39
+ <!-- LINKS -->
40
+ [EcmaScript Modules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
41
+ {{#each readme.links}}
42
+ {{{this}}}
43
+ {{/each}}
@@ -0,0 +1,2 @@
1
+ import gasket from './gasket.js';
2
+ gasket.actions.startServer();
package/lib/create.js ADDED
@@ -0,0 +1,37 @@
1
+ import path from 'path';
2
+ import { createRequire } from 'module';
3
+ import { fileURLToPath } from 'url';
4
+ const require = createRequire(import.meta.url);
5
+ const { devDependencies } = require('../package.json');
6
+
7
+ /** @type {import('@gasket/core').HookHandler<'create'>} */
8
+ export default function create(gasket, context) {
9
+ const { pkg, files, packageManager } = context;
10
+
11
+ let runCmd;
12
+ if (packageManager === 'yarn') {
13
+ runCmd = 'yarn';
14
+ } else if (packageManager === 'pnpm') {
15
+ runCmd = 'pnpm';
16
+ } else {
17
+ runCmd = 'npm run';
18
+ }
19
+
20
+ const __dirname = fileURLToPath(import.meta.url);
21
+ const generatorDir = path.join(__dirname, '..', '..', 'generator');
22
+ files.add(`${generatorDir}/*.md`);
23
+
24
+ if (!context.typescript) {
25
+ files.add(`${generatorDir}/*.js`);
26
+
27
+ pkg.add('devDependencies', {
28
+ nodemon: devDependencies.nodemon
29
+ });
30
+
31
+ pkg.add('scripts', {
32
+ start: 'node server.js',
33
+ local: 'nodemon server.js',
34
+ preview: `${runCmd} start`
35
+ });
36
+ }
37
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import '@gasket/plugin-express';
2
+ import '@gasket/plugin-fastify';
3
+ import '@gasket/plugin-https';
4
+ import '@gasket/plugin-lint';
5
+ import '@gasket/plugin-winston';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import { createRequire } from 'module';
2
+ import presetPrompt from './preset-prompt.js';
3
+ import presetConfig from './preset-config.js';
4
+ import create from './create.js';
5
+ const require = createRequire(import.meta.url);
6
+ const { name, version, description } = require('../package.json');
7
+
8
+ /** @type {import('@gasket/core').Preset} */
9
+ export default {
10
+ name,
11
+ version,
12
+ description,
13
+ hooks: {
14
+ presetPrompt,
15
+ presetConfig,
16
+ create
17
+ }
18
+ };
@@ -0,0 +1,59 @@
1
+ // Default Plugins - included by default for all presets
2
+ import pluginCommand from '@gasket/plugin-command';
3
+ import pluginDocs from '@gasket/plugin-docs';
4
+ import pluginDocusaurus from '@gasket/plugin-docusaurus';
5
+ import pluginDynamicPlugins from '@gasket/plugin-dynamic-plugins';
6
+ import pluginGit from '@gasket/plugin-git';
7
+ import pluginLogger from '@gasket/plugin-logger';
8
+
9
+ // Preset-specific Plugins
10
+ import pluginHttps from '@gasket/plugin-https';
11
+ import pluginWinston from '@gasket/plugin-winston';
12
+ import pluginLint from '@gasket/plugin-lint';
13
+
14
+ /**
15
+ * presetConfig hook
16
+ * @param {Gasket} gasket - Gasket API
17
+ * @param {Create} context - Create context
18
+ * @returns {Promise<CreateContext.presetConfig>} config
19
+ */
20
+ export default async function presetConfig(gasket, context) {
21
+ const plugins = new Set([
22
+ pluginCommand,
23
+ pluginDocs,
24
+ pluginDocusaurus,
25
+ pluginDynamicPlugins,
26
+ pluginGit,
27
+ pluginHttps,
28
+ pluginLint,
29
+ pluginLogger,
30
+ pluginWinston
31
+ ]);
32
+
33
+ const frameworkPlugin = context.server === 'express'
34
+ ? await import('@gasket/plugin-express')
35
+ : await import('@gasket/plugin-fastify');
36
+
37
+ plugins.add(frameworkPlugin.default || frameworkPlugin);
38
+
39
+ if ('testPlugins' in context && context.testPlugins.length > 0) {
40
+ await Promise.all(context.testPlugins.map(async (testPlugin) => {
41
+ const plugin = await import(testPlugin);
42
+ plugins.add(plugin ? plugin.default || plugin : null);
43
+ }));
44
+ }
45
+
46
+ if (context.typescript) {
47
+ const typescriptPlugin = await import('@gasket/plugin-typescript');
48
+ plugins.add(typescriptPlugin.default || typescriptPlugin);
49
+ }
50
+
51
+ if (context.useSwagger) {
52
+ const swaggerPlugin = await import('@gasket/plugin-swagger');
53
+ plugins.add(swaggerPlugin.default || swaggerPlugin);
54
+ }
55
+
56
+ return {
57
+ plugins: Array.from(plugins)
58
+ };
59
+ }
@@ -0,0 +1,34 @@
1
+ import typescriptPrompts from '@gasket/plugin-typescript/prompts';
2
+ import swaggerPrompts from '@gasket/plugin-swagger/prompts';
3
+
4
+ /**
5
+ * presetPrompt hook
6
+ * @param {Gasket} gasket - Gasket API
7
+ * @param {Create} context - Create context
8
+ * @param {object} utils - Prompt utils
9
+ * @param {Function} utils.prompt - Inquirer prompt
10
+ */
11
+ export default async function presetPrompt(gasket, context, { prompt }) {
12
+ context.apiApp = true;
13
+
14
+ await typescriptPrompts.promptTypescript(context, prompt);
15
+ await swaggerPrompts.promptSwagger(context, prompt);
16
+
17
+ if (!('server' in context)) {
18
+ const { server } = await prompt([
19
+ {
20
+ name: 'server',
21
+ message: 'Which server framework would you like to use?',
22
+ type: 'list',
23
+ choices: [
24
+ { name: 'Express', value: 'express' },
25
+ { name: 'Fastify', value: 'fastify' }
26
+ ]
27
+ }
28
+ ]);
29
+
30
+ Object.assign(context, { server });
31
+
32
+ return context;
33
+ }
34
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@gasket/preset-api",
3
+ "version": "0.0.0-canary-20250922152503",
4
+ "description": "Create Express-based API with Gasket",
5
+ "type": "module",
6
+ "types": "lib/index.d.ts",
7
+ "files": [
8
+ "generator",
9
+ "lib",
10
+ "cjs",
11
+ "EXAMPLES.md"
12
+ ],
13
+ "exports": {
14
+ ".": {
15
+ "types": "./lib/index.d.ts",
16
+ "import": "./lib/index.js",
17
+ "require": "./cjs/index.cjs",
18
+ "default": "./cjs/index.cjs"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "repository": "godaddy/gasket.git",
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "author": "GoDaddy Operating Company, LLC",
27
+ "license": "MIT",
28
+ "bugs": "https://github.com/godaddy/gasket/issues",
29
+ "homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-preset-api",
30
+ "dependencies": {
31
+ "@gasket/plugin-cypress": "^0.0.0-canary-20250922152503",
32
+ "@gasket/plugin-docs": "^0.0.0-canary-20250922152503",
33
+ "@gasket/plugin-dynamic-plugins": "^0.0.0-canary-20250922152503",
34
+ "@gasket/plugin-docusaurus": "^0.0.0-canary-20250922152503",
35
+ "@gasket/plugin-express": "^0.0.0-canary-20250922152503",
36
+ "@gasket/plugin-git": "^0.0.0-canary-20250922152503",
37
+ "@gasket/plugin-fastify": "^0.0.0-canary-20250922152503",
38
+ "@gasket/plugin-https": "^0.0.0-canary-20250922152503",
39
+ "@gasket/plugin-lint": "^0.0.0-canary-20250922152503",
40
+ "@gasket/plugin-jest": "^0.0.0-canary-20250922152503",
41
+ "@gasket/plugin-command": "^0.0.0-canary-20250922152503",
42
+ "@gasket/plugin-logger": "^0.0.0-canary-20250922152503",
43
+ "@gasket/plugin-mocha": "^7.5.4",
44
+ "@gasket/plugin-typescript": "^0.0.0-canary-20250922152503",
45
+ "@gasket/plugin-swagger": "^0.0.0-canary-20250922152503",
46
+ "@gasket/plugin-winston": "^0.0.0-canary-20250922152503",
47
+ "@gasket/plugin-vitest": "^0.0.0-canary-20250922152503"
48
+ },
49
+ "devDependencies": {
50
+ "@vitest/coverage-v8": "^3.2.0",
51
+ "nodemon": "^3.1.9",
52
+ "vitest": "^3.2.0",
53
+ "@gasket/cjs": "^0.0.0-canary-20250922152503",
54
+ "create-gasket-app": "^0.0.0-canary-20250922152503",
55
+ "@gasket/plugin-metadata": "^0.0.0-canary-20250922152503"
56
+ },
57
+ "scripts": {
58
+ "build": "gasket-cjs ./lib",
59
+ "build:watch": "pnpm run build --watch",
60
+ "lint": "eslint .",
61
+ "lint:fix": "pnpm run lint --fix",
62
+ "posttest": "pnpm run lint",
63
+ "test": "vitest run --globals",
64
+ "test:coverage": "vitest run --coverage",
65
+ "test:watch": "vitest"
66
+ }
67
+ }