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 }
|
||||
|
||||
Reference in New Issue
Block a user