-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(setup): Add basic setup : .gitignore, .eslintrc, Dockerfile and …
…sample app
- Loading branch information
1 parent
643a97f
commit 4eb84e1
Showing
7 changed files
with
3,660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module.exports = { | ||
root: true, | ||
ignorePatterns: [], | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx', 'd.ts'], | ||
}, | ||
}, | ||
}, | ||
env: { | ||
node: true, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaVersion: 12, | ||
sourceType: 'module', | ||
}, | ||
plugins: [ | ||
'@typescript-eslint', | ||
'extra-rules', | ||
], | ||
rules: { | ||
// Following are rules we added to the airbnb-base ruleset. | ||
'extra-rules/no-commented-out-code': 'warn', | ||
|
||
// Following are rules we explicitly don't want to follow. | ||
'no-console': 'off', // Logging is a good practice. | ||
'import/extensions': ['error', 'always', { // Never allow .js .ts in imports. Make transition from .js to .ts easier. | ||
js: 'never', | ||
ts: 'never', | ||
}], | ||
'no-restricted-imports': ['error', { | ||
name: 'pg', | ||
importNames: ['Pool'], | ||
message: 'Use Pool from src/utils/db instead.', | ||
}], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['./src/**/*.test.js'], | ||
globals: { | ||
jest: true, | ||
it: true, | ||
fit: true, | ||
describe: true, | ||
afterAll: true, | ||
beforeAll: true, | ||
afterEach: true, | ||
expect: true, | ||
fail: true, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.env | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# ================================================================================================== | ||
# Build Container | ||
# ================================================================================================== | ||
FROM node:18.15.0 | ||
|
||
WORKDIR /app | ||
|
||
COPY ./package.json /app/package.json | ||
COPY ./yarn.lock /app/yarn.lock | ||
|
||
RUN mkdir /app/src | ||
RUN yarn --frozen-lockfile | ||
|
||
ENV NODE_ENV="production" | ||
|
||
# Copy code | ||
COPY src /app/src | ||
|
||
# Build | ||
RUN npx esbuild src/index.ts --bundle --platform=node --packages=external --outfile=build.js | ||
|
||
# ================================================================================================== | ||
# Server Container | ||
# ================================================================================================== | ||
FROM node:18.15.0 | ||
WORKDIR /app | ||
|
||
# Copy code & node_modules from Build Container | ||
# ================================================================================================== | ||
COPY --from=0 /app/build.js /app/build.js | ||
COPY --from=0 /app/node_modules /app/node_modules | ||
|
||
# 2. Copy non-source code files needed for some modules | ||
# ================================================================================================== | ||
# Package.json to get version number | ||
COPY package.json /app/package.json | ||
|
||
# Prepare container for execution | ||
ENV PORT=80 | ||
ENV NODE_ENV="production" | ||
EXPOSE 80 | ||
|
||
CMD ["node", "build.js"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "assistant", | ||
"version": "1.0.0", | ||
"author": "Thomas Hermine", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"scripts": { | ||
"dev": "nodemon --exec node --loader @esbuild-kit/esm-loader -r @esbuild-kit/cjs-loader src/index.ts", | ||
"d": "yarn dev", | ||
"start": "node --loader @esbuild-kit/esm-loader -r @esbuild-kit/cjs-loader src/index.ts", | ||
"lint": "eslint src --max-warnings=0", | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"@esbuild-kit/esm-loader": "^2.6.5", | ||
"@types/jest": "^29.5.6", | ||
"@typescript-eslint/eslint-plugin": "^6.8.0", | ||
"@typescript-eslint/parser": "^6.8.0", | ||
"eslint": "^8.51.0", | ||
"jest": "^29.7.0", | ||
"nodemon": "^3.0.1", | ||
"ts-jest": "^29.1.1", | ||
"typescript": "^5.2.2" | ||
}, | ||
"dependencies": { | ||
"@esbuild-kit/cjs-loader": "^2.4.4", | ||
"dotenv": "^16.3.1", | ||
"homeassistant": "^0.2.0", | ||
"openai": "^4.12.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'dotenv/config'; | ||
|
||
async function main() { | ||
console.log("Hello, world!"); | ||
} | ||
|
||
main(); |
Oops, something went wrong.