diff --git a/server/config/app.ts b/server/config/app.ts index 1a70dcf..08b87c0 100644 --- a/server/config/app.ts +++ b/server/config/app.ts @@ -7,12 +7,10 @@ import proxyAddr from 'proxy-addr' import Env from '@ioc:Adonis/Core/Env' +import { ServerConfig } from '@ioc:Adonis/Core/Server' import { LoggerConfig } from '@ioc:Adonis/Core/Logger' -import { RequestConfig } from '@ioc:Adonis/Core/Request' -import { ResponseConfig } from '@ioc:Adonis/Core/Response' import { ProfilerConfig } from '@ioc:Adonis/Core/Profiler' - -type HttpConfig = RequestConfig & ResponseConfig +import { ValidatorConfig } from '@ioc:Adonis/Core/Validator' /* |-------------------------------------------------------------------------- @@ -27,7 +25,7 @@ type HttpConfig = RequestConfig & ResponseConfig | be decrypted. | */ -export const appKey: string = Env.get('APP_KEY') as string +export const appKey: string = Env.get('APP_KEY') /* |-------------------------------------------------------------------------- @@ -38,7 +36,7 @@ export const appKey: string = Env.get('APP_KEY') as string | the config properties to make keep server secure. | */ -export const http: HttpConfig = { +export const http: ServerConfig = { /* |-------------------------------------------------------------------------- | Allow method spoofing @@ -149,7 +147,7 @@ export const logger: LoggerConfig = { | reading the `name` property from the `package.json` file. | */ - name: Env.get('APP_NAME') as string, + name: Env.get('APP_NAME'), /* |-------------------------------------------------------------------------- @@ -171,7 +169,7 @@ export const logger: LoggerConfig = { | at deployment level and not code level. | */ - level: Env.get('LOG_LEVEL', 'info') as string, + level: Env.get('LOG_LEVEL', 'info'), /* |-------------------------------------------------------------------------- @@ -223,3 +221,14 @@ export const profiler: ProfilerConfig = { */ whitelist: [], } + +/* +|-------------------------------------------------------------------------- +| Validator +|-------------------------------------------------------------------------- +| +| Configure the global configuration for the validator. Here's the reference +| to the default config https://git.io/JT0WE +| +*/ +export const validator: ValidatorConfig = {} diff --git a/server/config/bodyparser.ts b/server/config/bodyparser.ts index 0e2818a..65e2ca2 100644 --- a/server/config/bodyparser.ts +++ b/server/config/bodyparser.ts @@ -53,9 +53,7 @@ const bodyParserConfig: BodyParserConfig = { encoding: 'utf-8', limit: '1mb', queryString: {}, - types: [ - 'application/x-www-form-urlencoded', - ], + types: ['application/x-www-form-urlencoded'], }, /* @@ -72,9 +70,7 @@ const bodyParserConfig: BodyParserConfig = { encoding: 'utf-8', limit: '1mb', queryString: {}, - types: [ - 'text/*', - ], + types: ['text/*'], }, /* @@ -177,9 +173,7 @@ const bodyParserConfig: BodyParserConfig = { | The types that will be considered and parsed as multipart body. | */ - types: [ - 'multipart/form-data', - ], + types: ['multipart/form-data'], }, } diff --git a/server/config/hash.ts b/server/config/hash.ts index 0e1e6f9..cd731e6 100644 --- a/server/config/hash.ts +++ b/server/config/hash.ts @@ -27,7 +27,7 @@ const hashConfig: HashConfig = { | free to change the default value | */ - default: Env.get('HASH_DRIVER', 'argon') as 'argon', + default: Env.get('HASH_DRIVER', 'argon'), list: { /* diff --git a/server/config/redis.ts b/server/config/redis.ts index d3522b1..3d8a6ce 100644 --- a/server/config/redis.ts +++ b/server/config/redis.ts @@ -22,7 +22,7 @@ import { RedisConfig } from '@ioc:Adonis/Addons/Redis' | Make sure to check `contracts/redis.ts` file for defining extra connections */ const redisConfig: RedisConfig = { - connection: Env.get('REDIS_CONNECTION', 'local') as 'local', + connection: Env.get('REDIS_CONNECTION'), connections: { /* @@ -36,9 +36,9 @@ const redisConfig: RedisConfig = { | */ local: { - host: Env.get('REDIS_HOST', '127.0.0.1') as string, - port: Env.get('REDIS_PORT', '6379') as string, - password: Env.get('REDIS_PASSWORD', '') as string, + host: Env.get('REDIS_HOST'), + port: Env.get('REDIS_PORT'), + password: Env.get('REDIS_PASSWORD', ''), db: 0, keyPrefix: '', }, diff --git a/server/contracts/league.ts b/server/contracts/league.ts deleted file mode 100644 index 144c28e..0000000 --- a/server/contracts/league.ts +++ /dev/null @@ -1,3 +0,0 @@ -declare module '@ioc:Adonis/League' { - -} diff --git a/server/providers/AppProvider.ts b/server/providers/AppProvider.ts index 8408dbe..af35fc6 100644 --- a/server/providers/AppProvider.ts +++ b/server/providers/AppProvider.ts @@ -1,8 +1,9 @@ -import { IocContract } from '@adonisjs/fold' +import { ApplicationContract } from '@ioc:Adonis/Core/Application' export default class AppProvider { - constructor (protected $container: IocContract) { - } + public static needsApplication = true + + constructor (protected app: ApplicationContract) {} public register () { // Register your own bindings @@ -10,16 +11,15 @@ export default class AppProvider { public async boot () { // IoC container is ready - // Load Match Collections await import('App/Repositories/MatchRepository') } - public shutdown () { - // Cleanup, since app is going down - } - - public ready () { + public async ready () { // App is ready } + + public async shutdown () { + // Cleanup, since app is going down + } } diff --git a/server/start/routes.ts b/server/start/routes.ts index f1ed35f..83ccebc 100644 --- a/server/start/routes.ts +++ b/server/start/routes.ts @@ -19,29 +19,8 @@ */ import Route from '@ioc:Adonis/Core/Route' -import mongodb from '@ioc:Mongodb/Database' -import Jax from 'App/Services/Jax' -Route.get('/', async () => { - return { hello: 'world' } -}) - -Route.get('mongo', async () => { - const match = await (await mongodb.connection().collection('matches')).findOne({}) - return { test: match } -}) - -Route.get('jax', async () => { - const summoner = await Jax.Summoner.summonerName('LeagueStats GG', 'euw1') - return { player: summoner } -}) - -Route.get('test', async () => { - const summonersCollection = await mongodb.connection().collection('summoners') - const summonerDB = await summonersCollection.findOne({ puuid: 1234 }) - - return { player: summonerDB } -}) +Route.get('/', async () => ({ hi: 'Hello World from LeagueStats API', uptime: process.uptime() })) Route.post('/summoner/basic', 'SummonersController.basic') Route.post('/summoner/overview', 'SummonersController.overview')