Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .dev.example.vars
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ COMULINE_ENV="development"

# Take token from .env.db
UPSTASH_REDIS_REST_TOKEN=""
UPSTASH_REDIS_REST_URL="http://localhost:8079"
UPSTASH_REDIS_REST_URL="http://localhost:8079"

# KRL stuff
KRL_ENDPOINT_BASE_URL="https://api-partner.krl.co.id/krl-webs/v1"
4 changes: 3 additions & 1 deletion src/sync/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { KAI_HEADERS } from "./headers"
const sync = async () => {
if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL env is missing")
if (!process.env.COMULINE_ENV) throw new Error("COMULINE_ENV env is missing")
if (!process.env.KRL_ENDPOINT_BASE_URL)
throw new Error("KRL_ENDPOINT_BASE_URL env is missing")

const { db } = new Database({
COMULINE_ENV: process.env.COMULINE_ENV,
Expand Down Expand Up @@ -55,7 +57,7 @@ const sync = async () => {
batch.map(async ({ id, metadata }) => {
await sleep(5000)

const url = `https://api-partner.krl.co.id/krlweb/v1/schedule?stationid=${id}&timefrom=00:00&timeto=23:00`
const url = `${process.env.KRL_ENDPOINT_BASE_URL}/schedule?stationid=${id}&timefrom=00:00&timeto=23:00`

console.info(`[SYNC][SCHEDULE][${id}] Send preflight`)
const optionsResponse = await fetch(url, {
Expand Down
4 changes: 3 additions & 1 deletion src/sync/station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const createStationKey = (type: StationType, id: string) =>
const sync = async () => {
if (!process.env.DATABASE_URL) throw new Error("DATABASE_URL env is missing")
if (!process.env.COMULINE_ENV) throw new Error("COMULINE_ENV env is missing")
if (!process.env.KRL_ENDPOINT_BASE_URL)
throw new Error("KRL_ENDPOINT_BASE_URL env is missing")

const { db } = new Database({
COMULINE_ENV: process.env.COMULINE_ENV,
Expand All @@ -29,7 +31,7 @@ const sync = async () => {
),
})

const url = "https://api-partner.krl.co.id/krlweb/v1/krl-station"
const url = `${process.env.KRL_ENDPOINT_BASE_URL}/krl-station`

const req = await fetch(url, {
method: "GET",
Expand Down