mirror of
https://github.com/roleypoly/roleypoly-v1.git
synced 2025-04-24 19:59:12 +00:00
chore: prettier Server
This commit is contained in:
parent
d08c9e4829
commit
5119e1142c
5 changed files with 16 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
module.exports = (R, $) => {
|
||||
R.post('/api/auth/token', async ctx => {
|
||||
R.post('/api/auth/token', async (ctx) => {
|
||||
const { token } = ctx.request.body
|
||||
|
||||
if (token == null || token === '') {
|
||||
|
@ -27,7 +27,7 @@ module.exports = (R, $) => {
|
|||
}
|
||||
})
|
||||
|
||||
R.get('/api/auth/user', async ctx => {
|
||||
R.get('/api/auth/user', async (ctx) => {
|
||||
if (ctx.session.accessToken === undefined) {
|
||||
ctx.body = { err: 'not_logged_in' }
|
||||
ctx.status = 401
|
||||
|
@ -46,7 +46,7 @@ module.exports = (R, $) => {
|
|||
}
|
||||
})
|
||||
|
||||
R.get('/api/auth/redirect', ctx => {
|
||||
R.get('/api/auth/redirect', (ctx) => {
|
||||
const url = $.discord.getAuthUrl()
|
||||
if (ctx.query.url === '✔️') {
|
||||
ctx.body = { url }
|
||||
|
@ -56,11 +56,11 @@ module.exports = (R, $) => {
|
|||
ctx.redirect(url)
|
||||
})
|
||||
|
||||
R.post('/api/auth/logout', ctx => {
|
||||
R.post('/api/auth/logout', (ctx) => {
|
||||
ctx.session = null
|
||||
})
|
||||
|
||||
R.get('/api/oauth/bot', ctx => {
|
||||
R.get('/api/oauth/bot', (ctx) => {
|
||||
const url = $.discord.getBotJoinUrl()
|
||||
if (ctx.query.url === '✔️') {
|
||||
ctx.body = { url }
|
||||
|
@ -70,5 +70,5 @@ module.exports = (R, $) => {
|
|||
ctx.redirect(url)
|
||||
})
|
||||
|
||||
R.get('/api/oauth/bot/callback', ctx => {})
|
||||
R.get('/api/oauth/bot/callback', (ctx) => {})
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ const Roleypoly = require('./Roleypoly')
|
|||
const ksuid = require('ksuid')
|
||||
|
||||
// monkey patch async-reduce because F U T U R E
|
||||
Array.prototype.areduce = async function(predicate, acc = []) {
|
||||
Array.prototype.areduce = async function (predicate, acc = []) {
|
||||
// eslint-disable-line
|
||||
for (let i of this) {
|
||||
acc = await predicate(acc, i)
|
||||
|
@ -23,8 +23,8 @@ Array.prototype.areduce = async function(predicate, acc = []) {
|
|||
|
||||
Array.prototype.filterNot =
|
||||
Array.prototype.filterNot ||
|
||||
function(predicate) {
|
||||
return this.filter(v => !predicate(v))
|
||||
function (predicate) {
|
||||
return this.filter((v) => !predicate(v))
|
||||
}
|
||||
|
||||
// Create the server and socket.io server
|
||||
|
@ -139,6 +139,6 @@ async function start() {
|
|||
server.listen(process.env.APP_PORT || 6769)
|
||||
}
|
||||
|
||||
start().catch(e => {
|
||||
start().catch((e) => {
|
||||
log.fatal('app failed to start', e)
|
||||
})
|
||||
|
|
|
@ -2,12 +2,12 @@ const log = new (require('../logger'))('models/index')
|
|||
const glob = require('glob')
|
||||
const path = require('path')
|
||||
|
||||
module.exports = sql => {
|
||||
module.exports = (sql) => {
|
||||
const models = {}
|
||||
const modelFiles = glob.sync('./models/**/!(index).js')
|
||||
log.debug('found models', modelFiles)
|
||||
|
||||
modelFiles.forEach(v => {
|
||||
modelFiles.forEach((v) => {
|
||||
let name = path.basename(v).replace('.js', '')
|
||||
if (v === './models/index.js') {
|
||||
log.debug('index.js hit, skipped')
|
||||
|
@ -23,7 +23,7 @@ module.exports = sql => {
|
|||
}
|
||||
})
|
||||
|
||||
Object.keys(models).forEach(v => {
|
||||
Object.keys(models).forEach((v) => {
|
||||
if (models[v].hasOwnProperty('__associations')) {
|
||||
models[v].__associations(models)
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class PresentationService extends Service {
|
|||
const serverData = await this.ctx.server.get(server.id)
|
||||
const serverRoles = await this.discord.getRoles(server.id)
|
||||
const memberRoles = member.rolesList
|
||||
.map(id => serverRoles.find(role => role.id === id))
|
||||
.map((id) => serverRoles.find((role) => role.id === id))
|
||||
.sort((a, b) => (a.position > b.position ? -1 : 1))
|
||||
|
||||
const color = memberRoles.length > 0 ? memberRoles[0].color : 0
|
||||
|
@ -67,7 +67,7 @@ class PresentationService extends Service {
|
|||
if (process.env.DISABLE_CACHE === 'true') {
|
||||
return func()
|
||||
}
|
||||
|
||||
|
||||
if (this.cache.has(key)) {
|
||||
return this.cache.get(key)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ const ksuid = require('ksuid')
|
|||
|
||||
module.exports = {
|
||||
ksuid(field = 'id') {
|
||||
return async function() {
|
||||
return async function () {
|
||||
this.id = await ksuid.random()
|
||||
return this
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue