Skip to content

Commit

Permalink
refactor: Migrate from Fastify to Elysia
Browse files Browse the repository at this point in the history
  • Loading branch information
zAlweNy26 committed Jun 30, 2024
1 parent 635c6bc commit 6d2b0f9
Show file tree
Hide file tree
Showing 23 changed files with 1,482 additions and 1,747 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm run typecheck
- run: pnpm run lint
- run: pnpm run test
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- run: bun run typecheck
- run: bun run lint
- run: bun run test
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ Check out the [linked project](https://github.com/zAlweNy26/ts-cat/projects?quer

## Pre-requisites

- Node.js 18.x
- pnpm 8.10.x
- Bun (>= 1.1.0)

## Installation

```bash
# (for development)
pnpm install
bun install
rm -f .git/hooks/pre-commit && ln -s ../../pre-commit .git/hooks/pre-commit

# (for production)
Expand All @@ -57,9 +56,9 @@ docker compose build --no-cache

```bash
# (for development, with watcher)
pnpm run dev
bun run dev
# (for development, without watcher)
pnpm start
bun start

# (for production)
docker compose up
Expand All @@ -70,5 +69,5 @@ docker compose up
To run the tests, be sure to have the Docker compose up and running. Then you can do:

```bash
docker exec -it ccat_ts pnpm test
docker exec -it ccat_ts bun test
```
Binary file modified bun.lockb
Binary file not shown.
18 changes: 1 addition & 17 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import zodOpenApi from 'eslint-plugin-zod-openapi'
import antfu from '@antfu/eslint-config'

export default antfu({
Expand All @@ -10,17 +9,7 @@ export default antfu({
yaml: true,
markdown: false, // TODO: Temporary fix until code blocks are correctly read
ignores: ['package.json', 'dist/', 'node_modules/', 'test/mocks/'],
plugins: {
'zod-openapi': zodOpenApi,
},
rules: {
// Error: You have used a rule which requires parserServices to be generated.
// You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
/* 'zod-openapi/require-openapi': 'off',
'zod-openapi/require-comment': 'off',
'zod-openapi/require-example': 'off',
'zod-openapi/prefer-zod-default': 'warn',
'zod-openapi/prefer-openapi-last': 'warn', */
'unused-imports/no-unused-vars-ts': 'warn',
'style/max-statements-per-line': 'off',
'regexp/no-unused-capturing-group': 'warn',
Expand All @@ -34,9 +23,4 @@ export default antfu({
'no-console': 'off',
'one-var': 'off',
},
}, /* , {
files: ['src/routes/*.ts'],
rules: {
'zod-openapi/require-openapi': 'error',
},
} */)
})
224 changes: 109 additions & 115 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,117 +1,111 @@
{
"name": "ts-cat",
"type": "module",
"version": "1.2.6",
"private": true,
"description": "TypeScript version of the Cheshire Cat AI project",
"author": "zAlweNy26 & Contributors",
"license": "GPL-3.0-only",
"homepage": "https://github.com/zAlweNy26/ts-cat",
"repository": {
"type": "git",
"url": "https://github.com/zAlweNy26/ts-cat.git"
},
"bugs": {
"url": "https://github.com/zAlweNy26/ts-cat/issues"
},
"keywords": [
"fastify",
"typescript",
"ai",
"javascript",
"cheshire-cat",
"langchain",
"assistant",
"framework",
"bun"
],
"main": "dist/main.js",
"module": "dist/main.mjs",
"types": "dist/main.d.ts",
"files": [
".d.ts",
"dist"
],
"scripts": {
"build": "bun build src/** --outdir ./dist --target bun",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest dev --run",
"test:ui": "vitest dev --ui",
"release": "bun run lint && bun run test && changelogen --release && git push --follow-tags",
"typecheck": "tsc --noEmit",
"dev": "WATCH=true bun --watch run start",
"start": "bun run ./index.ts"
},
"dependencies": {
"@fastify/cors": "^9.0.1",
"@fastify/formbody": "^7.4.0",
"@fastify/multipart": "^8.3.0",
"@fastify/sensible": "^5.6.0",
"@fastify/static": "^7.0.4",
"@fastify/swagger": "^8.14.0",
"@fastify/swagger-ui": "^4.0.0",
"@fastify/websocket": "^9.0.0",
"@langchain/anthropic": "^0.2.2",
"@langchain/azure-openai": "^0.0.11",
"@langchain/cohere": "^0.1.0",
"@langchain/community": "^0.2.15",
"@langchain/core": "^0.2.11",
"@langchain/google-genai": "^0.0.21",
"@langchain/mistralai": "^0.0.24",
"@langchain/openai": "^0.2.1",
"@mgcrea/fastify-request-logger": "^1.6.0",
"@mgcrea/pino-pretty-compact": "^1.3.0",
"@qdrant/js-client-rest": "^1.9.0",
"callsites": "^4.1.0",
"cheerio": "1.0.0-rc.12",
"chokidar": "^3.6.0",
"consola": "^3.2.3",
"console-table-printer": "^2.12.1",
"d3-dsv": "^2.0.0",
"date-fns": "^3.6.0",
"defu": "^6.1.4",
"destr": "^2.0.3",
"dotenv": "^16.4.5",
"fastembed": "^1.14.1",
"fastify": "^4.28.0",
"fastify-zod-openapi": "^1.2.1",
"get-port-please": "^3.1.2",
"html-to-text": "^9.0.5",
"is-docker": "^3.0.0",
"js-tiktoken": "^1.0.12",
"langchain": "^0.2.8",
"lodash": "^4.17.21",
"lowdb": "^7.0.1",
"mammoth": "^1.8.0",
"ofetch": "^1.3.4",
"officeparser": "^4.1.1",
"pdf-parse": "^1.1.1",
"pkg-types": "^1.1.1",
"qs": "^6.12.1",
"scule": "^1.3.0",
"turbowatch": "^2.29.4",
"uncrypto": "^0.1.3",
"zod": "^3.23.8",
"zod-openapi": "^2.19.0",
"zod-to-json-schema": "^3.23.1"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.2",
"@total-typescript/ts-reset": "^0.5.1",
"@types/bun": "^1.1.6",
"@types/lodash": "^4.17.6",
"@types/nodemon": "^1.19.6",
"@types/qs": "^6.9.15",
"@types/ws": "^8.5.10",
"@vitest/ui": "^1.6.0",
"changelogen": "^0.5.5",
"eslint": "^8.57.0",
"eslint-plugin-zod-openapi": "^0.1.0",
"magicast": "^0.3.4",
"nodemon": "^3.1.0",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
"name": "ts-cat",
"type": "module",
"version": "1.2.6",
"private": true,
"description": "TypeScript version of the Cheshire Cat AI project",
"author": "zAlweNy26 & Contributors",
"license": "GPL-3.0-only",
"homepage": "https://github.com/zAlweNy26/ts-cat",
"repository": {
"type": "git",
"url": "https://github.com/zAlweNy26/ts-cat.git"
},
"bugs": {
"url": "https://github.com/zAlweNy26/ts-cat/issues"
},
"keywords": [
"elysia",
"typescript",
"ai",
"javascript",
"cheshire-cat",
"langchain",
"assistant",
"framework",
"bun"
],
"main": "dist/main.js",
"module": "dist/main.mjs",
"types": "dist/main.d.ts",
"files": [
".d.ts",
"dist"
],
"scripts": {
"build": "bun build src/** --outdir ./dist --target bun",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest dev --run",
"test:ui": "vitest dev --ui",
"release": "bun run lint && bun run test && changelogen --release && git push --follow-tags",
"typecheck": "tsc --noEmit",
"dev": "WATCH=true bun --watch run start",
"start": "NODE_ENV=production bun run ./index.ts"
},
"dependencies": {
"@elysiajs/cors": "^1.0.2",
"@elysiajs/eden": "^1.0.14",
"@elysiajs/server-timing": "^1.0.2",
"@elysiajs/static": "^1.0.3",
"@elysiajs/stream": "^1.0.3",
"@elysiajs/swagger": "^1.0.5",
"@langchain/anthropic": "^0.2.2",
"@langchain/azure-openai": "^0.0.11",
"@langchain/cohere": "^0.1.0",
"@langchain/community": "^0.2.15",
"@langchain/core": "^0.2.11",
"@langchain/google-genai": "^0.0.21",
"@langchain/mistralai": "^0.0.24",
"@langchain/openai": "^0.2.1",
"@mgcrea/pino-pretty-compact": "^1.3.0",
"@qdrant/js-client-rest": "^1.9.0",
"callsites": "^4.1.0",
"cheerio": "1.0.0-rc.12",
"chokidar": "^3.6.0",
"consola": "^3.2.3",
"console-table-printer": "^2.12.1",
"d3-dsv": "^2.0.0",
"date-fns": "^3.6.0",
"defu": "^6.1.4",
"destr": "^2.0.3",
"dotenv": "^16.4.5",
"elysia": "^1.0.25",
"fastembed": "^1.14.1",
"get-port-please": "^3.1.2",
"html-to-text": "^9.0.5",
"is-docker": "^3.0.0",
"js-tiktoken": "^1.0.12",
"langchain": "^0.2.8",
"lodash": "^4.17.21",
"lowdb": "^7.0.1",
"mammoth": "^1.8.0",
"ofetch": "^1.3.4",
"officeparser": "^4.1.1",
"pdf-parse": "^1.1.1",
"pkg-types": "^1.1.1",
"qs": "^6.12.1",
"scule": "^1.3.0",
"turbowatch": "^2.29.4",
"uncrypto": "^0.1.3",
"zod": "^3.23.8",
"zod-to-json-schema": "^3.23.1"
},
"devDependencies": {
"@antfu/eslint-config": "^2.21.2",
"@total-typescript/ts-reset": "^0.5.1",
"@types/bun": "^1.1.6",
"@types/lodash": "^4.17.6",
"@types/nodemon": "^1.19.6",
"@types/qs": "^6.9.15",
"@types/ws": "^8.5.10",
"@vitest/ui": "^1.6.0",
"changelogen": "^0.5.5",
"eslint": "^8.57.0",
"magicast": "^0.3.4",
"nodemon": "^3.1.0",
"typescript": "^5.4.5",
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^1.6.0"
}
}
Loading

0 comments on commit 6d2b0f9

Please sign in to comment.