hoosat-create 1.5.2 → 1.6.0

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.
Files changed (2) hide show
  1. package/README.md +228 -169
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,169 +1,228 @@
1
- # Hoosat Create
2
-
3
- Hoosat create is a `npx` script that creates React 19 full-stack server side rendering ESM project for you, where you can use Typescript to build web applications. It uses [@TMCKodes/hoosat-template](https://github.com/TMKCodes/hoosat-template) to build React project with SSR and Typescript.
4
-
5
- ## Requirements
6
-
7
- Node.js 22, 24 or 26 (any supported LTS line). Node.js 20 and older are end-of-life and not supported. Git is needed for cloning the template.
8
-
9
- ## Command to run
10
-
11
- ```
12
- npx hoosat-create@latest
13
- ```
14
-
15
- ### Commandline arguments
16
- - `submodule`
17
- - `--destination`
18
- - `--author`
19
- - `--license`
20
- - `--keywords`
21
- - `--keywoordsList`
22
- - `--gitInit`
23
-
24
- For example:
25
-
26
- ```
27
- npx hoosat-create@latest --destination "new_project" --author "Toni Lukkaroinen" --gitInit Y
28
- ```
29
-
30
- Now it will ask the rest like `license` in the process. Which you can default just by pressing enter.
31
-
32
- ### Submodule creation
33
-
34
- The following command creates an empty git submodule for you to start working on code that will be shared with another project later.
35
- ```
36
- npx hoosat-create@latest submodule --destination "src/client/submodule"
37
- ```
38
-
39
- ## Technologies Used
40
-
41
- - React 19
42
- - React Router 8
43
- - React-helmet-async 3
44
- - i18next 27 / react-i18next 18
45
- - TypeScript 6
46
- - Webpack 5
47
- - Jest 30
48
-
49
- ## Features
50
-
51
- - Full-stack TypeScript application using React and Node HTTP/HTTPS.
52
- - Includes working server side SEO with `react-helmet-async`
53
- - Supports ES modules for server-side and client-side ```.
54
- - Configured with Webpack for production builds.
55
- - Includes Jest for unit testing.
56
- - Includes example components and routes for getting started.
57
-
58
- ## Scripts
59
-
60
- - `npm run dev`: Builds and runs the development version.
61
- - This script concurrently executes the following commands:
62
- - `npm run dev:build:client`: Builds the client in development mode and watches for file changes.
63
- - `npm run dev:build:server`: Builds the server in development mode and watches for file changes.
64
- - `npm run dev:run`: Starts the server with Nodemon to automatically restart it on file changes.
65
-
66
- - `npm run build`: Builds the production version.
67
- - This script sequentially executes the following commands:
68
- - `npm run build:client`: Builds the client in production mode.
69
- - `npm run build:server`: Builds the server in production mode.
70
-
71
- - `npm run start`: Runs the production version.
72
- - This script starts the server using the compiled production files.
73
-
74
- - `npm run test`: Runs test units with Jest.
75
- - This script executes the test units using Jest.
76
-
77
- ## File structure
78
-
79
- - `src/client`: Contains client-side ``` (React components, styles, etc.).
80
- - `src/server`: Contains server-side ``` (Node HTTP/HTTPS routes, API routes, etc.).
81
- - `src/common`: Contains common ```.
82
- - `public`: Contains the bundle.js client ``` and public files for the project.
83
- - `dist`: Contains production build output of server.
84
-
85
- ## Node HTTP/HTTP server with server side router.
86
-
87
- `src/server/core/server.ts` contains the source ```, it supports middlewares, wildcard routes and specific routes. There are middlewares currently for setting cors and static files.
88
-
89
- ### Basic example
90
-
91
- ```
92
- import { createRouter, createServer, listen } from './core/server';
93
- import { cors } from './core/cors';
94
- import { assets } from './core/assets';
95
- // Creating the router
96
- const router = createRouter();
97
-
98
- // Adding static file middleware
99
- router.Middleware(assets("./public"));
100
-
101
- // Creating a ping route
102
- // For request and response we dont use wrappers for node http types and methods.
103
- router.Get("/ping", (req: HoosatRequest, res: HoosatResponse) => {
104
- res.status(200).json("pong!");
105
- });
106
-
107
- // Now that the middleware and routes have been set the server must be created that handles the routes.
108
- const server = createServer(router);
109
-
110
- // Start listening on port 3000
111
- const port = parseInt(process.env.PORT || "8080");
112
- listen(server, port, () => {
113
- console.log(`Server is running on port ${port.toString()}`);
114
- });
115
- ```
116
-
117
-
118
- ## License
119
- This template is licensed under the ISC License. Feel free to use it for your own projects or as a starting point for your own templates.
120
-
121
- ## Message
122
-
123
- I just dropped some dependancies from the repository and this will keep happening. With our own ``` we can keep it up to date with React and Node versions more easily.
124
- Though for now the only goal seems to be to drop `react-helmet-async`.
125
-
126
- ## Release changes
127
-
128
- ### 1.5.0 -> 1.5.1
129
- - Remove HoosatUI from the stack. The CLI no longer asks to install it, and `--hoosatui` is ignored with a warning.
130
- - Template: drop the unused `react-markdown`, `rehype-highlight` and `remark-gfm` dependencies and the HoosatUI special case in the CSS build.
131
-
132
- ### 1.4.7 -> 1.5.0
133
- - Requires Node.js 22 or newer (Node.js 20 is end-of-life), template is tested on Node.js 22, 24 and 26.
134
- - Clone the template and its submodule over HTTPS, so no GitHub SSH key is needed.
135
- - Run git and npm without a shell and with argument lists, so project names can not be interpreted as shell commands.
136
- - Fix `--gitInit n` and `--hoosatui n` being treated as yes.
137
- - Stop when cloning the template fails instead of continuing in the wrong directory.
138
- - Fix `submodule` command on Windows and with git 2.38.1+.
139
- - Template: React 19, React Router 8, TypeScript 6, Jest 30, i18next 27, security fixes in server core and all dependency vulnerabilities resolved.
140
-
141
- ### 1.4.5 -> 1.4.6
142
- - Use submodule for server, make cloning of template recursive.
143
-
144
- ### 1.4.4 -> 1.4.5
145
- - One small document change in server code example, to make your life easier.
146
- - Add support for command line arguments.
147
- - Add support for npx hoosat-create submodule
148
-
149
- ### 1.4.3 -> 1.4.4
150
- - Why the heck I removed that #!/usr/bin/env node.. Now it's back.
151
-
152
- ### 1.4.2 -> 1.4.3
153
- - Update package.json to contain metadata
154
-
155
- ### 1.4.1 -> 1.4.2
156
- - Remove download-git-repo dependancy from hoosat-create
157
- - Do input validation in hoosat-create. Which means following characters do not work in project name.
158
- - ';', '|', '&&', '>', '<', '`', '$(', '$()'
159
-
160
- ### 1.4.0 -> 1.4.1
161
- - Changed createServer to include options argument for changing server protocol and to include SSL certificate information.
162
- - JSDoc has been added and more documentation work.
163
-
164
- ### 1.3.5 -> 1.4.0
165
- - Dropped Express.js and Babel from dependancies.
166
- - Updated package.json scripts to use concurrently and nodemon.
167
-
168
- ## Join us
169
- [https://discord.gg/UXPFcPaPBg](Discord)
1
+ # Hoosat Create
2
+
3
+ **React server rendering, without the framework.**
4
+
5
+ Hoosat Create scaffolds a full-stack React and TypeScript app that streams HTML from a small, dependency-light Node.js server. No Express, no magic, just code you can read and own.
6
+
7
+ ```
8
+ npx hoosat-create@latest
9
+ ```
10
+
11
+ [Website](https://create.hoosat.fi) · [Tutorial](https://create.hoosat.fi/tutorial) · [Template](https://github.com/TMKCodes/hoosat-template) · [Server core](https://github.com/TMKCodes/hoosat-server-core) · [npm](https://www.npmjs.com/package/hoosat-create) · [Discord](https://discord.gg/UXPFcPaPBg)
12
+
13
+ | | |
14
+ |---|---|
15
+ | **1** | command to a running SSR app |
16
+ | **0** | Express or Babel dependencies |
17
+ | **3** | precompressed formats: br, gzip, deflate |
18
+ | **100%** | TypeScript, build tools included |
19
+
20
+ ## Quick start
21
+
22
+ You need **Node.js 22, 24 or 26** and **git**. Node.js 20 and older are end-of-life, and the build tools are TypeScript files that only current Node.js can run directly.
23
+
24
+ ```
25
+ $ npx hoosat-create@latest
26
+ Creating a new project from Hoosat React SSR Template.
27
+ Enter destination project name: my-site
28
+ Do you want to initialize a git repository? [Y/n] y
29
+ Project cloned successfully.
30
+ Project template dependencies installed with npm.
31
+ $ cd my-site && npm run dev
32
+ Server is running on port 8181
33
+ ```
34
+
35
+ Open http://localhost:8181. The port comes from `PORT` in `.env`.
36
+
37
+ The script clones [hoosat-template](https://github.com/TMKCodes/hoosat-template) over HTTPS together with the [hoosat-server-core](https://github.com/TMKCodes/hoosat-server-core) submodule, writes your details into `package.json`, runs `npm install` and can initialise a fresh git repository for you.
38
+
39
+ For the full walkthrough, from an empty folder to a deployed site, read the [tutorial](https://create.hoosat.fi/tutorial). It is exactly how [create.hoosat.fi](https://create.hoosat.fi) was built.
40
+
41
+ ### Command line arguments
42
+
43
+ Every question can be answered up front. Anything you leave out is asked interactively, and you can press Enter to leave it empty.
44
+
45
+ | Argument | Sets |
46
+ |---|---|
47
+ | `--destination` | Project folder and `package.json` name |
48
+ | `--description` | `package.json` description |
49
+ | `--author` | `package.json` author |
50
+ | `--license` | `package.json` license |
51
+ | `--keywords` | `package.json` keywords, comma-separated |
52
+ | `--gitInit` | Initialise a git repository: `Y` or `n` |
53
+
54
+ ```
55
+ npx hoosat-create@latest --destination my-site --author "Your Name" --license MIT --gitInit Y
56
+ ```
57
+
58
+ Values containing `;`, `|`, `&&`, `>`, `<`, `` ` `` or `$(` are rejected, and git and npm are run without a shell, so a project name can never be run as a command.
59
+
60
+ ### Create a submodule
61
+
62
+ Inside an existing git repository, this creates an empty git repository at the destination and registers it as a submodule, ready for code you want to share with other projects later:
63
+
64
+ ```
65
+ npx hoosat-create@latest submodule --destination src/client/submodule
66
+ ```
67
+
68
+ ## Client and server, kept apart
69
+
70
+ Many React frameworks fuse server and client code into the same files with server components, loaders and server actions, and decide at build time what runs where. In Hoosat Create, **the folder decides**.
71
+
72
+ | Folder | Runs in | What lives there |
73
+ |---|---|---|
74
+ | `src/client` | Browser | Your React app: pages, components and CSS. Bundled for the browser, starting from `src/client/index.tsx`. |
75
+ | `src/server` | Node.js | Your own HTTP server: middlewares, API routes and rendering. Bundled into `build/server.js`, starting from `src/server/index.tsx`. |
76
+
77
+ Two webpack configs, two bundles and no `"use client"` or `"use server"` directives. You always know what ships to the browser.
78
+
79
+ ## Features
80
+
81
+ The template is a starting point you copy, not a framework you depend on. Every feature below is plain code in your repository.
82
+
83
+ - **Streaming SSR.** Pages render with React 19's `renderToPipeableStream`, so the browser gets real HTML first and then hydrates it into an interactive app.
84
+ - **A router you can read.** The server core is a few hundred lines of TypeScript on Node's `http` and `https` modules: middlewares, `:params`, wildcards and composable routers.
85
+ - **SEO in the first bytes.** Titles, meta, Open Graph and JSON-LD written with `react-helmet-async` are streamed into the `<head>`, so crawlers see them without running JavaScript.
86
+ - **Precompressed assets.** The build writes Brotli, gzip and deflate copies of every public file. The server picks one by `Accept-Encoding` and sets long cache headers.
87
+ - **TypeScript everywhere.** Strict TypeScript 6 for client and server code. Even the build tools are `.ts` files that Node runs directly with type stripping.
88
+ - **Built-in i18n.** i18next and react-i18next are wired in on both the server and the client.
89
+ - **Secure defaults.** A Content-Security-Policy header with a nonce, path traversal safe static files, and an `.npmrc` that only installs package versions that have been public for 7 days.
90
+ - **Tests from day one.** Jest 30 and Testing Library come configured, with example tests for the server core.
91
+ - **Fast dev loop.** `npm run dev` rebuilds the client and the server whenever you save and restarts the server with nodemon, so changes show up in seconds.
92
+
93
+ ## How a request becomes a page
94
+
95
+ One request through the stack, from socket to interactive page. Each step is a file you can open.
96
+
97
+ 1. **Request.** Node's `http` or `https` server accepts the request, and the URL is sanitised against path traversal.
98
+ 2. **Middlewares.** Middlewares run in order, for example CORS, file uploads and precompressed static files.
99
+ 3. **Routes.** API routes such as `/api/ping/:id` answer directly. Everything else falls through to the `*` route.
100
+ 4. **React render.** The `*` route renders `<App />` inside a `StaticRouter` and streams it to the client.
101
+ 5. **Head injection.** A transform stream writes Helmet tags, preload links and the bundles into the `<head>` while the HTML streams out.
102
+ 6. **Hydration.** In the browser `hydrateRoot` attaches React to the existing markup. From here on, navigation happens on the client.
103
+
104
+ ## Your server is just a file
105
+
106
+ `src/server/index.tsx` is the whole server. Middlewares and routes are plain functions:
107
+
108
+ ```tsx
109
+ import { createRouter, createServer, listen } from './core/server';
110
+ import { assets } from './core/assets';
111
+ import { renderer } from './core/renderer';
112
+
113
+ const router = createRouter();
114
+
115
+ // Middlewares run in order, before any route.
116
+ router.Middleware(assets(publicDir));
117
+
118
+ // API routes answer directly.
119
+ router.Get("/api/hello/:name", (req, res) => {
120
+ res.status(200).json({ message: "Hello, " + req.params!["name"] });
121
+ });
122
+
123
+ // Every other GET request is a React page.
124
+ router.Get("*", async (req, res) => {
125
+ renderer({ res, jsx: <App url={req.url} />, publicDir });
126
+ });
127
+
128
+ listen(createServer(router), 8181, () => console.log("Ready"));
129
+ ```
130
+
131
+ Path parameters are in `req.params`, and `res.status()`, `res.send()` and `res.json()` cover most responses. Group routes with `createRouter()` and mount them with `router.UseRouter()`.
132
+
133
+ ## Project layout
134
+
135
+ ```
136
+ my-site/
137
+ ├── public/ static files, copied into the build
138
+ ├── src/
139
+ │ ├── client/ React app: App.tsx, routes/, components, *.css
140
+ │ ├── server/
141
+ │ │ ├── api-routes/ your API endpoints
142
+ │ │ ├── core/ hoosat-server-core (git submodule)
143
+ │ │ └── index.tsx the server itself
144
+ │ └── __tests__/ Jest tests
145
+ ├── build-tools/ TypeScript build helpers run by Node
146
+ ├── webpack.client.config.js
147
+ └── webpack.server.config.js
148
+ ```
149
+
150
+ `src/server/core` is a git submodule shared by every Hoosat project. Update it with `git submodule update --remote` instead of editing it in place.
151
+
152
+ Plain `.css` files anywhere under `src/client` are merged and minified into `/public/styles.css`, which the renderer links in every page. No imports needed.
153
+
154
+ ## Scripts
155
+
156
+ | Command | What it does |
157
+ |---|---|
158
+ | `npm run dev` | Builds into `build-dev`, starts the server and rebuilds whenever a file in `src` or `public` changes |
159
+ | `npm run build` | Production build into `build`, including precompressed copies of every asset |
160
+ | `npm start` | Runs the production server from `build/server.js` |
161
+ | `npm test` | Runs the Jest tests |
162
+ | `npm run typecheck` | Type checks the whole project with `tsc --noEmit` |
163
+
164
+ Webpack bundles the server and its dependencies into `build/server.js`, so production only needs the `build` folder. Put it behind a reverse proxy such as Caddy or nginx for TLS, or run it as a container.
165
+
166
+ ## Current, boring, supported
167
+
168
+ Every dependency is on its latest major release, and the template is tested on all supported Node.js LTS lines.
169
+
170
+ | | |
171
+ |---|---|
172
+ | React | 19 |
173
+ | React Router | 8 |
174
+ | TypeScript | 6 |
175
+ | react-helmet-async | 3 |
176
+ | i18next | 27 |
177
+ | Webpack | 5 |
178
+ | Jest | 30 |
179
+ | Node.js | 22 · 24 · 26 |
180
+
181
+ ## Release changes
182
+
183
+ ### 1.5.0 -> 1.5.1
184
+ - Remove HoosatUI from the stack. The CLI no longer asks to install it, and `--hoosatui` is ignored with a warning.
185
+ - Template: drop the unused `react-markdown`, `rehype-highlight` and `remark-gfm` dependencies and the HoosatUI special case in the CSS build.
186
+
187
+ ### 1.4.7 -> 1.5.0
188
+ - Requires Node.js 22 or newer (Node.js 20 is end-of-life), template is tested on Node.js 22, 24 and 26.
189
+ - Clone the template and its submodule over HTTPS, so no GitHub SSH key is needed.
190
+ - Run git and npm without a shell and with argument lists, so project names can not be interpreted as shell commands.
191
+ - Fix `--gitInit n` and `--hoosatui n` being treated as yes.
192
+ - Stop when cloning the template fails instead of continuing in the wrong directory.
193
+ - Fix `submodule` command on Windows and with git 2.38.1+.
194
+ - Template: React 19, React Router 8, TypeScript 6, Jest 30, i18next 27, security fixes in server core and all dependency vulnerabilities resolved.
195
+
196
+ ### 1.4.5 -> 1.4.6
197
+ - Use submodule for server, make cloning of template recursive.
198
+
199
+ ### 1.4.4 -> 1.4.5
200
+ - One small document change in server code example, to make your life easier.
201
+ - Add support for command line arguments.
202
+ - Add support for `npx hoosat-create submodule`.
203
+
204
+ ### 1.4.3 -> 1.4.4
205
+ - Bring back the `#!/usr/bin/env node` line.
206
+
207
+ ### 1.4.2 -> 1.4.3
208
+ - Update package.json to contain metadata.
209
+
210
+ ### 1.4.1 -> 1.4.2
211
+ - Remove the `download-git-repo` dependency from hoosat-create.
212
+ - Validate input in hoosat-create. The following characters do not work in the project name: `;`, `|`, `&&`, `>`, `<`, `` ` ``, `$(`, `$()`
213
+
214
+ ### 1.4.0 -> 1.4.1
215
+ - Changed `createServer` to include an options argument for changing the server protocol and to include SSL certificate information.
216
+ - JSDoc has been added and more documentation work.
217
+
218
+ ### 1.3.5 -> 1.4.0
219
+ - Dropped Express.js and Babel from dependencies.
220
+ - Updated package.json scripts to use concurrently and nodemon.
221
+
222
+ ## License
223
+
224
+ The `hoosat-create` CLI is licensed under the [ISC License](LICENSE.txt). Use it for your own projects or as a starting point for your own templates.
225
+
226
+ ## Join us
227
+
228
+ Questions, ideas or something broken? Open an [issue](https://github.com/TMKCodes/hoosat-create/issues) or come talk on [Discord](https://discord.gg/UXPFcPaPBg).
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hoosat-create",
3
3
  "type": "module",
4
- "version": "1.5.2",
4
+ "version": "1.6.0",
5
5
  "description": "Hoosat - React & Typescript SSR project template.",
6
6
  "homepage": "https://example.com",
7
7
  "author": "Toni Lukkaroinen @ TMKCodes",