@indiekit/endpoint-json-feed
Version:
Syndicate posts from Indiekit using JSON Feed.
35 lines (27 loc) • 738 B
JavaScript
import path from "node:path";
import express from "express";
import { jsonFeedController } from "./lib/controllers/json-feed.js";
const defaults = {
feedName: "feed.json",
mountPath: "/",
};
const router = express.Router();
export default class jsonFeedEndpoint {
constructor(options = {}) {
this.name = "JSON Feed";
this.options = { ...defaults, ...options };
this.feedName = this.options.feedName;
this.mountPath = this.options.mountPath;
}
get routesPublic() {
router.get(`/${this.feedName}`, jsonFeedController);
return router;
}
init(Indiekit) {
Indiekit.addEndpoint(this);
Indiekit.config.application.jsonFeed = path.join(
this.mountPath,
this.feedName,
);
}
}