Skip to content

Commit 18f59df

Browse files
authored
Migrate to Vite + other updates (#345)
* Functional * Updated workflows * Fix * Fix PR preview * Fix path * Tweak charts * Cleanup * Update routes * More cleanup * Fix * Fixes
1 parent 4b4fffd commit 18f59df

52 files changed

Lines changed: 11044 additions & 10890 deletions

Some content is hidden

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

.eslintrc.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
module.exports = {
2-
extends: ["@stellar/eslint-config"],
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
node: true,
6+
},
7+
extends: ["eslint:recommended", "prettier"],
8+
parser: "@typescript-eslint/parser",
9+
parserOptions: {
10+
ecmaVersion: 12,
11+
sourceType: "module",
12+
},
13+
plugins: ["@typescript-eslint"],
314
rules: {
415
"no-console": "off",
5-
"import/no-unresolved": "off",
6-
"no-await-in-loop": "off",
716
"no-constant-condition": "off",
8-
"@typescript-eslint/naming-convention": ["warn"],
17+
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
18+
"no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
19+
"prefer-const": "warn",
20+
"no-var": "warn",
21+
eqeqeq: "warn",
922
},
23+
ignorePatterns: ["node_modules/", "dist/", "*.min.js"],
1024
};

.github/workflows/codeql.yml

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
name: "CodeQL"
1+
name: "CodeQL Security Analysis"
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: ["master", "main"]
66
pull_request:
7-
branches: [ "master" ]
7+
branches: ["master", "main"]
88
schedule:
9-
- cron: '26 17 * * 6'
9+
- cron: "26 17 * * 6"
1010

1111
jobs:
1212
analyze:
@@ -16,26 +16,31 @@ jobs:
1616
permissions:
1717
# required for all workflows
1818
security-events: write
19+
# required to fetch internal or private CodeQL packs
20+
packages: read
21+
# only required for workflows in private repositories
22+
actions: read
23+
contents: read
1924

2025
strategy:
2126
fail-fast: false
2227
matrix:
2328
include:
24-
- language: javascript-typescript
25-
build-mode: none
26-
29+
- language: javascript-typescript
30+
build-mode: none
31+
2732
steps:
28-
- name: Checkout repository
29-
uses: actions/checkout@v4
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
3035

31-
# Initializes the CodeQL tools for scanning.
32-
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@v3
34-
with:
35-
languages: ${{ matrix.language }}
36-
build-mode: ${{ matrix.build-mode }}
36+
# Initializes the CodeQL tools for scanning.
37+
- name: Initialize CodeQL
38+
uses: github/codeql-action/init@v3
39+
with:
40+
languages: ${{ matrix.language }}
41+
build-mode: ${{ matrix.build-mode }}
3742

38-
- name: Perform CodeQL Analysis
39-
uses: github/codeql-action/analyze@v3
40-
with:
41-
category: "/language:${{matrix.language}}"
43+
- name: Perform CodeQL Analysis
44+
uses: github/codeql-action/analyze@v3
45+
with:
46+
category: "/language:${{matrix.language}}"

.github/workflows/test-build.yml

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,55 @@
1-
name: Test and build
1+
name: Test and Build
2+
23
on:
34
push:
45
branches:
5-
- master
6+
- master
7+
- main
68
pull_request:
79

810
jobs:
9-
build:
11+
test-and-build:
1012
runs-on: ubuntu-latest
13+
1114
services:
1215
redis:
13-
image: redis
16+
image: redis:7-alpine
1417
# Set health checks to wait until redis has started
1518
options: >-
16-
--health-cmd "redis-cli ping"
17-
--health-interval 10s
18-
--health-timeout 5s
19-
--health-retries 5
19+
--health-cmd "redis-cli ping" --health-interval 10s --health-timeout
20+
5s --health-retries 5
2021
ports:
21-
- 6379:6379
22+
- 6379:6379
23+
2224
steps:
23-
- uses: actions/checkout@v2
24-
- uses: actions/setup-node@v2
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: "22"
32+
cache: "npm"
33+
34+
- name: Install dependencies
35+
run: npm install --legacy-peer-deps
36+
# Note: Using --legacy-peer-deps due to muicss package compatibility with React 18
37+
38+
- name: Run linter
39+
run: npx eslint backend/ --ext .ts
40+
41+
- name: Run tests
42+
run: npm test
43+
env:
44+
DEV: true
45+
46+
- name: Build application
47+
run: npm run build
48+
49+
- name: Upload build artifacts
50+
uses: actions/upload-artifact@v4
51+
if: success()
2552
with:
26-
node-version: 16
27-
- run: yarn install
28-
- run: yarn test
29-
- run: yarn build
53+
name: build-files
54+
path: dist/
55+
retention-days: 7

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
/node_modules
2-
/.tmp
32
/dist
43
*.eslintcache
54
*service-account.json
65
*.env
6+
/.vscode
7+
/.idea
8+
/.kiro
9+
/.cursor
10+
dump.rdb

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
.tmp
1+

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:24.04
22

33
MAINTAINER SDF Ops Team <ops@stellar.org>
44

@@ -8,16 +8,20 @@ WORKDIR /app/src
88
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
99
gpg curl ca-certificates git apt-transport-https && \
1010
curl -sSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key|gpg --dearmor >/etc/apt/trusted.gpg.d/nodesource-key.gpg && \
11-
echo "deb https://deb.nodesource.com/node_16.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
12-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg |gpg --dearmor >/etc/apt/trusted.gpg.d/yarnpkg.gpg && \
13-
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
14-
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs yarn && \
15-
yarn install && /app/src/node_modules/gulp/bin/gulp.js build
11+
echo "deb https://deb.nodesource.com/node_22.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
12+
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs && \
13+
npm ci --legacy-peer-deps && npm run build
1614

1715
ENV PORT=80 UPDATE_DATA=false
1816
EXPOSE 80
1917

2018
RUN node_modules/typescript/bin/tsc
2119

20+
# Copy common directory to dist for runtime access
21+
RUN cp -r common dist/
22+
23+
# Change working directory to dist for runtime
24+
WORKDIR /app/src/dist
25+
2226
ENTRYPOINT ["/usr/bin/node"]
2327
CMD ["./backend/app.js"]

Procfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
web: node app.js
1+
web: npx tsx backend/app.ts

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
To build this project, you must have the following dependencies installed:
66

7-
- node 10.16.3
8-
- yarn
7+
- Node v22
8+
- NPM
99

1010
## Installation
1111

1212
```sh
13-
yarn
13+
npm install
1414
```
1515

1616
## Developing
1717

1818
```sh
19-
yarn start
19+
npm run dev
2020
```
2121

2222
### If you wish to use backend server API, you need to have redis running locally on port 6379 (default for redis)
@@ -27,7 +27,7 @@ yarn start
2727
brew install redis
2828
```
2929

30-
(Other install directions can be found here: https://redis.io/download)
30+
(Other install directions can be found [here](https://redis.io/download))
3131

3232
Make sure it's running
3333

@@ -38,17 +38,25 @@ brew services start redis
3838
Once you have redis installed, start this command
3939

4040
```sh
41-
yarn run start:backend
41+
npm run start:backend
4242
```
4343

4444
It will create a proxy to `browser-sync` server started by gulp at
4545
`http://localhost:5000`
4646

4747
### Connecting to Big Query
48-
Connecting to Big Query is not required for running the backend (if you run with UPDATE_DATA=false), but is required for things like catching up ledger data in redis.
4948

50-
This project is pulling from SDF's `crypto-stellar` public data set, so no special credentials are required. However you will need a Google Cloud Platform project with a service account to be able to access Big Query.
49+
Connecting to Big Query is not required for running the backend (if you run with
50+
UPDATE_DATA=false), but is required for things like catching up ledger data in
51+
redis.
5152

52-
Directions for creating a service account [can be found here](https://cloud.google.com/docs/authentication/getting-started).
53+
This project is pulling from SDF's `crypto-stellar` public data set, so no
54+
special credentials are required. However you will need a Google Cloud Platform
55+
project with a service account to be able to access Big Query.
5356

54-
Once you've created a service account, add the service account key json file to the `gcloud` folder under the name `service-account.json`. An example json file shows what the file structure should look like.
57+
Directions for creating a service account
58+
[can be found here](https://cloud.google.com/docs/authentication/getting-started).
59+
60+
Once you've created a service account, add the service account key json file to
61+
the `gcloud` folder under the name `service-account.json`. An example json file
62+
shows what the file structure should look like.

backend/app.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
// need to manually import regeneratorRuntime for babel w/ async
2-
// https://github.com/babel/babel/issues/9849#issuecomment-487040428
3-
// require("regenerator-runtime/runtime");
4-
import "regenerator-runtime/runtime";
5-
61
import "dotenv/config";
72

83
// Run backend with cache updates.

backend/ledgers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import stellarSdk from "stellar-sdk";
1+
import { Horizon } from "@stellar/stellar-sdk";
22
import { findIndex } from "lodash";
33
import { Response, NextFunction } from "express";
44

@@ -64,7 +64,7 @@ export async function updateLedgers() {
6464

6565
await catchup(REDIS_LEDGER_KEY, pagingToken, REDIS_PAGING_TOKEN_KEY, 0);
6666

67-
const horizon = new stellarSdk.Server("https://horizon.stellar.org");
67+
const horizon = new Horizon.Server("https://horizon.stellar.org");
6868
horizon
6969
.ledgers()
7070
.cursor(CURSOR_NOW)
@@ -82,7 +82,7 @@ export async function catchup(
8282
pagingTokenKey: string,
8383
limit: number, // if 0, catchup until now
8484
) {
85-
const horizon = new stellarSdk.Server("https://horizon.stellar.org");
85+
const horizon = new Horizon.Server("https://horizon.stellar.org");
8686
let ledgers: LedgerRecord[] = [];
8787
let total = 0;
8888
let pagingToken = pagingTokenStart;

0 commit comments

Comments
 (0)