Skip to content

Commit

Permalink
fix: move places
Browse files Browse the repository at this point in the history
  • Loading branch information
rizkhal committed Dec 7, 2023
1 parent eb2b49c commit 26f473b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 91,592 deletions.
3 changes: 2 additions & 1 deletion dist/src/controllers/place.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const csv_parser_1 = __importDefault(require("csv-parser"));
exports.default = {
index(req, res) {
Expand All @@ -21,7 +22,7 @@ exports.default = {
const { nik } = req.body;
const [province, city, district] = nik.slice(0, 6).match(/(\d{2})/g);
const data = [];
fs_1.default.createReadStream("wilayah.csv")
fs_1.default.createReadStream(path_1.default.join(process.cwd(), "static", "places.csv"))
.pipe((0, csv_parser_1.default)())
.on("data", (row) => {
if (row.kode == province) {
Expand Down
3 changes: 2 additions & 1 deletion src/controllers/place.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import fs from "fs";
import path from "path";
import csvParser from "csv-parser";
import { Request, Response } from "express";

Expand All @@ -10,7 +11,7 @@ export default {

const data: any = [];

fs.createReadStream("wilayah.csv")
fs.createReadStream(path.join(process.cwd(), "static", "places.csv"))
.pipe(csvParser())
.on("data", (row) => {
if (row.kode == province) {
Expand Down
File renamed without changes.
Loading

0 comments on commit 26f473b

Please sign in to comment.