Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist
node_modules
.env
*.tfvars
Expand Down
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ RUN pnpm install --frozen-lockfile

COPY . .

# Стили собираются на сборке образа: собранный css в гит не едет, а без него
# приложение отдавало бы страницы без оформления.
RUN pnpm run build

# Запуск через скрипт, а не через `pnpm start`: приложение слушает 3000, и на
# этот порт рассчитаны уроки курса docker_basics_course.
CMD ["bin/start.sh"]
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ compose:
compose-down:
docker compose down -v --remove-orphans

setup: env-prepare install
setup: env-prepare install build

install:
pnpm install --frozen-lockfile

build:
pnpm run build

start:
pnpm start

Expand Down
23 changes: 23 additions & 0 deletions __tests__/assets.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import fastify from "fastify";

import init from "../server/plugin.js";

// Сборка стилей проверяется прогоном: её отказ выглядит как успех, потому что
// main.css оказывается на месте, а классов из шаблонов в нём нет, и страница
// приходит без оформления.
describe("assets", () => {
let app;

beforeAll(async () => {
app = fastify();
await init(app);
});

it("отдаёт собранный css с классами из шаблонов", async () => {
const res = await app.inject({ method: "GET", url: "/assets/main.css" });

expect(res.statusCode).toBe(200);
expect(res.body).toMatch(".max-w-3xl");
expect(res.body).toMatch(".bg-red-50");
});
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"type": "module",
"main": "index.js",
"scripts": {
"build": "vite build",
"test": "vitest run",
"start": "bin/start.sh",
"lint": "oxlint --config=.oxlintrc.json .",
Expand All @@ -19,7 +20,6 @@
"@fastify/static": "^10.1.2",
"@fastify/view": "^12.0.0",
"@sentry/node": "^10.68.0",
"bootstrap": "^5.3.8",
"dotenv": "^17.4.2",
"fastify": "^5.10.0",
"fastify-cli": "^8.0.0",
Expand All @@ -28,10 +28,13 @@
"pug": "^3.0.4"
},
"devDependencies": {
"@tailwindcss/vite": "^4.3.3",
"npm-check-updates": "^23.0.0",
"oxfmt": "^0.63.0",
"oxlint": "^1.78.0",
"pino": "^10.3.1",
"tailwindcss": "^4.3.3",
"vite": "^8.2.2",
"vitest": "^4.1.10"
},
"engines": {
Expand Down
Loading