@gasket/template-nextjs-express 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 +125 -0
- package/template/components/head.tsx +13 -0
- package/template/gasket.ts +42 -0
- package/template/intl.ts +22 -0
- package/template/locales/en-US.json +5 -0
- package/template/locales/fr-FR.json +5 -0
- package/template/next-env.d.ts +6 -0
- package/template/next.config.js +4 -0
- package/template/package-lock.json +27228 -0
- package/template/package.json +92 -0
- package/template/pages/_app.tsx +22 -0
- package/template/pages/_document.ts +4 -0
- package/template/pages/index.tsx +21 -0
- package/template/server.ts +4 -0
- package/template/test/index.test.tsx +19 -0
- package/template/tsconfig.json +47 -0
- package/template/tsconfig.server.json +33 -0
- package/template/vitest.config.js +13 -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-nextjs-express",
|
|
3
|
+
"version": "0.0.0-canary-20250922153852",
|
|
4
|
+
"description": "Gasket Next.js Pages Router template with Express",
|
|
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-nextjs-express",
|
|
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,125 @@
|
|
|
1
|
+
# {{{appName}}}
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This application is built with [Gasket] and [Next.js] utilizing [EcmaScript Modules] and requires Node.js v20 or higher.
|
|
6
|
+
|
|
7
|
+
## Getting Started
|
|
8
|
+
|
|
9
|
+
### Development
|
|
10
|
+
|
|
11
|
+
To start the app 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=express:* npm run local // express 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
|
+
### Page Router
|
|
43
|
+
|
|
44
|
+
This Gasket app uses Next.js 14 with [Page Router] which relies on the traditional file-based routing within the pages directory. The integration with Next.js 14 leverages features like server-side rendering and static optimization, providing a streamlined development process and ensuring the app remains efficient and scalable.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Custom Server
|
|
49
|
+
|
|
50
|
+
This Gasket app uses Next.js 14 Page Router with a [Custom Server] implementation. The Custom Server allows for more control over the server environment, enabling advanced features like custom routing, middleware, and server-side rendering. This integration enhances development by providing a flexible and scalable solution for building web applications.
|
|
51
|
+
|
|
52
|
+
### TypeScript & Custom Server
|
|
53
|
+
|
|
54
|
+
This Gasket app uses TypeScript with Next.js and a [Custom Server] for enhanced type safety and flexibility. A separate `tsc` process and `tsconfig.server` file are necessary to compile TypeScript code for the custom server and additional files. It’s essential to include root-level Gasket files in the Next.js TypeScript build and configure TypeScript aliases in the Next.js application to correctly import these Gasket TypeScript files into the Next.js application code. This setup ensures that all TypeScript code integrates smoothly and maintains strong type checking.
|
|
55
|
+
|
|
56
|
+
### Aliases
|
|
57
|
+
|
|
58
|
+
In Gasket apps that use TypeScript with Next.js [Page Router] and [Custom Server], it’s essential to configure TypeScript aliases to import Gasket TypeScript files correctly. The use-cases are as follows:
|
|
59
|
+
|
|
60
|
+
- `tsconfig.json` - Aliases for importing root-level Gasket files into application code.
|
|
61
|
+
|
|
62
|
+
Here is an example TypeScript plugin:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// plugins/my-cool-plugin.ts
|
|
66
|
+
export default {
|
|
67
|
+
name: 'my-cool-plugin',
|
|
68
|
+
hooks: {
|
|
69
|
+
// hooks
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Import the TypeScript plugin in the `gasket.ts`:
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
// gasket.ts
|
|
78
|
+
import { makeGasket } from '@gasket/core';
|
|
79
|
+
import myCoolPlugin from './plugins/my-cool-plugin.ts';
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
The expectation would that the above import should work correctly but it does not. The absolute path import is not compiled or changes by the TypeScript compiler. The extensions are never changed and the cannot be left out due to the constraints with ESM.
|
|
83
|
+
|
|
84
|
+
Import the TypeScript plugin in the `gasket.ts` using the `.js` extension:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
// gasket.ts
|
|
88
|
+
import { makeGasket } from '@gasket/core';
|
|
89
|
+
import myCoolPlugin from './plugins/my-cool-plugin.js';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This workaround allows TypeScript to resolve the `.ts` file to the `.js` file at runtime. The relative paths in the compiled `.js` files resolve correctly.
|
|
93
|
+
|
|
94
|
+
An example of importing a Gasket TypeScript file into Next.js application code:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
// index.tsx
|
|
98
|
+
import gasket from '@/gasket'; // preconfigured TypeScript alias
|
|
99
|
+
|
|
100
|
+
export default function Home() {
|
|
101
|
+
return (
|
|
102
|
+
<div>
|
|
103
|
+
<h1>{gasket.config.coolValue}</h1>
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
For `.ts` Gasket files that need to be used in NextJS application code, be sure to configure the appropriate TypeScript aliases in the `tsconfig.json` file.
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
### Docusaurus
|
|
113
|
+
|
|
114
|
+
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.
|
|
115
|
+
|
|
116
|
+
<!-- LINKS -->
|
|
117
|
+
[Gasket]: https://gasket.dev
|
|
118
|
+
[Next.js]: https://nextjs.org
|
|
119
|
+
[EcmaScript Modules]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
120
|
+
[tsx]: https://tsx.is/
|
|
121
|
+
[@gasket/plugin-typescript]: https://gasket.dev/docs/plugins/plugin-typescript/
|
|
122
|
+
[Gasket TypeScript]: https://gasket.dev/docs/typescript/
|
|
123
|
+
[Custom Server]: https://nextjs.org/docs/pages/building-your-application/configuring/custom-server
|
|
124
|
+
[Page Router]: https://nextjs.org/docs/pages
|
|
125
|
+
[Docusaurus]: https://docusaurus.io/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import NextHead from 'next/head.js';
|
|
3
|
+
|
|
4
|
+
const Head = ({ title, description }) => (
|
|
5
|
+
<NextHead>
|
|
6
|
+
<meta charSet='UTF-8'/>
|
|
7
|
+
<title>{title}</title>
|
|
8
|
+
<meta name='description' content={ description }/>
|
|
9
|
+
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'/>
|
|
10
|
+
</NextHead>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default Head;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 pluginLogger from '@gasket/plugin-logger';
|
|
6
|
+
import pluginWebpack from '@gasket/plugin-webpack';
|
|
7
|
+
import pluginWinston from '@gasket/plugin-winston';
|
|
8
|
+
import pluginHttps from '@gasket/plugin-https';
|
|
9
|
+
import pluginExpress from '@gasket/plugin-express';
|
|
10
|
+
import pluginNextjs from '@gasket/plugin-nextjs';
|
|
11
|
+
import pluginIntl from '@gasket/plugin-intl';
|
|
12
|
+
|
|
13
|
+
export default makeGasket({
|
|
14
|
+
plugins: [
|
|
15
|
+
pluginCommand,
|
|
16
|
+
pluginDynamicPlugins,
|
|
17
|
+
pluginLogger,
|
|
18
|
+
pluginWebpack,
|
|
19
|
+
pluginWinston,
|
|
20
|
+
pluginHttps,
|
|
21
|
+
pluginExpress,
|
|
22
|
+
pluginNextjs,
|
|
23
|
+
pluginIntl
|
|
24
|
+
],
|
|
25
|
+
commands: {
|
|
26
|
+
docs: {
|
|
27
|
+
dynamicPlugins: [
|
|
28
|
+
'@gasket/plugin-docs',
|
|
29
|
+
'@gasket/plugin-metadata',
|
|
30
|
+
'@gasket/plugin-docusaurus'
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
intl: {
|
|
35
|
+
locales: [
|
|
36
|
+
'en-US',
|
|
37
|
+
'fr-FR'
|
|
38
|
+
],
|
|
39
|
+
defaultLocale: 'en-US',
|
|
40
|
+
managerFilename: 'intl.ts'
|
|
41
|
+
}
|
|
42
|
+
} as GasketConfigDefinition);
|
package/template/intl.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/* -- GENERATED FILE - DO NOT EDIT -- */
|
|
2
|
+
import { makeIntlManager } from '@gasket/intl';
|
|
3
|
+
import type { LocaleManifest } from '@gasket/intl';
|
|
4
|
+
|
|
5
|
+
const manifest: LocaleManifest = {
|
|
6
|
+
defaultLocaleFilePath: 'locales',
|
|
7
|
+
staticLocaleFilePaths: [
|
|
8
|
+
'locales'
|
|
9
|
+
],
|
|
10
|
+
defaultLocale: 'en-US',
|
|
11
|
+
locales: [
|
|
12
|
+
'en-US',
|
|
13
|
+
'fr-FR'
|
|
14
|
+
],
|
|
15
|
+
localesMap: {},
|
|
16
|
+
imports: {
|
|
17
|
+
'locales/en-US': () => import('./locales/en-US.json'),
|
|
18
|
+
'locales/fr-FR': () => import('./locales/fr-FR.json')
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default makeIntlManager(manifest);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="next" />
|
|
2
|
+
/// <reference types="next/image-types/global" />
|
|
3
|
+
/// <reference path="./.next/types/routes.d.ts" />
|
|
4
|
+
|
|
5
|
+
// NOTE: This file should not be edited
|
|
6
|
+
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.
|