Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(fractal, opts = {}) {
if (!Fractal.isFractal(fractal)) {
throw new TypeError(`Server.constructor - first argument must be an instance of Fractal [fractal-missing]`);
}
super(opts);
const componentOpts = opts.components || {};
const router = new Router(opts.api);
router.use(async (ctx, next) => {
ctx.fractal = fractal;
try {
const {components, files} = await fractal.parse();
ctx.files = files;
ctx.components = componentOpts.filter ? components.filter(componentOpts.filter) : components;
} catch (err) {
ctx.throw(500, err);