### Install and Run API Locally
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-preset-api/generator/README.md
Navigate to the project directory, install dependencies, and start the API locally.
```bash
cd {{{appName}}}
{{{installCmd}}}
{{{localCmd}}}
```
--------------------------------
### Install and Run Application Locally
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-template-api-express/template/README.md
Navigate to the application directory, install dependencies, and start the API locally.
```bash
cd {{{appName}}}
npm install
npm run local
```
--------------------------------
### Start Gasket Application Locally
Source: https://github.com/godaddy/gasket/blob/main/packages/create-gasket-app/test/fixtures/packages/ci-basic-plugin/generator/README.md
Navigate to the application directory, install dependencies, and start the Gasket app. This assumes you have the necessary install and local commands defined.
```bash
cd {{{appName}}}
{{{installCmd}}}
{{{localCmd}}}
```
--------------------------------
### Installation and Basic Configuration
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-nextjs/README.md
Instructions for installing the plugin and updating your gasket.js file, along with an example of basic Next.js configuration.
```APIDOC
## Installation
```bash
npm i @gasket/plugin-nextjs
```
Update your `gasket.js` file plugin configuration:
```diff
// gasket.js
import pluginNextjs from '@gasket/plugin-nextjs';
export default makeGasket({
plugins: [
pluginNextjs
]
});
```
## Configuration
It is also possible for apps to config Next.js using the `gasket.js`
file. To do so, specify a `nextConfig` object property in the same form as what
you would set for [custom configurations][next.config] or using Next.js plugins.
#### Example Gasket configuration
```js
// gasket.js
export default makeGasket({
plugins: [
pluginNextjs
],
nextConfig: {
poweredByHeader: false,
useFileSystemPublicRoutes: false
}
});
```
```
--------------------------------
### Basic Plugin Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-winston/EXAMPLES.md
Install the plugin by importing it and adding it to the plugins array in your gasket.js configuration.
```javascript
import { makeGasket } from '@gasket/core';
import pluginWinston from '@gasket/plugin-winston';
export default makeGasket({
plugins: [
pluginWinston
]
});
```
--------------------------------
### Basic Plugin Installation and Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-workbox/EXAMPLES.md
Configure the basic @gasket/plugin-workbox by importing and including it in your gasket configuration.
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginWorkbox from '@gasket/plugin-workbox';
export default makeGasket({
plugins: [
pluginWorkbox
]
});
```
--------------------------------
### Gasket Plugin: Init Lifecycle Example
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-core/README.md
Example of a Gasket plugin implementing the `init` lifecycle. This hook is executed early for initial setup and can record timestamps.
```javascript
// gasket-plugin-example.js
const name = 'gasket-plugin-example';
let _initializedTime;
const hooks = {
init(gasket) {
_initializedTime = Date.now();
}
};
export default { name, hooks };
```
--------------------------------
### Install and Setup @gasket/plugin-happyfeet
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-happyfeet/EXAMPLES.md
Demonstrates how to import and include the plugin in your Gasket application's configuration.
```javascript
import { makeGasket } from '@gasket/core';
import pluginHappyfeet from '@gasket/plugin-happyfeet';
export default makeGasket({
plugins: [
pluginHappyfeet
]
});
```
--------------------------------
### Installation and Basic Configuration
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-webpack/README.md
Instructions on how to install the plugin and add it to your Gasket configuration.
```APIDOC
## Installation
```sh
npm i @gasket\/plugin-webpack
```
Update your `gasket` file plugin configuration:
```diff
// gasket.js
+ import pluginWebpack from '@gasket\/plugin-webpack';
export default makeGasket({
plugins: [
+ pluginWebpack
]
});
```
## Configuration
The Webpack plugin is configured using the `gasket.js` file.
First, add it to the `plugins` section of your `gasket.js`:
```js
export default makeGasket({
plugins: {
pluginWebpack
}
});
```
If your app was previously using the `webpack` property in the
`gasket.js`, you should update your configuration to use the
[webpackConfig] lifecycle instead.
```
--------------------------------
### Build and Start Application
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-template-api-express/template/README.md
Run the build and start scripts together to compile and then run the application.
```bash
npm run preview
```
--------------------------------
### Install Dependencies
Source: https://github.com/godaddy/gasket/blob/main/site/README.md
Run this command to install project dependencies.
```bash
yarn
```
--------------------------------
### Build and Start Gasket App
Source: https://github.com/godaddy/gasket/blob/main/docs/quick-start.md
To prepare the application for production or a standalone deployment, first build the application and then start it using `npm run build` and `npm run start` respectively.
```bash
npm run build
```
```bash
npm run start
```
--------------------------------
### Basic Plugin Installation
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-docusaurus/EXAMPLES.md
Install the plugin by importing it in your gasket.js file.
```javascript
import { makeGasket } from '@gasket/core';
import pluginDocs from '@gasket/plugin-docs';
import pluginDocusaurus from '@gasket/plugin-docusaurus';
export default makeGasket({
plugins: [
pluginDocs,
pluginDocusaurus
]
});
```
--------------------------------
### Basic Plugin Installation
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-https/EXAMPLES.md
Demonstrates how to install the @gasket/plugin-https plugin with basic Gasket configuration.
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginHttps from '@gasket/plugin-https';
export default makeGasket({
plugins: [
pluginHttps
]
});
```
--------------------------------
### Define Custom Docs Setup in Gasket Preset
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-docs/README.md
This example demonstrates how to configure custom documentation settings within a Gasket preset using the `docsSetup` property. It specifies a link to another markdown file and includes glob patterns for additional documentation files.
```javascript
// gasket-preset-example.js
export default {
name: 'gasket-preset-example',
docsSetup: {
link: 'OTHER.md#go-here',
files: ['more-docs/**/*.*'],
}
}
```
--------------------------------
### Basic Plugin Setup with @gasket/plugin-fastify
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-fastify/EXAMPLES.md
Demonstrates the basic setup for integrating the @gasket/plugin-fastify plugin into a Gasket application.
```javascript
import { makeGasket } from '@gasket/core';
import pluginFastify from '@gasket/plugin-fastify';
export default makeGasket({
plugins: [
pluginFastify
]
});
```
--------------------------------
### Install @gasket/plugin-docs-graphs
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-docs-graphs/README.md
Use npm to install the plugin. This is the first step before configuring it.
```bash
npm i @gasket/plugin-docs-graphs
```
--------------------------------
### Install @gasket/plugin-morgan
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-morgan/EXAMPLES.md
Basic installation of the plugin. Ensure @gasket/plugin-express is also included.
```javascript
import { makeGasket } from '@gasket/core';
import pluginMorgan from '@gasket/plugin-morgan';
import pluginExpress from '@gasket/plugin-express';
export default makeGasket({
plugins: [
pluginExpress,
pluginMorgan
]
});
```
--------------------------------
### Preboot Hook for HTTPS Proxy Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-https-proxy/EXAMPLES.md
Implement custom logic to run before the HTTPS proxy server starts. This hook is useful for tasks like loading SSL certificates, initializing connection pools, or setting up health checks.
```javascript
export default {
name: 'my-proxy-plugin',
hooks: {
prebootHttpsProxy: async function(gasket) {
// Load SSL certificates
gasket.logger.info('Loading SSL certificates...');
await loadCertificates();
// Initialize connection pools
gasket.logger.info('Initializing connection pools...');
await initializeConnectionPools();
// Set up health check endpoints
gasket.logger.info('Setting up health checks...');
await setupHealthChecks();
}
}
};
async function loadCertificates() {
// Certificate loading logic
return new Promise(resolve => setTimeout(resolve, 100));
}
async function initializeConnectionPools() {
// Connection pool initialization
return new Promise(resolve => setTimeout(resolve, 50));
}
async function setupHealthChecks() {
// Health check setup
return new Promise(resolve => setTimeout(resolve, 25));
}
```
--------------------------------
### Installation
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-cjs/README.md
Install the @gasket/cjs package using pnpm.
```APIDOC
## Installation
```bash
pnpm install @gasket/cjs
```
```
--------------------------------
### Basic Plugin Installation
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-command/EXAMPLES.md
Install and configure the command plugin in your Gasket application.
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginCommand from '@gasket/plugin-command';
export default makeGasket({
plugins: [
pluginCommand
]
});
```
--------------------------------
### Install @gasket/fetch
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-fetch/README.md
Install the @gasket/fetch package using npm.
```bash
npm i @gasket/fetch
```
--------------------------------
### Install @gasket/plugin-dynamic-plugins
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-dynamic-plugins/README.md
Install the plugin using npm.
```bash
npm i @gasket/plugin-dynamic-plugins
```
--------------------------------
### Install @gasket/plugin-analyze
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-analyze/README.md
Install the plugin using npm. Then, import and add it to your gasket.js plugin configuration.
```bash
npm i @gasket/plugin-analyze
```
```diff
// gasket.js
+ import pluginAnalyze from '@gasket/plugin-analyze';
export default makeGasket({
plugins: [
+ pluginAnalyze
]
});
```
--------------------------------
### Install @gasket/plugin-manifest
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-manifest/README.md
Install the plugin using npm. This is the first step for new applications.
```bash
npm i @gasket/plugin-manifest
```
--------------------------------
### Install @gasket/plugin-redux and @gasket/plugin-middleware
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-redux/README.md
Install the necessary Gasket plugins using npm.
```bash
npm i @gasket/plugin-redux @gasket/plugin-middleware
```
--------------------------------
### Example Test File
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-vitest/EXAMPLES.md
A basic example of a Vitest test file that can be generated by the plugin.
```javascript
// test/example.test.js
import { describe, it, expect } from 'vitest';
describe('Example test', () => {
it('should pass', () => {
expect(true).toBe(true);
});
});
```
--------------------------------
### Install @gasket/core
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-core/README.md
Install the core Gasket package using npm. This is the first step for existing applications.
```shell
npm install @gasket/core
```
--------------------------------
### Install @gasket/plugin-data
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-data/README.md
Install the plugin using npm. This is the first step for new applications.
```bash
npm i @gasket/plugin-data
```
--------------------------------
### Basic Plugin Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-swagger/EXAMPLES.md
Configure the plugin with a definition file and API docs route.
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginSwagger from '@gasket/plugin-swagger';
export default makeGasket({
plugins: [
pluginSwagger
],
swagger: {
definitionFile: 'swagger.json',
apiDocsRoute: '/api-docs'
}
});
```
--------------------------------
### GET /users
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-swagger/EXAMPLES.md
Example of documenting a basic GET endpoint to retrieve all users using JSDoc annotations.
```APIDOC
## GET /users
### Description
This endpoint retrieves a list of all users. The response is documented to be an array of user objects.
### Method
GET
### Endpoint
/users
### Parameters
None
### Request Body
None
### Response
#### Success Response (200)
- **description** (string) - List of users
- **content** (object)
- **application/json** (object)
- **schema** (object)
- **type** (string) - array
- **items** (object)
- **$ref** (string) - '#/components/schemas/User'
### Response Example
```json
[
{
"id": "user-123",
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2023-01-01T12:00:00Z"
}
]
```
### Code
```javascript
// routes/users.js
/**
* @swagger
* /users:
* get:
* summary: Get all users
* tags: [Users]
* responses:
* 200:
* description: List of users
* content:
* application/json:
* schema:
* type: array
* items:
* $ref: '#/components/schemas/User'
*/
router.get('/users', (req, res) => {
res.json([]);
});
```
```
--------------------------------
### Install pnpm
Source: https://github.com/godaddy/gasket/blob/main/CONTRIBUTING.md
Instructions for installing pnpm, the package manager used in this monorepo.
```bash
pnpm install
```
--------------------------------
### Start Local Development Server
Source: https://github.com/godaddy/gasket/blob/main/site/README.md
Starts a local development server for live preview. Changes are reflected without a server restart.
```bash
yarn start
```
--------------------------------
### Install @gasket/plugin-middleware
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-middleware/README.md
Install the plugin using npm. This is the initial step for integrating middleware functionality.
```sh
npm i @gasket/plugin-middleware
```
--------------------------------
### Install @gasket/plugin-morgan
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-morgan/README.md
Install the plugin using npm. This is the first step to integrating morgan logging into your Gasket application.
```bash
npm i @gasket/plugin-morgan
```
--------------------------------
### GET /users/{id}
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-swagger/EXAMPLES.md
Example of documenting a GET endpoint to retrieve a specific user by ID, including path parameters and error responses.
```APIDOC
## GET /users/{id}
### Description
This endpoint retrieves a specific user's details by their unique ID. It includes documentation for path parameters and potential error responses like 404 Not Found.
### Method
GET
### Endpoint
/users/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - User ID
### Request Body
None
### Response
#### Success Response (200)
- **description** (string) - User details
- **content** (object)
- **application/json** (object)
- **schema** (object)
- **$ref** (string) - '#/components/schemas/User'
#### Error Response (404)
- **description** (string) - User not found
### Response Example
```json
{
"id": "user-123",
"email": "user@example.com",
"name": "John Doe",
"createdAt": "2023-01-01T12:00:00Z"
}
```
### Code
```javascript
// routes/users.js
/**
* @swagger
* /users/{id}:
* get:
* summary: Get user by ID
* tags: [Users]
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: string
* description: User ID
* responses:
* 200:
* description: User details
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/User'
* 404:
* description: User not found
*/
router.get('/users/:id', (req, res) => {
res.json({});
});
```
```
--------------------------------
### Basic Plugin Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-swagger/EXAMPLES.md
Demonstrates the minimal configuration required to enable the swagger plugin.
```APIDOC
## Plugin Configuration: Basic Plugin Setup
### Description
This snippet shows the basic setup for the `@gasket/plugin-swagger` in your `gasket.js` file.
### Code
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginSwagger from '@gasket/plugin-swagger';
export default makeGasket({
plugins: [
pluginSwagger
],
swagger: {
definitionFile: 'swagger.json',
apiDocsRoute: '/api-docs'
}
});
```
```
--------------------------------
### Start Development Server with GASKET_DEV
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-nextjs/EXAMPLES.md
Set the `GASKET_DEV=1` environment variable to start the development server when using a custom server setup. This is typically used with `npm run local`.
```bash
# Start development server when using Custom Server
GASKET_DEV=1 npm run local
```
--------------------------------
### Install @gasket/plugin-docs
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-docs/README.md
Install the plugin using npm. Then, update your gasket.js file to include the plugin in the plugins array.
```bash
npm i @gasket/plugin-docs
```
```diff
// gasket.js
+ import pluginDocs from '@gasket/plugin-docs';
export default makeGasket({
plugins: [
+ pluginDocs
]
});
```
--------------------------------
### Basic Gasket Plugin Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-middleware/EXAMPLES.md
Demonstrates the basic setup for a Gasket application by importing and registering core plugins like Express and Middleware.
```javascript
// gasket.js
import { makeGasket } from '@gasket/core';
import pluginMiddleware from '@gasket/plugin-middleware';
import pluginExpress from '@gasket/plugin-express';
export default makeGasket({
plugins: [
pluginExpress,
pluginMiddleware
]
});
```
--------------------------------
### Add Custom Server Entry Point
Source: https://github.com/godaddy/gasket/blob/main/docs/upgrade-to-7.md
Create a server.js file to initiate the Gasket server with Next.js.
```js
import gasket from './gasket.js';
gasket.actions.startServer();
```
--------------------------------
### Get Logger Instance using Action
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-logger/EXAMPLES.md
Retrieve the logger instance that was initialized during Gasket setup using the getLogger action.
```javascript
// Using the action
const logger = gasket.actions.getLogger();
logger.info('Application started');
logger.error('Something went wrong');
```
--------------------------------
### Basic Plugin Setup
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-plugin-webpack/EXAMPLES.md
Set up the Gasket core with the webpack plugin.
```javascript
import { makeGasket } from '@gasket/core';
import pluginWebpack from '@gasket/plugin-webpack';
export default makeGasket({
plugins: [
pluginWebpack
]
});
```
--------------------------------
### Combine Locale and Message Providers
Source: https://github.com/godaddy/gasket/blob/main/packages/gasket-nextjs/EXAMPLES.md
This example shows how to combine `withLocaleInitialProps` with `withMessagesProvider` and `IntlProvider` for comprehensive internationalization setup in `_app.js`.
```jsx
// pages/_app.js
import { withLocaleInitialProps } from '@gasket/nextjs';
import { withMessagesProvider } from '@gasket/react-intl';
import { IntlProvider } from 'react-intl';
import intlManager from '../path/to/intl.js';
import gasket from '../gasket.js';
const IntlMessagesProvider = withMessagesProvider(intlManager)(IntlProvider);
function MyApp({ Component, pageProps, locale }) {
return (
Locale: {locale}