lerna: split up bulk of packages

This commit is contained in:
41666 2019-04-02 23:10:45 -05:00
parent cb0b1d2410
commit 47a2e5694e
No known key found for this signature in database
GPG key ID: BC51D07640DC10AF
90 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,49 @@
// @flow
import Service from './Service'
import { type AppContext } from '../Roleypoly'
type SessionData = {
rolling: boolean,
maxAge: number,
changed: boolean
}
export default class SessionsService extends Service {
Session: any
constructor (ctx: AppContext) {
super(ctx)
this.Session = ctx.M.Session
}
async get (id: string, { rolling }: SessionData) {
const user = await this.Session.findOne({ where: { id } })
if (user === null) {
return null
}
return user.data
}
async set (id: string, data: any, { maxAge, rolling, changed }: SessionData) {
let session = await this.Session.findOne({ where: { id } })
if (session === null) {
session = this.Session.build({ id })
}
console.log(maxAge)
session.data = data
session.maxAge = maxAge
return session.save()
}
async destroy (id: string) {
const sess = await this.Session.findOne({ where: { id } })
if (sess != null) {
return sess.destroy()
}
}
}