Use bun for web3proxy and webui
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# Use an official Node.js image as the base
|
||||
FROM node:22.14.0-alpine
|
||||
# Use an official Bun image as the base
|
||||
FROM oven/bun:1.3-debian
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
@@ -8,13 +8,13 @@ WORKDIR /app
|
||||
COPY /src/Managing.Web3Proxy/package.json ./
|
||||
|
||||
|
||||
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
|
||||
RUN npm install
|
||||
# Install dependencies
|
||||
RUN bun install
|
||||
|
||||
COPY src/Managing.Web3Proxy/ .
|
||||
|
||||
RUN npm run build
|
||||
RUN bun run build
|
||||
|
||||
EXPOSE 4111
|
||||
|
||||
CMD ["npm", "run", "start"]
|
||||
CMD ["bun", "run", "start"]
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
The aim of this repository is to provide a concrete example of a Fastify application using what are considered best practices by the Fastify community.
|
||||
|
||||
**Prerequisites:** You need to have Node.js version 22 or higher installed.
|
||||
**Prerequisites:** You need to have Bun version 1.3 or higher installed.
|
||||
|
||||
## Getting started
|
||||
Install the dependencies:
|
||||
```bash
|
||||
npm install
|
||||
bun install
|
||||
```
|
||||
|
||||
### Database
|
||||
@@ -23,54 +23,54 @@ docker compose up -d
|
||||
|
||||
To create and update the database schema, run the migrations:
|
||||
```bash
|
||||
npm run db:migrate
|
||||
bun run db:migrate
|
||||
```
|
||||
|
||||
To populate the database with initial data, run:
|
||||
```bash
|
||||
npm run db:seed
|
||||
bun run db:seed
|
||||
```
|
||||
|
||||
### TypeScript
|
||||
To build the project:
|
||||
```bash
|
||||
npm run build
|
||||
bun run build
|
||||
```
|
||||
|
||||
### Start the server
|
||||
In dev mode:
|
||||
```bash
|
||||
npm run dev
|
||||
bun run dev
|
||||
```
|
||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
||||
|
||||
In production mode:
|
||||
```bash
|
||||
npm run start
|
||||
bun run start
|
||||
```
|
||||
|
||||
### Testing
|
||||
To run the tests:
|
||||
```bash
|
||||
npm run test
|
||||
bun run test
|
||||
```
|
||||
|
||||
### Standalone
|
||||
`dev` and `start` leverage [fastify-cli](https://github.com/fastify/fastify-cli),
|
||||
but you can run the demo as a standalone executable (see [server.ts](./src/server.ts)):
|
||||
```bash
|
||||
npm run standalone
|
||||
bun run standalone
|
||||
```
|
||||
|
||||
### Linting
|
||||
To check for linting errors:
|
||||
```bash
|
||||
npm run lint
|
||||
bun run lint
|
||||
```
|
||||
|
||||
To check and automatically fix linting errors:
|
||||
```bash
|
||||
npm run lint:fix
|
||||
bun run lint:fix
|
||||
```
|
||||
|
||||
## Learn More
|
||||
|
||||
2137
src/Managing.Web3Proxy/bun.lock
Normal file
2137
src/Managing.Web3Proxy/bun.lock
Normal file
File diff suppressed because it is too large
Load Diff
11014
src/Managing.Web3Proxy/package-lock.json
generated
11014
src/Managing.Web3Proxy/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,14 +11,14 @@
|
||||
"start": "fastify start -l info dist/app.js",
|
||||
"build": "tsc",
|
||||
"watch": "tsc -w",
|
||||
"dev": "npm run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"npm:watch\" \"npm:dev:start\"",
|
||||
"dev:start": "npm run build && fastify start -d --ignore-watch=.ts$ -w -l info -P dist/app.js",
|
||||
"test": "npm run db:seed && c8 npm run test:run",
|
||||
"dev": "bun run build && concurrently -k -p \"[{name}]\" -n \"TypeScript,App\" -c \"yellow.bold,cyan.bold\" \"bun:watch\" \"bun:dev:start\"",
|
||||
"dev:start": "bun run build && fastify start -d --ignore-watch=.ts$ -w -l info -P dist/app.js",
|
||||
"test": "bun run db:seed && c8 bun run test:run",
|
||||
"test:run": "tsx --test ./test/**/*.ts",
|
||||
"test:single": "tsc && tsx --test",
|
||||
"standalone": "npm run build && node --env-file=.env dist/server.js",
|
||||
"standalone": "bun run build && node --env-file=.env dist/server.js",
|
||||
"lint": "eslint --ignore-pattern=dist",
|
||||
"lint:fix": "npm run lint -- --fix",
|
||||
"lint:fix": "bun run lint -- --fix",
|
||||
"db:create": "tsx --env-file=.env ./scripts/create-database.ts",
|
||||
"db:drop": "tsx --env-file=.env ./scripts/drop-database.ts",
|
||||
"db:migrate": "tsx --env-file=.env ./scripts/migrate.ts",
|
||||
|
||||
@@ -55,11 +55,12 @@ export default async function serviceApp (
|
||||
'Unhandled error occurred'
|
||||
)
|
||||
|
||||
reply.code(err.statusCode ?? 500)
|
||||
const statusCode = (err as any)?.statusCode ?? 500
|
||||
reply.code(statusCode)
|
||||
|
||||
let message = 'Internal Server Error'
|
||||
if (err.statusCode && err.statusCode < 500) {
|
||||
message = err.message
|
||||
if ((err as any)?.statusCode && (err as any).statusCode < 500) {
|
||||
message = (err as any).message
|
||||
}
|
||||
|
||||
return { message }
|
||||
|
||||
@@ -11,8 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
node-version: '18.1.0'
|
||||
- run: yarn install
|
||||
- run: yarn build
|
||||
bun-version: '1.3'
|
||||
- run: bun install
|
||||
- run: bun run build
|
||||
|
||||
@@ -11,8 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
node-version: '18.1.0'
|
||||
- run: yarn install
|
||||
- run: yarn lint
|
||||
bun-version: '1.3'
|
||||
- run: bun install
|
||||
- run: bun run lint
|
||||
|
||||
18
src/Managing.WebApp/.github/workflows/test.yml
vendored
18
src/Managing.WebApp/.github/workflows/test.yml
vendored
@@ -1,18 +0,0 @@
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
with:
|
||||
node-version: '18.1.0'
|
||||
- run: yarn install
|
||||
- run: yarn test
|
||||
@@ -11,8 +11,8 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2-beta
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
node-version: '18.1.0'
|
||||
- run: yarn install
|
||||
- run: yarn typecheck
|
||||
bun-version: '1.3'
|
||||
- run: bun install
|
||||
- run: bun run typecheck
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Use an official Node.js image as the base
|
||||
FROM node:18-alpine
|
||||
# Use an official Bun image as the base
|
||||
FROM oven/bun:1.3-debian
|
||||
|
||||
# Set the working directory in the container
|
||||
WORKDIR /app
|
||||
@@ -8,26 +8,26 @@ WORKDIR /app
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
|
||||
# Install git and Python
|
||||
RUN apk update && apk add --no-cache git python3 make g++
|
||||
RUN apt-get update && apt-get install -y git python3 make g++ && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a symlink for python3 as python
|
||||
RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||
|
||||
# Copy package.json and package-lock.json to the container
|
||||
# Copy package.json and bun.lockb to the container
|
||||
# COPY package*.json ./
|
||||
COPY /src/Managing.WebApp/package.json ./
|
||||
|
||||
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
|
||||
RUN npm install --legacy-peer-deps
|
||||
RUN npm install -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
||||
# Install dependencies with bun
|
||||
RUN bun install
|
||||
RUN bun add -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
||||
|
||||
# Copy the rest of the app's source code to the container
|
||||
# COPY . .
|
||||
COPY src/Managing.WebApp/ /app/
|
||||
RUN node --max-old-space-size=8192 ./node_modules/.bin/vite build
|
||||
RUN bun --bun ./node_modules/.bin/vite build
|
||||
|
||||
# Build the app
|
||||
RUN npm run build
|
||||
RUN bun run build
|
||||
|
||||
# Use NGINX as the web server
|
||||
FROM nginx:alpine
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Use an official Node.js image as the base
|
||||
FROM node:22.14.0-alpine
|
||||
# Use an official Bun image as the base
|
||||
FROM oven/bun:1.3-debian
|
||||
|
||||
# Add build argument for cache busting
|
||||
ARG CACHEBUST=1
|
||||
@@ -11,31 +11,30 @@ WORKDIR /app
|
||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||
|
||||
# Install git and Python
|
||||
RUN apk update && apk add --no-cache git python3 make g++
|
||||
RUN apt-get update && apt-get install -y git python3 make g++ && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Create a symlink for python3 as python
|
||||
# Create a symlink for python3 as python
|
||||
# This might not be strictly necessary for your current issue but good to keep if Python scripts are involved.
|
||||
# RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||
# RUN ln -sf /usr/bin/python3 /usr/bin/python
|
||||
|
||||
# Copy package.json and package-lock.json to the container
|
||||
# COPY package*.json ./
|
||||
COPY /src/Managing.WebApp/package.json ./
|
||||
# Copy package.json and bun.lockb to the container
|
||||
# COPY package*.json ./
|
||||
COPY /src/Managing.WebApp/package.json ./
|
||||
|
||||
# Use cache busting argument to force cache invalidation
|
||||
RUN echo "Cache bust: $CACHEBUST"
|
||||
|
||||
# Install dependencies with the --legacy-peer-deps flag to bypass peer dependency conflicts
|
||||
# Add --no-cache flag to prevent npm cache usage
|
||||
RUN npm install --legacy-peer-deps --loglevel verbose --no-cache
|
||||
RUN npm install -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
||||
# Install dependencies with bun
|
||||
RUN bun install
|
||||
RUN bun add -g tailwindcss postcss autoprefixer @tailwindcss/typography
|
||||
|
||||
# Copy the rest of the app's source code to the container
|
||||
# COPY . .
|
||||
RUN ls -la
|
||||
COPY src/Managing.WebApp/ .
|
||||
# Copy the rest of the app's source code to the container
|
||||
# COPY . .
|
||||
RUN ls -la
|
||||
COPY src/Managing.WebApp/ .
|
||||
|
||||
# Build the app
|
||||
RUN npm run build
|
||||
# Build the app
|
||||
RUN bun run build
|
||||
|
||||
# Use NGINX as the web server
|
||||
FROM nginx:alpine
|
||||
|
||||
4486
src/Managing.WebApp/bun.lock
Normal file
4486
src/Managing.WebApp/bun.lock
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,35 +0,0 @@
|
||||
const config = {
|
||||
collectCoverageFrom: ['<rootDir>/src/**/*.{js,jsx,ts,tsx}', '!src/**/*.d.ts'],
|
||||
moduleDirectories: ['node_modules'],
|
||||
moduleFileExtensions: ['js', 'mjs', 'jsx', 'ts', 'tsx', 'json'],
|
||||
moduleNameMapper: {
|
||||
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
|
||||
},
|
||||
notify: true,
|
||||
notifyMode: 'success-change',
|
||||
resetMocks: true,
|
||||
roots: ['<rootDir>'],
|
||||
setupFilesAfterEnv: ['<rootDir>/jest/setupTests.ts'],
|
||||
testEnvironment: 'jsdom',
|
||||
testMatch: [
|
||||
'<rootDir>/src/**/*.{spec,test}.{js,jsx,ts,tsx}',
|
||||
'<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}',
|
||||
],
|
||||
transform: {
|
||||
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)':
|
||||
'<rootDir>/jest/fileTransform.js',
|
||||
'^.+\\.[jt]sx?$': 'esbuild-jest',
|
||||
'^.+\\.css$': '<rootDir>/jest/cssTransform.js',
|
||||
},
|
||||
transformIgnorePatterns: [
|
||||
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
|
||||
'^.+\\.module\\.(css|sass|scss)$',
|
||||
],
|
||||
verbose: true,
|
||||
watchPlugins: [
|
||||
'jest-watch-typeahead/filename',
|
||||
'jest-watch-typeahead/testname',
|
||||
],
|
||||
}
|
||||
|
||||
module.exports = config
|
||||
@@ -3,16 +3,15 @@
|
||||
"version": "2.0.0",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"dev": "bunx --bun vite",
|
||||
"build": "bunx --bun vite build",
|
||||
"preview": "bunx --bun vite preview",
|
||||
"serve": "serve -s dist -p 3000",
|
||||
"test": "jest",
|
||||
"lint": "eslint . --ext .ts,.tsx,.js,jsx",
|
||||
"lint:fix": "eslint . --ext .ts,.tsx,.js,jsx --fix",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prettier": "prettier --write \"**/*.+(json|yml|css|md|mdx)\"",
|
||||
"clean": "rimraf node_modules yarn.lock dist",
|
||||
"clean": "rimraf node_modules bun.lock dist",
|
||||
"validate": "./scripts/validate"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -40,7 +39,7 @@
|
||||
"genetic-js": "^0.1.14",
|
||||
"jotai": "^1.6.7",
|
||||
"latest-version": "^9.0.0",
|
||||
"lightweight-charts": "git+https://github.com/ntf/lightweight-charts.git",
|
||||
"lightweight-charts": "^4.2.2",
|
||||
"moment": "^2.29.3",
|
||||
"plotly.js": "^2.18.1",
|
||||
"postcss": "^8.4.13",
|
||||
|
||||
Reference in New Issue
Block a user