UNPKG

@nimbella/postman-api

Version:

Postman Collection to Nimbella Project: Take your APIs seamlessly into Serverless world with this API

35 lines (34 loc) 1.41 kB
"use strict"; /* * Copyright (c) 2019 - present Nimbella Corp. * * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.isValid = exports.read = void 0; const fs_1 = require("fs"); const postman_collection_1 = require("postman-collection"); function read(fileLocation) { try { const collection = JSON.parse(fs_1.readFileSync(fileLocation).toString()); return { isVersion2X: ((collection.info || '').schema || '').includes('v2'), collection: new postman_collection_1.Collection(collection), }; } catch (error) { return { isVersion2X: false, collection: new postman_collection_1.Collection() }; } } exports.read = read; function isValid(collection) { return postman_collection_1.Collection.isCollection(collection); } exports.isValid = isValid;