Files
medusa-store/docs-util/fixture-gen/utils/write-fixture.js
Sebastian Rindom 8edb32c742 docs: oas (#197)
Adds OpenAPI specification of Storefront and Admin APIs.
Updates docs project.
2021-03-10 11:51:54 +01:00

31 lines
654 B
JavaScript

const fs = require("fs").promises;
const path = require("path");
class FixtureWriter {
constructor() {
const resolvedPath = path.resolve("./docs/api/fixtures.json");
const existing = require(resolvedPath);
this.toWrite_ = existing.resources;
this.resolvedPath_ = resolvedPath;
}
addFixture(key, data) {
this.toWrite_ = {
...this.toWrite_,
[key]: data,
};
}
async execute() {
const toSet = {
resources: this.toWrite_,
};
const s = JSON.stringify(toSet, null, 2);
return await fs.writeFile(this.resolvedPath_, s);
}
}
const instance = new FixtureWriter();
export default instance;