refactor: import/export new architecture
This commit is contained in:
20
packages/hoppscotch-app/helpers/import-export/import/hopp.ts
Normal file
20
packages/hoppscotch-app/helpers/import-export/import/hopp.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { HoppRESTRequest } from "@hoppscotch/data"
|
||||
import { pipe } from "fp-ts/function"
|
||||
import * as TE from "fp-ts/TaskEither"
|
||||
import * as E from "fp-ts/Either"
|
||||
import { HoppImporter, IMPORTER_INVALID_FILE_FORMAT } from "."
|
||||
import {
|
||||
Collection,
|
||||
translateToNewRESTCollection,
|
||||
} from "~/newstore/collections"
|
||||
|
||||
const importer: HoppImporter<Collection<HoppRESTRequest>> = (content) =>
|
||||
pipe(
|
||||
E.tryCatch(
|
||||
() => translateToNewRESTCollection(content),
|
||||
() => IMPORTER_INVALID_FILE_FORMAT
|
||||
),
|
||||
TE.fromEither
|
||||
)
|
||||
|
||||
export default importer
|
||||
Reference in New Issue
Block a user