Skip to content

Commit 8a50242

Browse files
authored
Merge pull request #12 from Adamant-im/dev
v4.0.0 Initial release
2 parents e6963ed + b13fe2d commit 8a50242

45 files changed

Lines changed: 6323 additions & 4729 deletions

Some content is hidden

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

.github/CONTRIBUTING.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Contributing Guide
2+
3+
Hi! We're really excited that you are interested in contributing to ADAMANT. Before submitting your contribution, please make sure to take a moment and read through the following guidelines:
4+
5+
- [Pull Request Guidelines](#pull-request-guidelines)
6+
- [Development Setup](#development-setup)
7+
- [Scripts](#scripts)
8+
- [Project Structure](#project-structure)
9+
- [Financial Contribution](#financial-contribution)
10+
11+
## Pull Request Guidelines
12+
13+
- The `master` branch is just a snapshot of the latest stable release. All development should be done in dedicated branches. Do not submit PRs against the `master` branch.
14+
15+
- Checkout a topic branch from the relevant branch, e.g. `dev`, and merge back against that branch.
16+
17+
- [Make sure to tick the "Allow edits from maintainers" box](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork). This allows us to directly make minor edits / refactors and saves a lot of time.
18+
19+
- If adding a new feature, provide a convincing reason to add this feature. Ideally, you should open a suggestion issue first and have it approved before working on it.
20+
21+
- If fixing a bug:
22+
23+
- If you are resolving a special issue, add `(fix #xxxx[,#xxxx])` (#xxxx is the issue id) in your PR title for a better release log, e.g. `update entities encoding/decoding (fix #3899)`.
24+
- Provide a detailed description of the bug in the PR.
25+
26+
- It's OK to have multiple small commits as you work on the PR - GitHub can automatically squash them before merging.
27+
28+
- Commit messages must follow the [commit message convention](https://www.conventionalcommits.org/). Commit messages are automatically validated before commit (by invoking Git Hooks).
29+
30+
### Advanced Pull Request Tips
31+
32+
- The PR should fix the intended bug **only** and not introduce unrelated changes. This includes unnecessary refactors - a PR should focus on the fix and not code style, this makes it easier to trace changes in the future.
33+
34+
## Development Setup
35+
36+
You will need [Node.js](https://nodejs.org) **version 20.11+**, [PNPM](https://pnpm.io) **version 9+** and [MongoDB](https://www.mongodb.com/) **version 6+** or Docker Compose.
37+
38+
A high level overview of tools used:
39+
40+
- [TypeScript](https://www.typescriptlang.org/) as the development language
41+
- [Nest.js](https://nestjs.com/) as the server-side framework
42+
- [MongoDB](https://www.mongodb.com/) for database
43+
- [Zod](https://zod.dev/) for validation
44+
- [Docker](https://www.docker.com/) for production
45+
- [ESLint](https://eslint.org/) for static error prevention (outside of types)
46+
47+
### Using Docker
48+
49+
Install dependencies:
50+
51+
```
52+
pnpm install
53+
```
54+
55+
Copy the default config file:
56+
57+
```
58+
cp config.default.jsonc config.jsonc
59+
```
60+
61+
Run MongoDB with Docker:
62+
63+
```
64+
docker compose up
65+
```
66+
67+
### Without Docker
68+
69+
Install dependencies:
70+
71+
```
72+
pnpm install
73+
```
74+
75+
Copy the default config file:
76+
77+
```
78+
cp config.default.jsonc config.jsonc
79+
```
80+
81+
Install MongoDB and update `server.mongodb` value in `config.jsonc`. For example:
82+
83+
```json
84+
{
85+
"server": {
86+
"port": 36661,
87+
"mongodb": {
88+
"port": 27017,
89+
"host": "127.0.0.1"
90+
}
91+
}
92+
}
93+
```
94+
95+
## Scripts
96+
97+
- [`npm run start:dev`](#npm-run-start-dev)
98+
99+
### `npm run start:dev`
100+
101+
The `dev` script builds the app in dev mode. This is useful when you want to start the app for quick debugging:
102+
103+
```bash
104+
$ npm run start:dev
105+
106+
Successfully compiled: 33 files with swc (96.83ms)
107+
...
108+
```
109+
110+
## Project Structure
111+
112+
The source code is located under the `src` directory:
113+
114+
- `main.ts`: Entry point for the app.
115+
116+
- `app.module.ts`: Database connection and modules initialization.
117+
118+
- `shared`: The utilities used across the app.
119+
120+
- `global`: Global modules available that can be used in any part of the app, e.g. logger, config or notifier.
121+
122+
- `rates`:
123+
124+
- `api`: Contains all the API for each of the sources.
125+
126+
- `merger`
127+
128+
- `index`: Module responsible for merging rates from multiple sources and storing them.
129+
- `strategy`: Exports all implementations of `strategy` configuration.
130+
131+
- `rates.service.ts`: Service for fetching rates from all the available sources.
132+
133+
- `rates.interceptor.ts`: Formats the response of the endpoints.
134+
135+
- `rates.controller.ts`: Links the endpoints with the methods.
136+
137+
## Financial Contribution
138+
139+
We also welcome financial contributions via cryptocurrency. See https://adamant.im/donate.

.github/banner-dark.png

24.2 KB
Loading

.github/banner-light.png

23.9 KB
Loading

.github/logo.png

6.24 KB
Loading

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ docker-compose.override.yml
33

44
# configs
55
config.jsonc
6+
config.test.jsonc
67
.env
78

89
# compiled output
@@ -33,6 +34,7 @@ lerna-debug.log*
3334
*.launch
3435
.settings/
3536
*.sublime-workspace
37+
.vscode
3638

3739
# IDE - VSCode
3840
.vscode/*

.prettierrc

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
{
22
"singleQuote": true,
3-
"trailingComma": "all"
4-
}
3+
"trailingComma": "all",
4+
"overrides": [
5+
{
6+
"files": "*.jsonc",
7+
"options": {
8+
"trailingComma": "none"
9+
}
10+
}
11+
]
12+
}

Dockerfile

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
1-
FROM node:21
1+
# Build
2+
FROM node:21-alpine as builder
23

34
WORKDIR /usr/src/currencyinfo
45

5-
RUN npm install -g pnpm
6-
76
COPY package.json pnpm-lock.yaml ./
8-
9-
RUN pnpm install
7+
RUN npm install -g pnpm && \
8+
pnpm install
109

1110
COPY . .
12-
1311
RUN pnpm run build
1412

15-
EXPOSE 36661
13+
# Production
14+
FROM node:21-alpine
15+
16+
WORKDIR /usr/src/currencyinfo
17+
18+
COPY --from=builder /usr/src/currencyinfo/package.json \
19+
/usr/src/currencyinfo/pnpm-lock.yaml ./
20+
21+
RUN npm install -g pnpm && \
22+
pnpm install --only=production
1623

17-
CMD ["node", "dist/main"]
24+
COPY --from=builder /usr/src/currencyinfo/dist ./dist
25+
COPY --from=builder /usr/src/currencyinfo/config.default.jsonc \
26+
./
27+
28+
EXPOSE 36661
29+
CMD ["pnpm", "run", "start:prod"]

0 commit comments

Comments
 (0)