feat: bun support 🥟 (#907)

* feat: bun 🥟

* check if playwright/linux workflow is fixed

* fix: backend issues exposed by bun

* feat: update scripts for bun
This commit is contained in:
Danny Avila 2023-09-10 16:04:08 -04:00 committed by GitHub
parent a9215ed9ce
commit 75be9a3279
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 13 deletions

View file

@ -43,11 +43,11 @@ jobs:
- name: Install global dependencies
run: npm ci
- name: Remove sharp dependency
run: rm -rf node_modules/sharp
# - name: Remove sharp dependency
# run: rm -rf node_modules/sharp
- name: Install sharp with linux dependencies
run: cd api && SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux --libc=glibc sharp
# - name: Install sharp with linux dependencies
# run: cd api && SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --arch=x64 --platform=linux --libc=glibc sharp
- name: Build Client
run: npm run frontend

View file

@ -63,7 +63,7 @@
"passport-local": "^1.0.0",
"pino": "^8.12.1",
"sanitize": "^2.1.2",
"sharp": "^0.32.1",
"sharp": "^0.32.5",
"zod": "^3.22.2"
},
"devDependencies": {

View file

@ -9,7 +9,7 @@ const errorController = require('./controllers/ErrorController');
const passport = require('passport');
const configureSocialLogins = require('./socialLogins');
const port = process.env.PORT || 3080;
const port = Number(process.env.PORT) || 3080;
const host = process.env.HOST || 'localhost';
const projectPath = path.join(__dirname, '..', '..', 'client');
const { jwtLogin, passportLogin } = require('../strategies');

View file

@ -7,6 +7,10 @@ const loginLimiter = rateLimit({
windowMs,
max,
message: `Too many login attempts from this IP, please try again after ${windowInMinutes} minutes.`,
keyGenerator: function (req) {
// Strip out the port number from the IP address
return req.ip.replace(/:\d+[^:]*$/, '');
},
});
module.exports = loginLimiter;

View file

@ -7,6 +7,10 @@ const registerLimiter = rateLimit({
windowMs,
max,
message: `Too many accounts created from this IP, please try again after ${windowInMinutes} minutes`,
keyGenerator: function (req) {
// Strip out the port number from the IP address
return req.ip.replace(/:\d+[^:]*$/, '');
},
});
module.exports = registerLimiter;

View file

@ -50,9 +50,10 @@ async function passportLogin(req, email, password, done) {
}
function logError(title, parameters) {
const entries = Object.entries(parameters).map(([name, value]) => ({ name, value }));
DebugControl.log.functionName(title);
if (parameters) {
DebugControl.log.parameters(parameters);
if (entries) {
DebugControl.log.parameters(entries);
}
}

BIN
bun.lockb Executable file

Binary file not shown.

View file

@ -9,7 +9,9 @@
"dev": "cross-env NODE_ENV=development dotenv -e ../.env -- vite",
"preview-prod": "cross-env NODE_ENV=development dotenv -e ../.env -- vite preview",
"test": "cross-env NODE_ENV=test jest --watch",
"test:ci": "cross-env NODE_ENV=test jest --ci"
"test:ci": "cross-env NODE_ENV=test jest --ci",
"b:build": "NODE_ENV=production bunx --bun vite build",
"b:dev": "NODE_ENV=development bunx --bun vite"
},
"repository": {
"type": "git",

4
package-lock.json generated
View file

@ -90,7 +90,7 @@
"passport-local": "^1.0.0",
"pino": "^8.12.1",
"sanitize": "^2.1.2",
"sharp": "^0.32.1",
"sharp": "^0.32.5",
"zod": "^3.22.2"
},
"devDependencies": {
@ -26774,7 +26774,7 @@
},
"packages/data-provider": {
"name": "librechat-data-provider",
"version": "0.1.6",
"version": "0.1.7",
"license": "ISC",
"dependencies": {
"@tanstack/react-query": "^4.28.0",

View file

@ -41,7 +41,14 @@
"prepare": "node config/prepare.js",
"lint:fix": "eslint --fix \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
"lint": "eslint \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
"format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\""
"format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
"b:api": "NODE_ENV=production bun run api/server/index.js",
"b:api:dev": "NODE_ENV=development bun run --watch api/server/index.js",
"b:data-provider": "cd packages/data-provider && bun run b:build",
"b:client": "bun run b:data-provider && cd client && bun run b:build",
"b:client:dev": "cd client && bun run b:dev",
"b:test:client": "cd client && bun run test",
"b:test:api": "cd api && bun run test"
},
"repository": {
"type": "git",

View file

@ -11,7 +11,9 @@
"build:watch": "rollup -c -w",
"test": "jest --coverage --watch",
"test:ci": "jest --coverage --ci",
"verify": "npm run test:ci"
"verify": "npm run test:ci",
"b:clean": "bun run rimraf dist",
"b:build": "bun run b:clean && bun run rollup -c --silent --bundleConfigAsCjs"
},
"repository": {
"type": "git",