Skip to content

Commit

Permalink
Merge pull request #336 from cofacts/typescript
Browse files Browse the repository at this point in the history
Add Typescript support
  • Loading branch information
MrOrz authored May 6, 2024
2 parents f2a902b + 17aade7 commit 0179daa
Show file tree
Hide file tree
Showing 12 changed files with 1,486 additions and 288 deletions.
3 changes: 2 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"targets": {
"node": "current"
}
}]
}],
"@babel/preset-typescript"
],
"plugins": [
["module-resolver", {
Expand Down
6 changes: 6 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,9 @@ OPENAI_API_KEY=

# When LOG_REQUESTS exists, it also shows incoming GraphQL operation, variables, and resolved user info
LOG_REQUESTS=

# If given, API server will link to Google Pub/Sub using Application Default Credentials,
# to receive and execute administrative commands.
# It will create the topic, subscription and schema if not exists.
#
ADMIN_PUBSUB_TOPIC=
36 changes: 24 additions & 12 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,31 @@ module.exports = {
'plugin:import/warnings',
'prettier',
],
env: {node: true, es6: true, jest: true},
plugins: [
'prettier',
],
env: { node: true, es6: true, jest: true },
plugins: ['prettier', 'import'],
rules: {
'prettier/prettier': ['error', {
trailingComma: 'es5',
'singleQuote': true,
}],
'prettier/prettier': [
'error',
{
trailingComma: 'es5',
singleQuote: true,
},
],
},
settings: {
'import/resolver': {
'babel-module': {}
}
}
}
'babel-module': {},
typescript: {},
},
'import/parsers': {
'@typescript-eslint/parser': ['.ts'],
},
},
overrides: [
{
files: ['**/*.ts'],
extends: ['plugin:@typescript-eslint/recommended'],
plugins: ['@typescript-eslint'],
},
],
};
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
service_account: ${{ secrets.GC_SERVICE_ACCOUNT }}
- run: npm ci
- run: npm run lint
- run: npm run typecheck
- run: npm run test -- --coverage
env:
GCS_CREDENTIALS: ${{ secrets.GCS_CREDENTIALS }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN npm install
#
COPY . .

RUN node_modules/.bin/babel src -d build
RUN node_modules/.bin/babel src -d build --extensions ".ts,.js"
RUN npm prune --production

#########################################
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ $ node_modules/.bin/babel-node src/scripts/fetchStatsFromGA.js

- For more options, run the above script with `--help` or see the file level comments.

### Pulling administrative commands from Google Pub/Sub

When API server starts up, it will link to Google Pub/Sub topic if and only if env var `ADMIN_PUBSUB_TOPIC` is set, using [Application Default Credentials](https://cloud.google.com/docs/authentication/application-default-credentials).

### Removing article-reply from database
- To set an article-reply to deleted state on production, run:
```
Expand Down
8 changes: 8 additions & 0 deletions ecosystem.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,13 @@ module.exports = {
out_file: '/dev/null',
error_file: '/dev/null',
},
{
name: 'command-listener',
script: 'build/commandListener.js',
instances: 1,
exec_mode: 'cluster',
out_file: '/dev/null',
error_file: '/dev/null',
},
],
};
Loading

0 comments on commit 0179daa

Please sign in to comment.