Skip to content
This repository has been archived by the owner on Oct 23, 2020. It is now read-only.

Commit

Permalink
merge: branch 'master' into feat/subject-parse
Browse files Browse the repository at this point in the history
  • Loading branch information
mu-hun committed Nov 15, 2019
2 parents 03222ae + 2bed07c commit 9e8a4d8
Show file tree
Hide file tree
Showing 17 changed files with 954 additions and 176 deletions.
9 changes: 9 additions & 0 deletions prisma/datamodel.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,18 @@ enum SemesterType {

type Semester {
id: ID! @id
subjects: [Subject!]
averagePoint: Float!
totalCredit: Int!
isOutside: Boolean @default(value: false)
year: Int!
semester: SemesterType!
}

type Subject {
id: ID! @id
title: String!
code: String!
grade: String!
course: String!
}
77 changes: 38 additions & 39 deletions src/@types/dreamy.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
type tSemester = '1학기' | '하기계절' | '2학기' | '동기계절'
type tSemesterNum = 10 | 11 | 20 | 21
type tRowCount = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
type tStatus = '재학' | '휴힉'
type tYear = 2018 | 2019
type tBoolInt = 0 | 1
type point =
type SemesterCategory = '1학기' | '하기계절' | '2학기' | '동기계절'
type SemesterNum = 10 | 11 | 20 | 21
type RowCount = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
type Status = '재학' | '휴힉'
type Year = 2018 | 2019
type BoolInt = 0 | 1
type Point =
| 4.3
| 4.0
| 3.7
Expand All @@ -19,7 +19,7 @@ type point =
| 0.7
| 0.0

export type gradePoint =
export type GradePoint =
| 'A+'
| 'A0'
| 'A-'
Expand All @@ -34,7 +34,7 @@ export type gradePoint =
| 'D-'
| 'F'

export enum grade {
export enum GradeNum {
'A+' = 4.3,
'A0' = 4.0,
'A-' = 3.7,
Expand All @@ -50,15 +50,15 @@ export enum grade {
'F' = 0,
}

export type course =
export type Course =
| '기초교양'
| '전공탐색'
| '전인교양'
| '전공선택'
| '전공필수'
| '일반선택'

type tUnivs =
type Univs =
| '인문대학'
| '사회과학대학'
| '경상대학'
Expand All @@ -74,38 +74,37 @@ type tUnivs =
| '예술대자인대학'
| '미래융합대학'

export interface gradeSet {
export interface GradeSet {
credit: 0 | 2 | 3 | 4
dg_gb: gradePoint
dg_gb: GradePoint
isu_cd:
| 'A.기초교양'
| 'B.전공탐색'
| 'T.전인교양'
| 'L.전공선택'
| 'D.전공필수'
| 'G.일반선택'
isu_nm: course

mark: point
rownum: tRowCount
isu_nm: Course
mark: Point
rownum: RowCount
subject_cd: string // 과목 코드
subject_nm: string // 고목 이름
term_gb: tSemester
year: tYear
term_gb: SemesterCategory
year: Year
}

export interface listItem {
export interface ListItem {
avg_mark: number
get_credit: number
outside_seq: 0 | 1
rownum: tRowCount
term_gb: tSemesterNum
term_mn: tSemester
rownum: RowCount
term_gb: SemesterNum
term_mn: SemesterCategory
tot_mark: 32.3
year: tYear
year: Year
}

export interface personalInfo {
export interface PersonalInfo {
cls_cd: number
cls_nm: string // 학과
course_gb: number
Expand All @@ -114,14 +113,14 @@ export interface personalInfo {
nm: string // 이름,
nm_eng: string // 영문이름
rownum: 0
status_gb: tStatus
status_gb: Status
status_gb2: 1 | 0
stu_gb: 1
student_no: number
univ_cd: number
}

export interface parent_grade_props {
export interface ParentGradeProps {
apply_credit: number
avg_mark: number
avg_mark45: number
Expand All @@ -132,28 +131,28 @@ export interface parent_grade_props {
}

export type PostprocessedList = {
TERMNOW_DATA: listItem[]
PERSON_DATA: personalInfo
TOP_DATA: parent_grade_props
TERMNOW_DATA: ListItem[]
PERSON_DATA: PersonalInfo
TOP_DATA: ParentGradeProps
}

export interface current_searched_grade_summary extends parent_grade_props {
year: tYear
term_gb: tSemester
export interface CurrentSearchedGradeSummary extends ParentGradeProps {
year: Year
term_gb: SemesterCategory
outside_gb?: '교류수학'
}

interface total_grade_summery extends parent_grade_props {
interface TotalGradeSummary extends ParentGradeProps {
cls_cd: string
grade: '1학년' | '2학년' | '3학년' | '4학년'
nm: string
rownum: 0
status_gb: tStatus
student_no: tYmber
univ_cd: tUnivs
status_gb: Status
student_no: number
univ_cd: Univs
}

export type PostprocessedItem = {
GRID_DATA: gradeSet[]
BOTTOM_DATA: current_searched_grade_summary
GRID_DATA: GradeSet[]
BOTTOM_DATA: CurrentSearchedGradeSummary
}
2 changes: 1 addition & 1 deletion src/@types/env.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface TypeEnv extends NodeJS.ProcessEnv {
export interface Env extends NodeJS.ProcessEnv {
service: 'gmail'
user: string
pass: string
Expand Down
16 changes: 8 additions & 8 deletions src/@types/models.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { gradePoint, course } from './dreamy'
import { GradePoint, Course } from './dreamy'

export interface TypeUserNoPw {
export interface UserNoPw {
student_no: number
student_pw: string
}

type Subject = {
title: string
code: string
grade: gradePoint
type: course
grade: GradePoint
type: Course
}

export type TypeSemester = {
export type Semester = {
subject: Subject[]
averagePoint: number // Float
totalCredit: number
Expand All @@ -21,14 +21,14 @@ export type TypeSemester = {
year: number
}

export type TypeUser = {
export type User = {
name: string | null
mailid: string
averagePoint: number // Float
semesters: TypeSemester[] | null
semesters: Semester[] | null
}

export enum enumSemester {
export enum EnumSemester {
'1학기' = 'FIRST',
'하기계절' = 'SUMMER',
'2학기' = 'SECOND',
Expand Down
26 changes: 13 additions & 13 deletions src/@types/params.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
import { Request, Response } from 'express'
import { Dictionary } from 'lodash'
import { TypeUserNoPw } from './models'
import { UserNoPw } from './models'

export interface TypeReqAuth extends Request<Dictionary<string>> {
body: TypeUserNoPw
export interface ReqAuth extends Request<Dictionary<string>> {
body: UserNoPw
}

export interface TypeReq<T> extends Request {
export interface Req<T> extends Request {
body: T
}

export interface TypeRes<T> extends Response {
export interface Res<T> extends Response {
body: T
}

export type TypePayload = {
export type Payload = {
mailid: string
iat: number
exp: number
}

export interface TypePayloadRes extends Response {
locals: TypePayload
export interface ResPayload extends Response {
locals: Payload
}

export type TypeSearchForm = {
export type SearchForm = {
mode: 'doSearch'
}

export type TypeListForm = {
export type ListForm = {
mode: 'doList'
year: number
term_gb: 10 | 11 | 20 | 21
outside_seq: 0 | 1
}

export type TypeSearchOrList = TypeSearchForm | TypeListForm
export type SearchOrList = SearchForm | ListForm

export interface TypeFechParam extends TypeUserNoPw {
form: TypeSearchOrList
export interface FechParam extends UserNoPw {
form: SearchOrList
}
4 changes: 2 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import request from 'request'

type TypeRes = {
type Res = {
result: boolean
isUserExist?: 'Y'
}
Expand All @@ -19,7 +19,7 @@ export const isNotVaild = (emailId: string) =>
// jsonReviver: (body: string) => JSON.parse(body),
},
(err, req, body: string) => {
const { result }: TypeRes = JSON.parse(body)
const { result }: Res = JSON.parse(body)
res(result)
}
)
Expand Down
4 changes: 2 additions & 2 deletions src/checkVaild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isUserExist, createUser } from './models'
import { signToken } from './jwt'
import { searchUser } from './models'

type TypeRes = {
type Res = {
result: boolean
isUserExist?: 'Y'
}
Expand All @@ -23,7 +23,7 @@ const isNotVaild = (mailid: string) =>
// jsonReviver: (body: string) => JSON.parse(body),
},
(err, req, body: string) => {
const { result }: TypeRes = JSON.parse(body)
const { result }: Res = JSON.parse(body)
res(result)
}
)
Expand Down
4 changes: 2 additions & 2 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import dotenv from 'dotenv'

import app from '.'
import { signToken } from './jwt'
import { TypeUser } from './@types/models'
import { User } from './@types/models'

interface TypeRes extends request.Response {
body: TypeUser
body: User
}

const invaild = 'INVAILD'
Expand Down
8 changes: 4 additions & 4 deletions src/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import crypto from 'crypto'

import { base64EncodeReplace } from './utils/base64'

import { TypePayloadRes, TypePayload } from './@types/params'
import { ResPayload, Payload } from './@types/params'
import { RequestHandler } from 'express-serve-static-core'
import { Dictionary } from 'lodash'
import { TypeUser } from './@types/models'
import { User } from './@types/models'

dotenv.config()
const secret = process.env.secret!
Expand All @@ -35,7 +35,7 @@ const verify = (token: string) =>

export const ensureAuth = (
req: Request,
res: TypePayloadRes,
res: ResPayload,
next: NextFunction
) => {
const { authorization } = req.headers
Expand All @@ -45,7 +45,7 @@ export const ensureAuth = (
}

try {
res.locals = verify(authorization) as TypePayload
res.locals = verify(authorization) as Payload
} catch (e) {
res.status(401)
throw e
Expand Down
Loading

0 comments on commit 9e8a4d8

Please sign in to comment.