const Unit = require('libflitter/Unit') const cors = require('cors') /* * The Miscellaneous Unit * ------------------------------------------------------------- * This is a Unit file where you should make any modifications that * your application may need such as custom Express add-ons. Changes * here are loaded after the core Flitter units, but before the other * units (secondary, custom, error, and App), so they are available to * other units in the stack. */ class CorsUnit extends Unit { /* * Initializes the unit class. * This is called OUTSIDE of a Flitter context, * so no other contexts are available. Modifications here * take place before any part of Flitter is loaded or available. */ constructor(){ super() } /* * Initialize the actual Unit. * This is where most of the changes will go. * This is provided an instance of the Express app * so any custom changes can be made. The core Flitter * contexts are available here, so things like config(), * model(), etc. work. */ async go(app, context){ app.express.use(cors()); } name(){ return "cors" } } module.exports = exports = CorsUnit