Skip to content

Commit

Permalink
Merge pull request #163 from WildCodeSchool/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
rocambille authored Oct 11, 2024
2 parents e4a5939 + 2490644 commit 46132dc
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 46 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Open an issue](https://github.com/WildCodeSchool/create-js-monorepo/issues) if you have any request/feedback :)

## [7.1.1] - 2024-10-11

### Fixed

- Fixed error messages in server when client build doesn't exist.

- Removed mentions to out of date documentation https://wildcodeschool-js-monorepo.vercel.app/.

## [7.1.0] - 2024-10-05

### Added
Expand Down
2 changes: 1 addition & 1 deletion bin/create-js-monorepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,5 @@ console.log(` ${i++}: ${bold(cyan(`npm run dev`))}`);

console.log(`\nUse ${bold(cyan("Ctrl-C"))} to halt the server.`);
console.log(
`\nStuck? Visit us at ${cyan("https://wildcodeschool-js-monorepo.vercel.app/")}`
`\nStuck? Visit us at ${cyan("https://github.com/wildcodeschool/create-js-monorepo/")}`
);
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@this-is-to-learn/create-js-monorepo",
"version": "7.1.0",
"version": "7.1.1",
"type": "module",
"description": "Our pedagogical framework for the React-Express-MySQL cursus in Wild Code School",
"homepage": "https://github.com/wildcodeschool/create-js-monorepo#readme",
Expand Down
2 changes: 1 addition & 1 deletion template/README.template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# {{name}}

Ce projet est un monorepo JS, suivant l'architecture React-Express-MySQL telle qu'enseignée à la Wild Code School (v7.1.0) :
Ce projet est un monorepo JS, suivant l'architecture React-Express-MySQL telle qu'enseignée à la Wild Code School (v7.1.1) :

```mermaid
sequenceDiagram
Expand Down
3 changes: 1 addition & 2 deletions template/client/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ header {

.navbar ul {
display: flex;
justify-content: end;
gap: 1rem;
list-style: none;
}
Expand All @@ -49,9 +50,7 @@ header {
color: #eee;
display: flex;
gap: 0.5rem;
justify-content: end;
align-items: center;
margin-top: auto;
}

.navbar a:hover {
Expand Down
32 changes: 1 addition & 31 deletions template/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,6 @@ function App() {

<nav className="navbar">
<ul>
<li>
<a
href="https://wildcodeschool-js-monorepo.vercel.app/"
target="_blank"
rel="noopener noreferrer"
>
<svg
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
width="30"
height="30"
viewBox="0 0 50 50"
>
<path
d="M37,4H13c-4.963,0-9,4.037-9,9v24c0,4.963,4.037,9,9,9h24c4.963,0,9-4.037,9-9V13C46,8.037,41.963,4,37,4z M14,15h18 c0.553,0,1,0.447,1,1c0,0.553-0.447,1-1,1H14c-0.553,0-1-0.447-1-1S13.447,15,14,15z M44,17.171 c-1.796,2.942-10.193,16.435-13.717,17.497L29.4,36.435c-0.175,0.351-0.528,0.553-0.896,0.553c-0.15,0-0.303-0.034-0.446-0.105 c-0.174-0.087-0.296-0.227-0.391-0.382c-0.906,0.334-1.853,0.483-2.647,0.487c-1.603-0.004-2.621-0.697-3.404-1.265 C20.979,35.261,20.59,35,20,35c-0.562,0-0.978,0.239-1.663,0.661C17.369,36.258,16.165,37,14,37c-0.553,0-1-0.447-1-1s0.447-1,1-1 c1.598,0,2.419-0.506,3.288-1.041C18.053,33.487,18.844,33,20,33c1.267,0,2.075,0.586,2.789,1.104 c0.682,0.493,1.22,0.884,2.201,0.884c0.007,0,0.013,0,0.02,0c1.253-0.006,2.914-0.486,3.635-1.518l0.1-0.2 c-0.134-1.062,0.159-2.55,0.73-4.27H14c-0.553,0-1-0.447-1-1s0.447-1,1-1h16.213c0.518-1.287,1.136-2.643,1.799-4H14 c-0.553,0-1-0.447-1-1s0.447-1,1-1h19.018c1.724-3.332,3.554-6.448,4.637-8.266c1.922,1.762,4.808,3.214,6.345,3.746V17.171z M44,14.596c-1.874-0.778-4.654-2.589-5.664-3.501V9.681l1.798-2.931C42.423,7.903,44,10.268,44,13V14.596z"
fill="#eee"
/>
</svg>
Documentation
</a>
</li>
<li>
<a
href="https://github.com/WildCodeSchool/create-js-monorepo"
Expand Down Expand Up @@ -63,14 +40,7 @@ function App() {
<h2 className="block-primary-main">JS Monorepo</h2>
<p className="block-primary-sub">Votre framework JavaScript</p>
</hgroup>
<a
href="https://wildcodeschool-js-monorepo.vercel.app/"
className="btn btn-white btn-animated"
target="_blank"
rel="noopener noreferrer"
>
Documentation
</a>
<p>Vous avez lu le README ?</p>
</main>

<footer>
Expand Down
31 changes: 31 additions & 0 deletions template/package-lock.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,15 @@
"integrity": "sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==",
"dev": true
},
"node_modules/@types/cors": {
"version": "2.8.17",
"resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
"integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/estree": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
Expand Down Expand Up @@ -3304,6 +3313,18 @@
"integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==",
"dev": true
},
"node_modules/cors": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/cosmiconfig": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-9.0.0.tgz",
Expand Down Expand Up @@ -6257,6 +6278,14 @@
"node": ">=4"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.13.2",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.2.tgz",
Expand Down Expand Up @@ -8191,12 +8220,14 @@
"server": {
"name": "@js-monorepo/server",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.0",
"mysql2": "^3.11.3"
},
"devDependencies": {
"@faker-js/faker": "^9.0.3",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.13",
"@types/supertest": "^6.0.2",
Expand Down
21 changes: 13 additions & 8 deletions template/server/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,30 @@ app.use(router);
// - Serving client static files from the server, which is useful when building a single-page application with React.
// - Redirecting unhandled requests (e.g., all requests not matching a defined API route) to the client's index.html. This allows the client to handle client-side routing.

import fs from "node:fs";
import path from "node:path";

// Serve server resources

const publicFolderPath = path.join(__dirname, "../../server/public");

app.use(express.static(publicFolderPath));
if (fs.existsSync(publicFolderPath)) {
app.use(express.static(publicFolderPath));
}

// Serve react resources
// Serve client resources

const reactBuildPath = path.join(__dirname, "../../client/dist");
const clientBuildPath = path.join(__dirname, "../../client/dist");

app.use(express.static(reactBuildPath));
if (fs.existsSync(clientBuildPath)) {
app.use(express.static(clientBuildPath));

// Redirect unhandled requests to the react index file
// Redirect unhandled requests to the client index file

app.get("*", (_, res) => {
res.sendFile("index.html", { root: reactBuildPath });
});
app.get("*", (_, res) => {
res.sendFile("index.html", { root: clientBuildPath });
});
}

/* ************************************************************************* */

Expand Down

0 comments on commit 46132dc

Please sign in to comment.