@gasket/template-api-fastify 0.0.0-canary-20250922153852
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/LICENSE.md +21 -0
- package/README.md +0 -0
- package/package.json +29 -0
- package/template/README.md +92 -0
- package/template/gasket.ts +46 -0
- package/template/package-lock.json +22887 -0
- package/template/package.json +64 -0
- package/template/plugins/README.md +11 -0
- package/template/plugins/routes-plugin.ts +27 -0
- package/template/server.ts +4 -0
- package/template/swagger.json +28 -0
- package/template/test/index.test.ts +21 -0
- package/template/tsconfig.json +33 -0
- package/template/vitest.config.js +8 -0
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
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gasket/template-api-fastify",
|
|
3
|
+
"version": "0.0.0-canary-20250922153852",
|
|
4
|
+
"description": "Gasket API template for Fastify",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"template"
|
|
8
|
+
],
|
|
9
|
+
"repository": "godaddy/gasket.git",
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"author": "GoDaddy Operating Company, LLC",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"bugs": "https://github.com/godaddy/gasket/issues",
|
|
16
|
+
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-template-api-fastify",
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@vitest/coverage-v8": "^3.2.0",
|
|
19
|
+
"vitest": "^3.2.0"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"lint:fix": "pnpm run lint --fix",
|
|
24
|
+
"posttest": "pnpm run lint",
|
|
25
|
+
"test": "vitest run --globals",
|
|
26
|
+
"test:coverage": "vitest run --coverage",
|
|
27
|
+
"test:watch": "vitest --watch --globals"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# {{{appName}}}
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This API is built with fastify.js framework and [Gasket](https://gasket.dev/). This application utilizes [EcmaScript Modules] and requires Node.js v20 or higher.
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
### Development
|
|
10
|
+
|
|
11
|
+
To start the API locally, run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd {{{appName}}}
|
|
15
|
+
npm install
|
|
16
|
+
npm run local
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Debugging
|
|
20
|
+
|
|
21
|
+
To start the API locally with debugging enabled, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
DEBUG=* npm run local
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Extended filtering of the debug output can be achieved by adding to the `DEBUG` environment variable:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
DEBUG=gasket:* npm run local // gasket operations only
|
|
31
|
+
DEBUG=fastify:* npm run local // fastify operations only
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Documentation
|
|
35
|
+
|
|
36
|
+
Generated docs will be placed in the `.docs` directory. To generate markdown documentation for the API, run:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm run docs
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Docusaurus
|
|
43
|
+
|
|
44
|
+
When using [Docusaurus], generated docs will be available at `http://localhost:3000` when running the [Docusaurus] server. By default the Docusaurus server is started with the `docs` script. Add the `--no-view` option to only generate the markdown files.
|
|
45
|
+
|
|
46
|
+
### Definitions
|
|
47
|
+
|
|
48
|
+
Use `@swagger` JSDocs to automatically generate the [swagger.json] spec file. Visit [swagger-jsdoc] for examples.
|
|
49
|
+
|
|
50
|
+
### TypeScript
|
|
51
|
+
|
|
52
|
+
This API is built with TypeScript. To compile the TypeScript code, run:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Use the `start` script to run the compiled code:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npm start
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Run `build` and `start` together:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm run preview
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Compiled code will be placed in the `dist` directory. For local development, the [tsx] runtime is used and the watcher will be started automatically when running the `local` script.
|
|
71
|
+
|
|
72
|
+
#### ESM & TypeScript
|
|
73
|
+
|
|
74
|
+
A common workaround when using ESM in a TypeScript project with `"type": "module"` set in `package.json` is to import `.ts` files using the `.js` extension. For example:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { myFunction } from './myModule.js';
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Here, `myModule.ts` is the actual TypeScript file, but it's imported using the `.js` extension. TypeScript is able to resolve `myModule.ts` to `myModule.js`, making the import work at runtime.
|
|
81
|
+
|
|
82
|
+
For more information, see the extended documentation in the [Gasket TypeScript] doc and the [@gasket/plugin-typescript] package.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
<!-- LINKS -->
|
|
86
|
+
[EcmaScript Modules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
87
|
+
[Docusaurus]: https://docusaurus.io/
|
|
88
|
+
[tsx]: https://tsx.is/
|
|
89
|
+
[@gasket/plugin-typescript]: https://gasket.dev/docs/plugins/plugin-typescript/
|
|
90
|
+
[Gasket TypeScript]: https://gasket.dev/docs/typescript/
|
|
91
|
+
[swagger-jsdoc]: https://github.com/Surnet/swagger-jsdoc/
|
|
92
|
+
[swagger.json]: /swagger.json
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { GasketConfigDefinition } from '@gasket/core';
|
|
2
|
+
import { makeGasket } from '@gasket/core';
|
|
3
|
+
import pluginCommand from '@gasket/plugin-command';
|
|
4
|
+
import pluginDynamicPlugins from '@gasket/plugin-dynamic-plugins';
|
|
5
|
+
import pluginHttps from '@gasket/plugin-https';
|
|
6
|
+
import pluginLogger from '@gasket/plugin-logger';
|
|
7
|
+
import pluginWinston from '@gasket/plugin-winston';
|
|
8
|
+
import pluginFastify from '@gasket/plugin-fastify';
|
|
9
|
+
import pluginRoutes from './plugins/routes-plugin.js';
|
|
10
|
+
import pluginSwagger from '@gasket/plugin-swagger';
|
|
11
|
+
|
|
12
|
+
export default makeGasket({
|
|
13
|
+
plugins: [
|
|
14
|
+
pluginCommand,
|
|
15
|
+
pluginDynamicPlugins,
|
|
16
|
+
pluginHttps,
|
|
17
|
+
pluginLogger,
|
|
18
|
+
pluginWinston,
|
|
19
|
+
pluginFastify,
|
|
20
|
+
pluginRoutes,
|
|
21
|
+
pluginSwagger
|
|
22
|
+
],
|
|
23
|
+
commands: {
|
|
24
|
+
docs: {
|
|
25
|
+
dynamicPlugins: [
|
|
26
|
+
'@gasket/plugin-docs',
|
|
27
|
+
'@gasket/plugin-metadata',
|
|
28
|
+
'@gasket/plugin-docusaurus'
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
swagger: {
|
|
33
|
+
jsdoc: {
|
|
34
|
+
definition: {
|
|
35
|
+
info: {
|
|
36
|
+
title: 'fastify-ts',
|
|
37
|
+
version: '0.0.0'
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
apis: [
|
|
41
|
+
'./routes/*',
|
|
42
|
+
'./plugins/*'
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} as GasketConfigDefinition);
|