Skip to content

Commit

Permalink
Initialize
Browse files Browse the repository at this point in the history
  • Loading branch information
superoo7 committed Jul 19, 2024
0 parents commit 6326e66
Show file tree
Hide file tree
Showing 48 changed files with 2,377 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# IDE
.idea
.vscode

# Build
node_modules/
dist/
coverage

# Environment Files
.env

# Configuration Files
Dockerfile
.dockerignore
.git
.gitignore

# Logs
npm-debug.log

# Documentation
README.md


29 changes: 29 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
PORT=3001
LOGGER_LEVEL=debug

# Chasm
# Orchestrator URL
ORCHESTRATOR_URL=
SCOUT_NAME=
# Scout UID
SCOUT_UID=
# Scout API Key
WEBHOOK_API_KEY=
# Scout Webhook Url, update based on your server's IP and Port, e.g. http://123.123.123.123:3001/
WEBHOOK_URL=

# Chosen Provider (groq, openrouter)
# Seperated by comma (,)
# The scout will prioritize the first provider and fallback to the next one
PROVIDERS=groq,openrouter
MODEL=gemma-7b-it

# Provider
GROQ_API_KEY=

# Optional
OPENAI_API_KEY=
OPENROUTER_API_KEY=

#local or production
NODE_ENV=local
31 changes: 31 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# IDE
.idea/
.vscode/

# Dependencies
node_modules/
dist/
coverage
package.json

# Docker Configs
docker-compose.yml

# System Files
.DS_Store
Thumbs.db

# Environment Files
.env

# Configuration Files
tsconfig.json
.eslintrc.json
.prettierrc.json
.lintstagedrc.json

# GitHub Actions
.github/

# Logs
*.log
37 changes: 37 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"env": {
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"plugins": [
"@typescript-eslint",
"unused-imports"
],
"rules": {
"prefer-const": "warn",
"no-self-assign": "warn",
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-var-requires": "warn",
"@typescript-eslint/no-unused-vars": "off", //"no-unused-vars": "off",
"unused-imports/no-unused-imports": "warn",
"unused-imports/no-unused-vars": [
"warn",
{
"vars": "all",
"varsIgnorePattern": "^_",
"args": "after-used",
"argsIgnorePattern": "^_"
}
]
}
}
135 changes: 135 additions & 0 deletions .github/workflows/pre-merge-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Pre-merge Checks

on:
pull_request:
branches: [ main, master ]

jobs:
checkout-install:
name: Checkout and Install Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Cache Bun packages
id: cache-bun
uses: actions/cache@v3
with:
path: |
~/.bun/bun
~/.bun/install
~/.bun/bin
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install

- name: Upload Bun cache
if: steps.cache-bun.outputs.cache-hit != 'true'
uses: actions/cache@v3
with:
path: |
~/.bun/bun
~/.bun/install
~/.bun/bin
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}

formatting-linting:
name: Formatting and Linting Checks
runs-on: ubuntu-latest
needs: checkout-install
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Bun cache
uses: actions/cache@v3
with:
path: |
~/.bun/bun
~/.bun/install
~/.bun/bin
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Run formatting checks
run: bun run prettier

- name: Run linting checks
run: bun run lint

jest-tests:
name: Jest Tests
runs-on: ubuntu-latest
needs: checkout-install
environment: CI
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Bun cache
uses: actions/cache@v3
with:
path: |
~/.bun/bun
~/.bun/install
~/.bun/bin
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Run Jest unit & integration tests
env:
OPENAI_API_KEY: ${{ vars.OPENAI_API_KEY }}
GROQ_API_KEY: ${{ vars.GROQ_API_KEY }}
OPENROUTER_API_KEY: ${{ vars.OPENROUTER_API_KEY }}
run: bun run test --verbose

type-check:
name: Type Checks
runs-on: ubuntu-latest
needs: [formatting-linting, jest-tests]
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Restore Bun cache
uses: actions/cache@v3
with:
path: |
~/.bun/bun
~/.bun/install
~/.bun/bin
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install dependencies
run: bun install

- name: Run type checks
run: bun run build
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# IDE
.idea
.vscode

# Build
node_modules/
dist/
coverage

# System Files
.DS_Store
Thumbs.db

# Environment Files
.env
.env.prod
.env.test
.env.test

# Logs
*.log
3 changes: 3 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bunx lint-staged
bun run build
# bun run test
9 changes: 9 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"*.ts": [
"bun run prettier:fix",
"bun run lint"
],
"*.md": [
"bun run prettier:fix"
]
}
31 changes: 31 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# IDE
.idea/
.vscode/

# Dependencies
node_modules/
dist/
coverage
package.json

# Docker Configs
docker-compose.yml

# System Files
.DS_Store
Thumbs.db

# Environment Files
.env

# Configuration Files
tsconfig.json
.eslintrc.json
.prettierrc.json
.lintstagedrc.json

# GitHub Actions
.github/

# Logs
*.log
26 changes: 26 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"quoteProps": "consistent",
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"proseWrap": "preserve",
"importOrder": [
"^dotenv(.*)$",
"<THIRD_PARTY_MODULES>",
"",
"^[./]"
],
"importOrderParserPlugins": [
"typescript",
"jsx",
"decorators-legacy"
],
"importOrderTypeScriptVersion": "5.0.0",
"plugins": [
"@ianvs/prettier-plugin-sort-imports"
]
}
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM oven/bun:alpine AS builder

ENV PATH="/root/.bun/bin:${PATH}"
WORKDIR /usr/src/app
COPY package.json tsconfig.json bun.lockb* ./
RUN bun install
COPY src ./src
RUN bun run build


FROM oven/bun:alpine

ENV PATH="/root/.bun/bin:${PATH}"
WORKDIR /usr/src/app
COPY --from=builder /usr/src/app/dist ./dist
COPY --from=builder /usr/src/app/package.json ./package.json
RUN bun install --production --ignore-scripts
EXPOSE 3001

RUN addgroup -S scout && adduser -S appuser -G scout
RUN chown -R appuser:scout /usr/src/app/
USER appuser

CMD ["bun", "run", "dist/src/server/express.js"]
Loading

0 comments on commit 6326e66

Please sign in to comment.