aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user-interface.ts
blob: a504f42a1bca74a68bb99e44f1d71f49b6980877 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as Sequelize from 'sequelize'

export namespace UserMethods {
  export type IsPasswordMatch = (password, callback) => void
  export type ToFormatedJSON = () => void
  export type IsAdmin = () => boolean

  export type CountTotal = (callback) => void
  export type GetByUsername = (username) => any
  export type List = (callback) => void
  export type ListForApi = (start, count, sort, callback) => void
  export type LoadById = (id, callback) => void
  export type LoadByUsername = (username, callback) => void
  export type LoadByUsernameOrEmail = (username, email, callback) => void
}

export interface UserClass {
  isPasswordMatch: UserMethods.IsPasswordMatch,
  toFormatedJSON: UserMethods.ToFormatedJSON,
  isAdmin: UserMethods.IsAdmin,

  countTotal: UserMethods.CountTotal,
  getByUsername: UserMethods.GetByUsername,
  list: UserMethods.List,
  listForApi: UserMethods.ListForApi,
  loadById: UserMethods.LoadById,
  loadByUsername: UserMethods.LoadByUsername,
  loadByUsernameOrEmail: UserMethods.LoadByUsernameOrEmail
}

export interface UserAttributes {
  password: string
  username: string
  email: string
  displayNSFW?: boolean
  role: string
}

export interface UserInstance extends UserClass, UserAttributes, Sequelize.Instance<UserAttributes> {
  id: number
  createdAt: Date
  updatedAt: Date
}

export interface UserModel extends UserClass, Sequelize.Model<UserInstance, UserAttributes> {}