Skip to content

Commit 731511b

Browse files
Project structure init with the docker file + guides
1 parent 857bb75 commit 731511b

Some content is hidden

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

63 files changed

+15107
-2
lines changed

.gitignore

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# compiled output
2+
/dist
3+
/node_modules
4+
/build
5+
6+
# Logs
7+
logs
8+
*.log
9+
npm-debug.log*
10+
pnpm-debug.log*
11+
yarn-debug.log*
12+
yarn-error.log*
13+
lerna-debug.log*
14+
15+
# OS
16+
.DS_Store
17+
18+
# Tests
19+
/coverage
20+
/.nyc_output
21+
22+
# IDEs and editors
23+
/.idea
24+
.project
25+
.classpath
26+
.c9/
27+
*.launch
28+
.settings/
29+
*.sublime-workspace
30+
31+
# IDE - VSCode
32+
.vscode/*
33+
!.vscode/settings.json
34+
!.vscode/tasks.json
35+
!.vscode/launch.json
36+
!.vscode/extensions.json
37+
38+
# dotenv environment variable files
39+
.env
40+
.env.development.local
41+
.env.test.local
42+
.env.production.local
43+
.env.local
44+
45+
# temp directory
46+
.temp
47+
.tmp
48+
49+
# Runtime data
50+
pids
51+
*.pid
52+
*.seed
53+
*.pid.lock
54+
55+
# Diagnostic reports (https://nodejs.org/api/report.html)
56+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all"
4+
}

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Multi-stage Dockerfile for NestJS app
2+
3+
FROM node:20-alpine AS base
4+
WORKDIR /app
5+
6+
# Install dependencies separately for layer caching
7+
FROM base AS deps
8+
COPY package.json package-lock.json ./
9+
RUN npm ci --no-audit --no-fund
10+
11+
# Build the application (needs devDependencies like @nestjs/cli)
12+
FROM deps AS build
13+
COPY . .
14+
RUN npm run build
15+
16+
# Prune dev dependencies to shrink runtime size
17+
RUN npm prune --omit=dev
18+
19+
# Final runtime image
20+
FROM node:20-alpine AS runner
21+
ENV NODE_ENV=production
22+
ENV PORT=3000
23+
WORKDIR /app
24+
25+
# Only copy what is needed at runtime
26+
COPY --from=build /app/node_modules ./node_modules
27+
COPY --from=build /app/package.json ./package.json
28+
COPY --from=build /app/package-lock.json ./package-lock.json
29+
COPY --from=build /app/dist ./dist
30+
COPY --from=build /app/public ./public
31+
32+
EXPOSE 3000
33+
# Because tsconfig includes project root, compiled entry is dist/src/main.js
34+
CMD ["node", "dist/src/main.js"]

README.md

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,98 @@
1-
# learn_reading-tracker-app
2-
NestJS Reading Tracker app backend
1+
<p align="center">
2+
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="120" alt="Nest Logo" /></a>
3+
</p>
4+
5+
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
6+
[circleci-url]: https://circleci.com/gh/nestjs/nest
7+
8+
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
9+
<p align="center">
10+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
11+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
12+
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
13+
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
14+
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
15+
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
16+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
17+
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg" alt="Donate us"/></a>
18+
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
19+
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow" alt="Follow us on Twitter"></a>
20+
</p>
21+
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
22+
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
23+
24+
## Description
25+
26+
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
27+
28+
## Project setup
29+
30+
```bash
31+
$ npm install
32+
```
33+
34+
## Compile and run the project
35+
36+
```bash
37+
# development
38+
$ npm run start
39+
40+
# watch mode
41+
$ npm run start:dev
42+
43+
# production mode
44+
$ npm run start:prod
45+
```
46+
47+
## Run tests
48+
49+
```bash
50+
# unit tests
51+
$ npm run test
52+
53+
# e2e tests
54+
$ npm run test:e2e
55+
56+
# test coverage
57+
$ npm run test:cov
58+
```
59+
60+
## Deployment
61+
62+
When you're ready to deploy your NestJS application to production, there are some key steps you can take to ensure it runs as efficiently as possible. Check out the [deployment documentation](https://docs.nestjs.com/deployment) for more information.
63+
64+
If you are looking for a cloud-based platform to deploy your NestJS application, check out [Mau](https://mau.nestjs.com), our official platform for deploying NestJS applications on AWS. Mau makes deployment straightforward and fast, requiring just a few simple steps:
65+
66+
```bash
67+
$ npm install -g @nestjs/mau
68+
$ mau deploy
69+
```
70+
71+
With Mau, you can deploy your application in just a few clicks, allowing you to focus on building features rather than managing infrastructure.
72+
73+
## Resources
74+
75+
Check out a few resources that may come in handy when working with NestJS:
76+
77+
- Visit the [NestJS Documentation](https://docs.nestjs.com) to learn more about the framework.
78+
- For questions and support, please visit our [Discord channel](https://discord.gg/G7Qnnhy).
79+
- To dive deeper and get more hands-on experience, check out our official video [courses](https://courses.nestjs.com/).
80+
- Deploy your application to AWS with the help of [NestJS Mau](https://mau.nestjs.com) in just a few clicks.
81+
- Visualize your application graph and interact with the NestJS application in real-time using [NestJS Devtools](https://devtools.nestjs.com).
82+
- Need help with your project (part-time to full-time)? Check out our official [enterprise support](https://enterprise.nestjs.com).
83+
- To stay in the loop and get updates, follow us on [X](https://x.com/nestframework) and [LinkedIn](https://linkedin.com/company/nestjs).
84+
- Looking for a job, or have a job to offer? Check out our official [Jobs board](https://jobs.nestjs.com).
85+
86+
## Support
87+
88+
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
89+
90+
## Stay in touch
91+
92+
- Author - [Kamil Myśliwiec](https://twitter.com/kammysliwiec)
93+
- Website - [https://nestjs.com](https://nestjs.com/)
94+
- Twitter - [@nestframework](https://twitter.com/nestframework)
95+
96+
## License
97+
98+
Nest is [MIT licensed](https://github.com/nestjs/nest/blob/master/LICENSE).

docker-guide-macos

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Docker Guide (macOS + Docker Desktop)
2+
3+
This guide walks you through building and running the NestJS app in Docker on macOS.
4+
5+
## Prerequisites
6+
- Docker Desktop for macOS installed and running
7+
- Terminal opened at the project root (same folder as `Dockerfile`)
8+
9+
## 1) Build the Docker image
10+
- Builds the production image using the multi‑stage `Dockerfile`.
11+
12+
```
13+
docker build -t reading-tracker-app:latest .
14+
```
15+
16+
## 2) Run the container (map port 3000)
17+
- Runs the container in detached mode and maps host port 3000 to container port 3000.
18+
19+
```
20+
docker run -d --name reading-tracker -p 3000:3000 reading-tracker-app:latest
21+
```
22+
23+
If your Mac already uses port 3000, map a different host port (for example, 8080):
24+
```
25+
docker run -d --name reading-tracker -p 8080:3000 reading-tracker-app:latest
26+
```
27+
28+
## 3) Verify the app is running
29+
- Open the app in your browser:
30+
```
31+
open http://localhost:3000
32+
```
33+
- Or test the public API endpoint:
34+
```
35+
curl http://localhost:3000/api/hello
36+
```
37+
Expected response:
38+
```
39+
{"success":true,"data":"Hello World!"}
40+
```
41+
42+
## 4) View logs (optional)
43+
- Stream container logs to troubleshoot or confirm startup:
44+
```
45+
docker logs -f reading-tracker
46+
```
47+
48+
## 5) Stop and remove the container
49+
- Stop the running container:
50+
```
51+
docker stop reading-tracker
52+
```
53+
- Remove the stopped container:
54+
```
55+
docker rm reading-tracker
56+
```
57+
58+
## 6) Rebuild and clean up tips
59+
- Rebuild without using cache:
60+
```
61+
docker build --no-cache -t reading-tracker-app:latest .
62+
```
63+
- Remove the image (forces a clean rebuild next time):
64+
```
65+
docker rmi reading-tracker-app:latest
66+
```
67+
- List running containers:
68+
```
69+
docker ps
70+
```
71+
- List all containers (including exited):
72+
```
73+
docker ps -a
74+
```
75+
76+
## Notes
77+
- The container exposes port 3000 and starts via `node dist/src/main.js`.
78+
- Static assets are served from `/app/public` and API endpoints are under `/api`, `/users`, `/books`, `/reading`, `/auth`, `/admin`, `/friends`.
79+

docker-guide-windows

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Docker Guide (Windows + Docker Desktop)
2+
3+
This guide walks you through building and running the NestJS app in Docker on Windows (PowerShell or Command Prompt).
4+
5+
## Prerequisites
6+
- Docker Desktop for Windows installed and running
7+
- Terminal opened at the project root (same folder as `Dockerfile`)
8+
9+
## 1) Build the Docker image
10+
Run in PowerShell or CMD:
11+
```
12+
docker build -t reading-tracker-app:latest .
13+
```
14+
15+
## 2) Run the container (map port 3000)
16+
Detached mode, mapping host port 3000 to container port 3000:
17+
```
18+
docker run -d --name reading-tracker -p 3000:3000 reading-tracker-app:latest
19+
```
20+
21+
If port 3000 is in use on Windows, map a different host port (e.g., 8080):
22+
```
23+
docker run -d --name reading-tracker -p 8080:3000 reading-tracker-app:latest
24+
```
25+
26+
## 3) Verify the app is running
27+
- In a browser, open:
28+
```
29+
http://localhost:3000
30+
```
31+
- Or verify the public API endpoint. On Windows, prefer `curl.exe` to avoid PowerShell aliasing:
32+
```
33+
curl.exe http://localhost:3000/api/hello
34+
```
35+
Expected response:
36+
```
37+
{"success":true,"data":"Hello World!"}
38+
```
39+
40+
## 4) View logs (optional)
41+
Tail container logs:
42+
```
43+
docker logs -f reading-tracker
44+
```
45+
46+
## 5) Stop and remove the container
47+
Stop the container:
48+
```
49+
docker stop reading-tracker
50+
```
51+
Remove the stopped container:
52+
```
53+
docker rm reading-tracker
54+
```
55+
56+
## 6) Rebuild and clean up tips
57+
Rebuild without cache:
58+
```
59+
docker build --no-cache -t reading-tracker-app:latest .
60+
```
61+
Remove the image (forces clean rebuild next time):
62+
```
63+
docker rmi reading-tracker-app:latest
64+
```
65+
List running containers:
66+
```
67+
docker ps
68+
```
69+
List all containers (including exited):
70+
```
71+
docker ps -a
72+
```
73+
74+
## Notes
75+
- The container exposes port 3000 and starts via `node dist/src/main.js`.
76+
- Static assets are served from `/app/public` and API routes include `/api`, `/users`, `/books`, `/reading`, `/auth`, `/admin`, `/friends`.
77+

0 commit comments

Comments
 (0)