Skip to content

Commit f312b71

Browse files
authored
Merge pull request #3 from hexlet-components/refactoring
Refactoring
2 parents d8d6856 + ee4279a commit f312b71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+48507
-12825
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
.DS_Store
33

44
# Default TypeSpec output
5-
tsp-output/
65
dist/
76

87
# Dependency directories

.github/workflows/release.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
name: Build
22

33
on:
4-
- push
5-
- pull_request
4+
push
5+
branches:
6+
- main
7+
68

79
jobs:
810
build:

Caddyfile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
http://localhost:8080
2+
3+
route / {
4+
reverse_proxy localhost:4010
5+
}
6+
7+
route /http-api/echo {
8+
reverse_proxy localhost:4010
9+
}
10+
11+
route /http-api/openapi {
12+
reverse_proxy localhost:4010
13+
}
14+
15+
route /http-protocol/openapi {
16+
reverse_proxy localhost:4010
17+
}
18+
19+
route /js-playwright/openapi {
20+
reverse_proxy localhost:4010
21+
}
22+
23+
route /postman/openapi {
24+
reverse_proxy localhost:4010
25+
}
26+
27+
route /assets {
28+
reverse_proxy localhost:4010
29+
}
30+
31+
route /http-api/example {
32+
reverse_proxy localhost:4010
33+
}
34+
35+
route /http-protocol/login {
36+
reverse_proxy localhost:4010
37+
}
38+
39+
route /http-protocol/stream {
40+
reverse_proxy localhost:4010
41+
}
42+
43+
route /http-protocol/removed {
44+
reverse_proxy localhost:4010
45+
}
46+
47+
route /http-protocol {
48+
reverse_proxy localhost:4010
49+
}
50+
51+
route /js-playwright/users-list {
52+
reverse_proxy localhost:4010
53+
}
54+
55+
route /js-dom-testing-library/users-list {
56+
reverse_proxy localhost:4010
57+
}
58+
59+
route /http-api/* {
60+
uri strip_prefix /http-api
61+
reverse_proxy localhost:4011
62+
}
63+
64+
route /http-protocol/* {
65+
uri strip_prefix /http-protocol
66+
reverse_proxy localhost:4011
67+
}
68+
69+
route /js-playwright/* {
70+
uri strip_prefix /playwright
71+
reverse_proxy localhost:4012
72+
}
73+
74+
route /postman/* {
75+
uri strip_prefix /postman
76+
reverse_proxy localhost:4013
77+
}

Dockerfile

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
FROM node:22-alpine
2+
3+
ENV NODE_ENV=production
4+
5+
RUN apk add --no-cache make caddy
6+
RUN npm install -g @stoplight/prism-cli
7+
8+
COPY package.json package-lock.json* ./
9+
RUN npm ci && npm cache clean --force
10+
211
COPY . .
3-
RUN npm ci
4-
RUN apk add --no-cache make
5-
RUN make compile
6-
CMD ["npm", "start"]
12+
# RUN make compile
13+
14+
EXPOSE 8080
15+
16+
CMD ["make", "start"]

Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
IMAGE_ID := ghcr.io/hexlet-components/rest-api-example
2+
13
setup:
24
npm ci
35
make compile
@@ -9,16 +11,25 @@ compile:
911
npx tsp compile ./typespec/js-playwright/main.tsp --output-dir "./tsp-output/js-playwright"
1012

1113
dev:
12-
npx fastify start -a 0.0.0.0 server/src/index.js
14+
docker run -v ./custom-server:/custom-server -p 8080:8080 $(IMAGE_ID)
1315

1416
start:
15-
npx fastify start -a 0.0.0.0 server/src/index.js
17+
prism mock -m -p 4011 --host 0.0.0.0 ./tsp-output/http-api/@typespec/openapi3/openapi.1.0.yaml &
18+
prism mock -m -p 4012 --host 0.0.0.0 ./tsp-output/http-protocol/@typespec/openapi3/openapi.1.0.yaml &
19+
prism mock -m -p 4013 --host 0.0.0.0 ./tsp-output/js-playwright/@typespec/openapi3/openapi.1.0.yaml &
20+
prism mock -m -p 4014 --host 0.0.0.0 ./tsp-output/postman/@typespec/openapi3/openapi.1.0.yaml &
21+
npm start &
22+
caddy run
1623

1724
test:
1825
echo no tests
1926

20-
compose-test:
21-
docker compose up --build --abort-on-container-exit
27+
docker-build:
28+
docker build . -t $(IMAGE_ID)
29+
30+
docker-run:
31+
docker rm -f rest-api-example
32+
docker run -p 8080:8080 --name rest-api-example $(IMAGE_ID)
2233

23-
generate-fixtures:
24-
node server/bin/generateFixtures.js
34+
docker-sh:
35+
docker run -it --entrypoint sh $(IMAGE_ID)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See [Makefile](./Makefile)
1313

1414
```bash
1515
make setup
16-
make start # Open http://localhost:5000/swagger
16+
make dev # Open http://localhost:8080
1717
```
1818

1919
---

__fixtures__/comments.json

Lines changed: 0 additions & 6002 deletions
This file was deleted.

__fixtures__/courses.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

__fixtures__/hexlet_logo.png

-40.1 KB
Binary file not shown.

__fixtures__/posts.json

Lines changed: 0 additions & 602 deletions
This file was deleted.

0 commit comments

Comments
 (0)