mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 12:57:28 +00:00
refactor(api): some more little tweaks to update adonis boilerplate
This commit is contained in:
parent
6f63d67be0
commit
f869e5b12c
7 changed files with 35 additions and 56 deletions
|
|
@ -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 = {}
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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: '',
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
declare module '@ioc:Adonis/League' {
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Reference in a new issue