{"id":20439307,"url":"https://github.com/skitsanos/fatsy","last_synced_at":"2025-04-12T22:42:52.565Z","repository":{"id":153096204,"uuid":"553624063","full_name":"skitsanos/fatsy","owner":"skitsanos","description":"Fastify Server Template done in TypeScript","archived":false,"fork":false,"pushed_at":"2025-03-20T06:42:45.000Z","size":139,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-20T07:37:14.904Z","etag":null,"topics":["docker","dockerfile","ecs","fastify","fastify-boilerplate","fastify-template","fastifyjs","hashicorp","hashicorp-waypoint","waypoint","yaml"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/skitsanos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-18T13:58:25.000Z","updated_at":"2025-03-20T06:42:49.000Z","dependencies_parsed_at":"2024-01-08T07:30:41.435Z","dependency_job_id":"df5c9966-97d4-41e2-b242-000d1955c9a4","html_url":"https://github.com/skitsanos/fatsy","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Ffatsy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Ffatsy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Ffatsy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skitsanos%2Ffatsy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skitsanos","download_url":"https://codeload.github.com/skitsanos/fatsy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643045,"owners_count":21138353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","dockerfile","ecs","fastify","fastify-boilerplate","fastify-template","fastifyjs","hashicorp","hashicorp-waypoint","waypoint","yaml"],"created_at":"2024-11-15T09:16:13.100Z","updated_at":"2025-04-12T22:42:52.522Z","avatar_url":"https://github.com/skitsanos.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fatsy\n\n\u003e Fastify Server Template done in TypeScript.\n\n## Routing convention\n\nFatsy is using the same route definition standard as\nin [Foxx Builder](https://github.com/skitsanos/foxx-builder), [Umi](https://umijs.org/), [Ice](https://ice.work/), and\nmany others:\n\n```\n/routes\n-- get.js\n-- /echo\n---- get.js\n-- /users\n---- /$id\n------- get.js\n---- get.js\n---- post.js\n```\n\nThe `routes` folder should contain all your routes. Each route is a folder with a name that is the same as the route\npath. The route path is the path that is used in the browser to access the route. For example, if you have a route\n`/users`, then the route path is `/users`. If your route has a parameter, then the route path contains a `$` followed\nby the name of the parameter.\n\nEach route folder can contain one or more files. Each file is a route handler. The name of the file is the HTTP method\nthat the route handler handles. For example, if you have a route handler that handles the `POST` method, then the name\nof the file is `post.js`. If you have a route handler that handles the `GET` method, then the name of the file\nis `get.js`.\n\n### Support for websockets\n\nIn order to support websockets, you need to create a file `ws.js` in the route folder. This file will be used as a\nwebsocket handler.\n\nThe following example demonstrates how to create a websocket handler that will use [OpenAI](https://openai.com/) to\nanswer questions from the user. It is using [Weaviate](https://www.semi.technology/developers/weaviate/current/) as a\nvector store for the document retrieval and index. \n\n```js\nimport weaviate from 'weaviate-ts-client';\nimport {WeaviateStore} from 'langchain/vectorstores/weaviate';\nimport {OpenAIEmbeddings} from 'langchain/embeddings/openai';\n\nconst ws: FatsyDynamicRoute = {\n    private: false,\n    handler: async (connection: SocketStream, _request: FastifyRequest) =\u003e\n    {\n        const client = weaviate.client({\n            scheme: process.env.WEAVIATE_SCHEME || 'http',\n            host: process.env.WEAVIATE_HOST || 'localhost'\n        });\n\n        const store = await WeaviateStore.fromExistingIndex(new OpenAIEmbeddings(), {\n            client,\n            indexName: 'Test',\n            textKey: 'content',\n            metadataKeys: ['productId', 'versionId']\n        });\n\n        const chat = new OpenAI({\n            streaming: true,\n            callbacks: [\n                {\n                    handleLLMNewToken(token)\n                    {\n                        connection.socket.send(token);\n                    }\n                }\n            ]\n        });\n\n        const chain = ConversationalRetrievalQAChain.fromLLM(\n            chat,\n            store.asRetriever()\n        );\n\n        connection.socket.on('message', async (message: string) =\u003e\n        {\n            await chain.call({\n                question: message.toString(),\n                chat_history: []\n            });\n        });\n\n        connection.socket.on('close', () =\u003e\n        {\n            console.log('Client disconnected');\n        });\n    }\n};\n\nexport default ws;\n```\n\n## Config is in YAML format\n\nNo more confusing JSON, - simple and readable YAML config\n\n```yaml\napp:\n  title: My demo API server\n\nserver:\n  host: \"0.0.0.0\"\n  port: 3000\n  logger:\n    level: trace\n```\n\n### Core features available\n\n- [x] Application routing convention similar to the one we use\n  on [Foxx Builder](https://github.com/skitsanos/foxx-builder)\n- [x] Application configuration with load order to the `config` npm package, so the first one loads is `default`,\n  then `local`,\n  then your `NODE_ENV` profile\n- [x] Templating engine - by default, there is [Handlebars](https://handlebarsjs.com/) bundled for you\n- [x] S3 storage support ([Example](src/routes/api/uploads/s3))\n- [x] Websockets support\n\n### Environments that were tested\n\n- [x] Runs in standalone mode\n- [x] Runs in Docker\n- [x] Runs in Amazon ECS\n- [x] Runs in amazon ECS via HashiCorp waypoint\n\n### Useful links\n\n- [Connect Node.js to MinIO with TLS using AWS S3](https://northflank.com/guides/connect-nodejs-to-minio-with-tls-using-aws-s3)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskitsanos%2Ffatsy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskitsanos%2Ffatsy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskitsanos%2Ffatsy/lists"}