mirror of
https://github.com/vkaelin/LeagueStats.git
synced 2026-03-25 21:07:27 +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 proxyAddr from 'proxy-addr'
|
||||||
import Env from '@ioc:Adonis/Core/Env'
|
import Env from '@ioc:Adonis/Core/Env'
|
||||||
|
import { ServerConfig } from '@ioc:Adonis/Core/Server'
|
||||||
import { LoggerConfig } from '@ioc:Adonis/Core/Logger'
|
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'
|
import { ProfilerConfig } from '@ioc:Adonis/Core/Profiler'
|
||||||
|
import { ValidatorConfig } from '@ioc:Adonis/Core/Validator'
|
||||||
type HttpConfig = RequestConfig & ResponseConfig
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
@ -27,7 +25,7 @@ type HttpConfig = RequestConfig & ResponseConfig
|
||||||
| be decrypted.
|
| 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.
|
| the config properties to make keep server secure.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
export const http: HttpConfig = {
|
export const http: ServerConfig = {
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
| Allow method spoofing
|
| Allow method spoofing
|
||||||
|
|
@ -149,7 +147,7 @@ export const logger: LoggerConfig = {
|
||||||
| reading the `name` property from the `package.json` file.
|
| 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.
|
| 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: [],
|
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',
|
encoding: 'utf-8',
|
||||||
limit: '1mb',
|
limit: '1mb',
|
||||||
queryString: {},
|
queryString: {},
|
||||||
types: [
|
types: ['application/x-www-form-urlencoded'],
|
||||||
'application/x-www-form-urlencoded',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -72,9 +70,7 @@ const bodyParserConfig: BodyParserConfig = {
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
limit: '1mb',
|
limit: '1mb',
|
||||||
queryString: {},
|
queryString: {},
|
||||||
types: [
|
types: ['text/*'],
|
||||||
'text/*',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -177,9 +173,7 @@ const bodyParserConfig: BodyParserConfig = {
|
||||||
| The types that will be considered and parsed as multipart body.
|
| The types that will be considered and parsed as multipart body.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
types: [
|
types: ['multipart/form-data'],
|
||||||
'multipart/form-data',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ const hashConfig: HashConfig = {
|
||||||
| free to change the default value
|
| free to change the default value
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
default: Env.get('HASH_DRIVER', 'argon') as 'argon',
|
default: Env.get('HASH_DRIVER', 'argon'),
|
||||||
|
|
||||||
list: {
|
list: {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ import { RedisConfig } from '@ioc:Adonis/Addons/Redis'
|
||||||
| Make sure to check `contracts/redis.ts` file for defining extra connections
|
| Make sure to check `contracts/redis.ts` file for defining extra connections
|
||||||
*/
|
*/
|
||||||
const redisConfig: RedisConfig = {
|
const redisConfig: RedisConfig = {
|
||||||
connection: Env.get('REDIS_CONNECTION', 'local') as 'local',
|
connection: Env.get('REDIS_CONNECTION'),
|
||||||
|
|
||||||
connections: {
|
connections: {
|
||||||
/*
|
/*
|
||||||
|
|
@ -36,9 +36,9 @@ const redisConfig: RedisConfig = {
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
local: {
|
local: {
|
||||||
host: Env.get('REDIS_HOST', '127.0.0.1') as string,
|
host: Env.get('REDIS_HOST'),
|
||||||
port: Env.get('REDIS_PORT', '6379') as string,
|
port: Env.get('REDIS_PORT'),
|
||||||
password: Env.get('REDIS_PASSWORD', '') as string,
|
password: Env.get('REDIS_PASSWORD', ''),
|
||||||
db: 0,
|
db: 0,
|
||||||
keyPrefix: '',
|
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 {
|
export default class AppProvider {
|
||||||
constructor (protected $container: IocContract) {
|
public static needsApplication = true
|
||||||
}
|
|
||||||
|
constructor (protected app: ApplicationContract) {}
|
||||||
|
|
||||||
public register () {
|
public register () {
|
||||||
// Register your own bindings
|
// Register your own bindings
|
||||||
|
|
@ -10,16 +11,15 @@ export default class AppProvider {
|
||||||
|
|
||||||
public async boot () {
|
public async boot () {
|
||||||
// IoC container is ready
|
// IoC container is ready
|
||||||
|
|
||||||
// Load Match Collections
|
// Load Match Collections
|
||||||
await import('App/Repositories/MatchRepository')
|
await import('App/Repositories/MatchRepository')
|
||||||
}
|
}
|
||||||
|
|
||||||
public shutdown () {
|
public async ready () {
|
||||||
// Cleanup, since app is going down
|
|
||||||
}
|
|
||||||
|
|
||||||
public ready () {
|
|
||||||
// App is 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 Route from '@ioc:Adonis/Core/Route'
|
||||||
import mongodb from '@ioc:Mongodb/Database'
|
|
||||||
import Jax from 'App/Services/Jax'
|
|
||||||
|
|
||||||
Route.get('/', async () => {
|
Route.get('/', async () => ({ hi: 'Hello World from LeagueStats API', uptime: process.uptime() }))
|
||||||
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.post('/summoner/basic', 'SummonersController.basic')
|
Route.post('/summoner/basic', 'SummonersController.basic')
|
||||||
Route.post('/summoner/overview', 'SummonersController.overview')
|
Route.post('/summoner/overview', 'SummonersController.overview')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue