Skip to content

Commit

Permalink
feat: switch to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
KagamiChan committed Jan 23, 2021
1 parent 0ce6b2d commit 8737b24
Show file tree
Hide file tree
Showing 32 changed files with 903 additions and 71 deletions.
24 changes: 11 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@ module.exports = {
es6: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:import/errors', 'plugin:import/warnings', 'prettier'],
parser: 'babel-eslint',
plugins: ['import', 'prettier'],
extends: [
'eslint:recommended',
'plugin:import/errors',
'plugin:import/warnings',
'plugin:import/typescript',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
],
parser: '@typescript-eslint/parser',
plugins: ['import', 'prettier', '@typescript-eslint'],
rules: {
'no-console': 'off',
'no-var': 'error',
'no-unused-vars': ['warn', { args: 'none' }],
'prettier/prettier': 'error',
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.es', '.coffee', '.cjsx'],
paths: [__dirname],
},
},
},
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"source.fixAll.eslint": true
},
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true
"files.trimTrailingWhitespace": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
20 changes: 9 additions & 11 deletions app.js → app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ import Cache from 'node-cache'
import mongoose from 'mongoose'
import childProcess from 'child_process'
import { trim } from 'lodash'
import bytes from 'bytes'

import config from './config'
import {
captureException,
sentryTracingMiddileaware,
reportCustomExceptionsMiddleware,
} from './sentry'
import { captureException, sentryTracingMiddileaware } from './src/sentry'

import './models'
import { router } from './controllers'
import './src/models'
import { router } from './src/controllers'

const app = new Koa()

Expand All @@ -30,7 +27,6 @@ mongoose.connection.on('error', () => {
})

app.use(sentryTracingMiddileaware)
app.use(reportCustomExceptionsMiddleware)

// Logger
if (!config.disableLogger) {
Expand All @@ -44,9 +40,11 @@ const _cache = new Cache({
})
app.use(
cache({
threshold: '1GB', // Compression is handled by nginx.
get: (key, maxAge) => _cache.get(key),
set: (key, value, maxAge) => _cache.set(key, value, maxAge > 0 ? maxAge : null),
threshold: bytes('1GB'), // Compression is handled by nginx.
get: async (key) => _cache.get(key),
set: async (key, value, maxAge) => {
_cache.set(key, value, maxAge > 0 ? maxAge : 0)
},
}),
)

Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: '14' } }]],
presets: [['@babel/preset-env', { targets: { node: '14' } }], '@babel/preset-typescript'],
plugins: [require.resolve('babel-plugin-add-module-exports')],
}
File renamed without changes.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require('@babel/register')({
cache: false,
extensions: ['.ts'],
})

require('./app')
13 changes: 0 additions & 13 deletions models/report/battle-api.js

This file was deleted.

Loading

0 comments on commit 8737b24

Please sign in to comment.