Skip to content

Commit 6ece36e

Browse files
committed
Implemented shared project.
1 parent 0632962 commit 6ece36e

18 files changed

+160
-45
lines changed
File renamed without changes.

Diff for: apps/backend/package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
"packageManager": "[email protected]",
77
"scripts": {
88
"build": "tsc",
9+
"clean": "rimraf ./dist",
910
"dev": "run-p dev:tsc dev:node",
1011
"dev:node": "node --watch ./dist/main.js",
1112
"dev:tsc": "tsc --watch --preserveWatchOutput"
1213
},
1314
"dependencies": {
14-
"@picocss/pico": "^1.5.6",
15+
"@picocss/pico": "1.5.6",
1516
"@types/express": "4.17.16",
1617
"cors": "2.8.5",
17-
"express": "4.18.2"
18+
"express": "4.18.2",
19+
"hotel-management-shared": "workspace:libs/shared"
1820
},
1921
"devDependencies": {
20-
"@types/cors": "^2.8.13",
21-
"sass": "^1.57.1"
22+
"@types/cors": "2.8.13"
2223
}
2324
}

Diff for: apps/backend/src/main.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from "node:fs/promises";
22
import cors from "cors";
33
import express from "express";
4+
import { type Hotel } from "hotel-management-shared";
45

56
const packageJson = JSON.parse(await fs.readFile("./package.json", "utf-8"));
67

@@ -10,7 +11,11 @@ const PORT = 3000;
1011
const app = express();
1112
app.use(cors());
1213

13-
const hotels = ["City Centre", "Messe", "Westend"];
14+
const hotels: Hotel[] = [
15+
{ id: 1, name: "City Centre" },
16+
{ id: 2, name: "Messe" },
17+
{ id: 3, name: "Westend" },
18+
];
1419

1520
app.get("/hotels", (request, response) => {
1621
response.send(JSON.stringify(hotels));

Diff for: apps/backend/tsconfig.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"module": "node16",
5+
"rootDir": "./src",
56
"outDir": "./dist"
6-
}
7+
},
8+
"include": ["src/**/*"],
9+
"references": [{ "path": "../../libs/shared/tsconfig.json" }]
710
}

Diff for: apps/backend/tsconfig.tsbuildinfo

+1
Large diffs are not rendered by default.

Diff for: apps/frontend/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "vite",
77
"build": "run-p type-check build-only",
8+
"clean": "rimraf ./dist",
89
"preview": "vite preview",
910
"test:unit": "vitest --environment jsdom --root src/",
1011
"test:e2e": "playwright test",
@@ -27,7 +28,9 @@
2728
"@vue/test-utils": "2.2.6",
2829
"@vue/tsconfig": "0.1.3",
2930
"eslint-plugin-vue": "9.3.0",
31+
"hotel-management-shared": "workspace:libs/shared",
3032
"jsdom": "20.0.3",
33+
"sass": "1.58.0",
3134
"vite": "4.0.0",
3235
"vitest": "0.25.6",
3336
"vue-tsc": "1.0.12"

Diff for: apps/frontend/src/components/HotelList.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<script setup lang="ts">
2+
import type { Hotel } from "hotel-management-shared";
3+
24
const props = defineProps<{
3-
hotels: string[];
5+
hotels: Hotel[];
46
}>();
57
</script>
68

79
<template>
810
<ul>
9-
<li v-for="hotel of props.hotels" :key="hotel">{{ hotel }}</li>
11+
<li v-for="hotel of props.hotels" :key="hotel.id">{{ hotel.name }}</li>
1012
</ul>
1113
</template>

Diff for: apps/frontend/tsconfig.json

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
{
2+
"extends": "../../tsconfig.json",
23
"files": [],
34
"references": [
4-
{
5-
"path": "./tsconfig.config.json"
6-
},
7-
{
8-
"path": "./tsconfig.app.json"
9-
},
10-
{
11-
"path": "./tsconfig.vitest.json"
12-
}
5+
{ "path": "./tsconfig.config.json" },
6+
{ "path": "./tsconfig.app.json" },
7+
{ "path": "./tsconfig.vitest.json" },
8+
{ "path": "../../libs/shared/tsconfig.json" }
139
]
1410
}

Diff for: libs/shared/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# shared

Diff for: libs/shared/package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "hotel-management-shared",
3+
"version": "0.0.0",
4+
"private": true,
5+
"type": "module",
6+
"packageManager": "[email protected]",
7+
"main": "dist/index.js",
8+
"types": "dist/index.d.ts",
9+
"scripts": {
10+
"build": "tsc",
11+
"clean": "rimraf ./dist",
12+
"dev": "run-p dev:tsc dev:node",
13+
"dev:node": "node --watch ./dist/main.js",
14+
"dev:tsc": "tsc --watch --preserveWatchOutput"
15+
}
16+
}

Diff for: libs/shared/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./models/Hotel.js";

Diff for: libs/shared/src/models/Hotel.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type Hotel = {
2+
id: number;
3+
name: string;
4+
};

Diff for: libs/shared/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"module": "node16",
5+
"rootDir": "./src",
6+
"outDir": "./dist"
7+
},
8+
"include": ["src/**/*"]
9+
}

Diff for: libs/shared/tsconfig.tsbuildinfo

+1
Large diffs are not rendered by default.

Diff for: notes.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
- `yarn`
77

88
- tsconfig.json in root directory.
9+
- `composite: true` to speed up compilation times.

Diff for: package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
"packageManager": "[email protected]",
88
"workspaces": [
99
"apps/frontend",
10-
"apps/backend"
10+
"apps/backend",
11+
"libs/shared"
1112
],
1213
"scripts": {
1314
"build": "yarn workspaces foreach run build",
15+
"clean": "yarn workspaces foreach run clean",
1416
"dev": "yarn workspaces foreach -pvi run dev",
1517
"lint": "eslint .",
1618
"lint:fix": "yarn lint --fix",
@@ -23,9 +25,11 @@
2325
"@typescript-eslint/parser": "5.49.0",
2426
"eslint": "8.22.0",
2527
"eslint-config-prettier": "8.6.0",
28+
"eslint-plugin-boundaries": "3.1.0",
2629
"eslint-plugin-prettier": "4.2.1",
2730
"npm-run-all": "4.1.5",
2831
"prettier": "2.7.1",
32+
"rimraf": "4.1.2",
2933
"typescript": "4.7.4"
3034
}
3135
}

Diff for: tsconfig.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"compilerOptions": {
3+
"composite": true,
34
"strict": true,
5+
"forceConsistentCasingInFileNames": true,
46
"esModuleInterop": true
57
}
68
}

0 commit comments

Comments
 (0)