hoosat-create 1.4.0 → 1.4.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 +44 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ npx hoosat-create@latest
|
|
|
20
20
|
|
|
21
21
|
- Full-stack TypeScript application using React and Node HTTP/HTTPS.
|
|
22
22
|
- Includes working server side SEO with `react-helmet-async`
|
|
23
|
-
- Supports ES modules for server-side and client-side
|
|
23
|
+
- Supports ES modules for server-side and client-side ```.
|
|
24
24
|
- Configured with Webpack for production builds.
|
|
25
25
|
- Includes Jest for unit testing.
|
|
26
26
|
- Includes example components and routes for getting started.
|
|
@@ -47,29 +47,63 @@ npx hoosat-create@latest
|
|
|
47
47
|
|
|
48
48
|
## File structure
|
|
49
49
|
|
|
50
|
-
- `src/client`: Contains client-side
|
|
51
|
-
- `src/server`: Contains server-side
|
|
52
|
-
- `src/common`: Contains common
|
|
53
|
-
- `public`: Contains the bundle.js client
|
|
50
|
+
- `src/client`: Contains client-side ``` (React components, styles, etc.).
|
|
51
|
+
- `src/server`: Contains server-side ``` (Node HTTP/HTTPS routes, API routes, etc.).
|
|
52
|
+
- `src/common`: Contains common ```.
|
|
53
|
+
- `public`: Contains the bundle.js client ``` and public files for the project.
|
|
54
54
|
- `dist`: Contains production build output of server.
|
|
55
55
|
|
|
56
|
+
## Node HTTP/HTTP server with server side router.
|
|
57
|
+
|
|
58
|
+
`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.
|
|
59
|
+
|
|
60
|
+
### Basic example
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
import { createRouter, createServer, listen } from './core/server';
|
|
64
|
+
import { cors } from './core/cors';
|
|
65
|
+
import { assets } from './core/assets';
|
|
66
|
+
// Creating the router
|
|
67
|
+
const router = createRouter();
|
|
68
|
+
|
|
69
|
+
// Adding static file middleware
|
|
70
|
+
router.Middleware(assets("./public"));
|
|
71
|
+
|
|
72
|
+
// Creating a ping route
|
|
73
|
+
// For request and response we dont use wrappers for node http types and methods.
|
|
74
|
+
router.Get("/ping", (req: IncomingMessage, res: ServerResponse) => {
|
|
75
|
+
res.writeHead(20, { 'Content-Type': "text/plain" });
|
|
76
|
+
res.end("pong!");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// Now that the middleware and routes have been set the server must be created that handles the routes.
|
|
80
|
+
const server = createServer(router);
|
|
81
|
+
|
|
82
|
+
// Start listening on port 3000
|
|
83
|
+
const port = parseInt(process.env.PORT || "8080");
|
|
84
|
+
listen(server, port, () => {
|
|
85
|
+
console.log(`Server is running on port ${port.toString()}`);
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
|
|
56
90
|
## License
|
|
57
91
|
This template is licensed under the MIT License. Feel free to use it for your own projects or as a starting point for your own templates.
|
|
58
92
|
|
|
59
93
|
## Message
|
|
60
94
|
|
|
61
|
-
I just dropped some dependancies from the repository and this will keep happening. With our own
|
|
95
|
+
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.
|
|
62
96
|
Though for now the only goal seems to be to drop `react-helmet-async`.
|
|
63
97
|
|
|
64
98
|
## Release changes
|
|
65
99
|
|
|
100
|
+
### 1.4.0 -> 1.4.1
|
|
101
|
+
- Changed createServer to include options argument for changing server protocol and to include SSL certificate information.
|
|
102
|
+
- JSDoc has been added and more documentation work.
|
|
103
|
+
|
|
66
104
|
### 1.3.5 -> 1.4.0
|
|
67
105
|
- Dropped Express.js and Babel from dependancies.
|
|
68
106
|
- Updated package.json scripts to use concurrently and nodemon.
|
|
69
107
|
|
|
70
108
|
## Join us
|
|
71
109
|
[https://discord.gg/UXPFcPaPBg](Discord)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|