@gasket/preset-api 7.3.0-canary.6 → 7.3.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 +1 -10
- package/generator/README.md +43 -0
- package/lib/create.js +5 -7
- package/lib/index.d.ts +0 -2
- package/lib/index.js +1 -1
- package/lib/preset-config.js +32 -17
- package/lib/preset-prompt.js +4 -0
- package/package.json +41 -29
package/README.md
CHANGED
|
@@ -2,18 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Framework for building API's using Gasket.
|
|
4
4
|
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
This preset requires v5 of the `@gasket/cli`:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm i -g @gasket/cli@^5.0.0
|
|
11
|
-
```
|
|
12
|
-
|
|
13
5
|
## Installation
|
|
14
6
|
|
|
15
7
|
```bash
|
|
16
|
-
|
|
8
|
+
npx create-gasket-app <app-name> --presets @gasket/preset-api
|
|
17
9
|
```
|
|
18
10
|
|
|
19
11
|
## Docs
|
|
@@ -22,7 +14,6 @@ To see complete the list of plugins configured in your app, and what commands, l
|
|
|
22
14
|
|
|
23
15
|
## Plugins
|
|
24
16
|
|
|
25
|
-
- [@gasket/plugin-data](/packages/gasket-plugin-data/README.md)
|
|
26
17
|
- [@gasket/plugin-swagger](/packages/gasket-plugin-swagger/README.md)
|
|
27
18
|
- [@gasket/plugin-docs](/packages/gasket-plugin-docs/README.md)
|
|
28
19
|
- [@gasket/plugin-docusaurus](/packages/gasket-plugin-docusaurus/README.md)
|
|
@@ -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}}
|
package/lib/create.js
CHANGED
|
@@ -4,18 +4,15 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
const require = createRequire(import.meta.url);
|
|
5
5
|
const { devDependencies } = require('../package.json');
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* createHook
|
|
9
|
-
* @param {Gasket} gasket - Gasket API
|
|
10
|
-
* @param {Create} context - Create context
|
|
11
|
-
*/
|
|
7
|
+
/** @type {import('@gasket/core').HookHandler<'create'>} */
|
|
12
8
|
export default function create(gasket, context) {
|
|
13
9
|
const { pkg, files } = context;
|
|
14
10
|
const __dirname = fileURLToPath(import.meta.url);
|
|
15
11
|
const generatorDir = path.join(__dirname, '..', '..', 'generator');
|
|
12
|
+
files.add(`${generatorDir}/*.md`);
|
|
16
13
|
|
|
17
14
|
if (!context.typescript) {
|
|
18
|
-
files.add(`${generatorDir}
|
|
15
|
+
files.add(`${generatorDir}/*.js`);
|
|
19
16
|
|
|
20
17
|
pkg.add('devDependencies', {
|
|
21
18
|
nodemon: devDependencies.nodemon
|
|
@@ -23,7 +20,8 @@ export default function create(gasket, context) {
|
|
|
23
20
|
|
|
24
21
|
pkg.add('scripts', {
|
|
25
22
|
start: 'node server.js',
|
|
26
|
-
local: '
|
|
23
|
+
local: 'nodemon server.js',
|
|
24
|
+
preview: 'npm run start'
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
}
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import create from './create.js';
|
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const { name, version, description } = require('../package.json');
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/** @type {import('@gasket/core').Preset} */
|
|
9
9
|
export default {
|
|
10
10
|
name,
|
|
11
11
|
version,
|
package/lib/preset-config.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
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
|
|
1
10
|
import pluginHttps from '@gasket/plugin-https';
|
|
2
|
-
import pluginData from '@gasket/plugin-data';
|
|
3
11
|
import pluginWinston from '@gasket/plugin-winston';
|
|
4
|
-
import pluginSwagger from '@gasket/plugin-swagger';
|
|
5
12
|
import pluginLint from '@gasket/plugin-lint';
|
|
6
13
|
|
|
7
14
|
/**
|
|
@@ -11,34 +18,42 @@ import pluginLint from '@gasket/plugin-lint';
|
|
|
11
18
|
* @returns {Promise<CreateContext.presetConfig>} config
|
|
12
19
|
*/
|
|
13
20
|
export default async function presetConfig(gasket, context) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
|
|
17
33
|
const frameworkPlugin = context.server === 'express'
|
|
18
34
|
? await import('@gasket/plugin-express')
|
|
19
35
|
: await import('@gasket/plugin-fastify');
|
|
20
36
|
|
|
37
|
+
plugins.add(frameworkPlugin.default || frameworkPlugin);
|
|
38
|
+
|
|
21
39
|
if ('testPlugins' in context && context.testPlugins.length > 0) {
|
|
22
40
|
await Promise.all(context.testPlugins.map(async (testPlugin) => {
|
|
23
41
|
const plugin = await import(testPlugin);
|
|
24
|
-
|
|
42
|
+
plugins.add(plugin ? plugin.default || plugin : null);
|
|
25
43
|
}));
|
|
26
44
|
}
|
|
27
45
|
|
|
28
46
|
if (context.typescript) {
|
|
29
|
-
typescriptPlugin = await import('@gasket/plugin-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);
|
|
30
54
|
}
|
|
31
55
|
|
|
32
56
|
return {
|
|
33
|
-
plugins:
|
|
34
|
-
pluginHttps,
|
|
35
|
-
pluginData,
|
|
36
|
-
pluginWinston,
|
|
37
|
-
pluginSwagger,
|
|
38
|
-
pluginLint,
|
|
39
|
-
frameworkPlugin.default || frameworkPlugin,
|
|
40
|
-
typescriptPlugin ? typescriptPlugin.default || typescriptPlugin : null,
|
|
41
|
-
...testPlugins
|
|
42
|
-
].filter(Boolean)
|
|
57
|
+
plugins: Array.from(plugins)
|
|
43
58
|
};
|
|
44
59
|
}
|
package/lib/preset-prompt.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import typescriptPrompts from '@gasket/plugin-typescript/prompts';
|
|
2
|
+
import swaggerPrompts from '@gasket/plugin-swagger/prompts';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* presetPrompt hook
|
|
@@ -11,6 +12,7 @@ export default async function presetPrompt(gasket, context, { prompt }) {
|
|
|
11
12
|
context.apiApp = true;
|
|
12
13
|
|
|
13
14
|
await typescriptPrompts.promptTypescript(context, prompt);
|
|
15
|
+
await swaggerPrompts.promptSwagger(context, prompt);
|
|
14
16
|
|
|
15
17
|
if (!('server' in context)) {
|
|
16
18
|
const { server } = await prompt([
|
|
@@ -26,5 +28,7 @@ export default async function presetPrompt(gasket, context, { prompt }) {
|
|
|
26
28
|
]);
|
|
27
29
|
|
|
28
30
|
Object.assign(context, { server });
|
|
31
|
+
|
|
32
|
+
return context;
|
|
29
33
|
}
|
|
30
34
|
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/preset-api",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Create Express-based API with Gasket",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"types": "lib/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"generator",
|
|
9
10
|
"lib"
|
|
10
11
|
],
|
|
11
|
-
"type": "module",
|
|
12
|
-
"scripts": {
|
|
13
|
-
"lint": "eslint .",
|
|
14
|
-
"lint:fix": "npm run lint -- --fix",
|
|
15
|
-
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
|
|
16
|
-
"test:watch": "npm run test -- --watch",
|
|
17
|
-
"test:coverage": "jest --coverage",
|
|
18
|
-
"posttest": "npm run lint"
|
|
19
|
-
},
|
|
20
12
|
"repository": {
|
|
21
13
|
"type": "git",
|
|
22
14
|
"url": "git+ssh://git@github.com/godaddy/gasket.git"
|
|
@@ -29,27 +21,39 @@
|
|
|
29
21
|
"bugs": {
|
|
30
22
|
"url": "https://github.com/godaddy/gasket/issues"
|
|
31
23
|
},
|
|
24
|
+
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-preset-api",
|
|
32
25
|
"dependencies": {
|
|
33
|
-
"@gasket/plugin-
|
|
34
|
-
"@gasket/plugin-
|
|
35
|
-
"@gasket/plugin-
|
|
36
|
-
"@gasket/plugin-
|
|
37
|
-
"@gasket/plugin-
|
|
38
|
-
"@gasket/plugin-
|
|
39
|
-
"@gasket/plugin-
|
|
40
|
-
"@gasket/plugin-
|
|
41
|
-
"@gasket/plugin-
|
|
42
|
-
"@gasket/plugin-
|
|
43
|
-
"@gasket/plugin-
|
|
26
|
+
"@gasket/plugin-command": "^7.3.0",
|
|
27
|
+
"@gasket/plugin-cypress": "^7.3.0",
|
|
28
|
+
"@gasket/plugin-docusaurus": "^7.3.0",
|
|
29
|
+
"@gasket/plugin-docs": "^7.3.0",
|
|
30
|
+
"@gasket/plugin-dynamic-plugins": "^7.3.0",
|
|
31
|
+
"@gasket/plugin-fastify": "^7.3.1",
|
|
32
|
+
"@gasket/plugin-git": "^7.3.0",
|
|
33
|
+
"@gasket/plugin-express": "^7.3.0",
|
|
34
|
+
"@gasket/plugin-https": "^7.3.0",
|
|
35
|
+
"@gasket/plugin-jest": "^7.3.0",
|
|
36
|
+
"@gasket/plugin-lint": "^7.3.0",
|
|
37
|
+
"@gasket/plugin-logger": "^7.3.0",
|
|
38
|
+
"@gasket/plugin-swagger": "^7.3.0",
|
|
39
|
+
"@gasket/plugin-typescript": "^7.3.0",
|
|
40
|
+
"@gasket/plugin-mocha": "^7.3.0",
|
|
41
|
+
"@gasket/plugin-winston": "^7.3.0"
|
|
44
42
|
},
|
|
45
43
|
"devDependencies": {
|
|
44
|
+
"@types/jest": "^29.5.14",
|
|
45
|
+
"@types/node": "^20.17.19",
|
|
46
46
|
"cross-env": "^7.0.3",
|
|
47
|
-
"eslint": "^8.
|
|
48
|
-
"eslint-config-godaddy": "^7.
|
|
49
|
-
"eslint-
|
|
50
|
-
"eslint-plugin-
|
|
47
|
+
"eslint": "^8.57.1",
|
|
48
|
+
"eslint-config-godaddy": "^7.1.1",
|
|
49
|
+
"eslint-config-godaddy-typescript": "^4.0.3",
|
|
50
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
51
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
51
52
|
"jest": "^29.7.0",
|
|
52
|
-
"nodemon": "^3.1.
|
|
53
|
+
"nodemon": "^3.1.9",
|
|
54
|
+
"typescript": "^5.7.3",
|
|
55
|
+
"@gasket/plugin-metadata": "^7.3.0",
|
|
56
|
+
"create-gasket-app": "^7.3.0"
|
|
53
57
|
},
|
|
54
58
|
"eslintConfig": {
|
|
55
59
|
"extends": [
|
|
@@ -64,10 +68,18 @@
|
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
70
|
"eslintIgnore": [
|
|
67
|
-
"test/fixtures"
|
|
71
|
+
"test/fixtures",
|
|
72
|
+
"generator"
|
|
68
73
|
],
|
|
69
74
|
"jest": {
|
|
70
75
|
"transform": {}
|
|
71
76
|
},
|
|
72
|
-
"
|
|
73
|
-
|
|
77
|
+
"scripts": {
|
|
78
|
+
"lint": "eslint .",
|
|
79
|
+
"lint:fix": "pnpm run lint --fix",
|
|
80
|
+
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
|
|
81
|
+
"test:watch": "pnpm run test --watch",
|
|
82
|
+
"test:coverage": "jest --coverage",
|
|
83
|
+
"posttest": "pnpm run lint"
|
|
84
|
+
}
|
|
85
|
+
}
|