Skip to content

Commit

Permalink
feat: reform schedule jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
taevel02 authored Aug 15, 2023
1 parent 524430b commit 361524a
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 171 deletions.
38 changes: 20 additions & 18 deletions src/api/domestic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { AxiosError } from 'axios'
import { ServerResponse, ServerResponseCode } from '../interface/api'
import {
HolidayRequest,
HolidayResponse,
MarketIndex,
MarketIndexRequest,
Expand All @@ -17,37 +16,37 @@ import { api } from '../utils/axios'
import dayjs from 'dayjs'

export class DomesticStockService {
public async checkHoliday(
request: HolidayRequest
): Promise<ServerResponse<HolidayResponse>> {
/**
*
* @param date
* @returns true - 휴장일, false - 휴장일 아님, undefined - 에러
*/
public async isHoliday(date: Date): Promise<Boolean> {
try {
const checkHolidayResults = (
await api.get<HolidayResponse>(
'/uapi/domestic-stock/v1/quotations/chk-holiday',
{
params: request,
params: {
BASS_DT: dayjs(date).format('YYYYMMDD'),
CTX_AREA_NK: '',
CTX_AREA_FK: ''
},
headers: {
tr_id: TR_ID.국내휴장일조회
}
}
)
).data

if (checkHolidayResults === undefined) {
return {
code: ServerResponseCode.NOT_FOUND
}
}
if (checkHolidayResults.rt_cd !== '0') return undefined

return {
code: ServerResponseCode.OK,
result: checkHolidayResults
}
if (checkHolidayResults.output[0].bzdy_yn === 'N') return true

return false
} catch (err) {
const error = err as AxiosError
return {
code: error.response?.status ?? -1
}
throw error
}
}

Expand Down Expand Up @@ -143,7 +142,10 @@ export class DomesticStockService {
}
}

public async getIndexes(): Promise<{kospi: MarketIndex; kosdaq: MarketIndex;}> {
public async getIndexes(): Promise<{
kospi: MarketIndex
kosdaq: MarketIndex
}> {
const basedMarketIndexRequest = {
FID_COND_MRKT_DIV_CODE: 'U',
FID_INPUT_DATE_1: dayjs(new Date()).format('YYYYMMDD'),
Expand Down
3 changes: 1 addition & 2 deletions src/api/evernote.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Evernote, { NoteStore } from 'evernote'
import { logger } from '../utils/logger'
import { guid } from '../interface/evernote'

const evernoteClient = new Evernote.Client({
Expand Down Expand Up @@ -73,7 +72,7 @@ export class EvernoteService {
.createNote(ourNote)
.then((note: any) => {
// Do something with `note`
logger(`Successfully created, ${note.title}`)
console.log(`Successfully created, ${note.title}`)
})
.catch((error: any) => {
// Something was wrong with the note data
Expand Down
Loading

0 comments on commit 361524a

Please sign in to comment.