title: Strapi Cms Create middleware transforming responses to make singletype work with strapi-jekyll
body: <p>I am trying to write a simple middleware to transport responses to work with jekyll.
  Jekyll only uses collections, basically an array, to store data. With the <a href="https://github.com/strapi-community/jekyll-strapi" rel="nofollow noreferrer">strapi-jekyll plugin</a> only the collections type is working which is mapped to the collection type in jekyll.</p>
  <p>One <a href="https://github.com/strapi-community/jekyll-strapi/issues/14" rel="nofollow noreferrer">workaround</a> working with older strapi versions to use strapi singletypes was to just add a small middleware wraping single type responses in an array.</p>
  <p>I tried to update the workaround to work with the current version of strapi but had no luck so far..
  When starting strapi with the middleware strapi is starting up but when browsing <code>http://localhost:1337/admin</code> i get a error.</p>
  <p>Anybody a idea how to make this work?</p>
  <p>My error when browsing <code>http://localhost:1337/admin</code></p>
  <pre class="lang-json prettyprint-override"><code>[{&quot;fd&quot;:null,&quot;path&quot;:&quot;/path/to/my/project/node_modules/@strapi/admin/build/index.html&quot;,&quot;flags&quot;:&quot;r&quot;,&quot;mode&quot;:438,&quot;end&quot;:null,&quot;bytesRead&quot;:0,&quot;closed&quot;:false,&quot;_readableState&quot;:{&quot;objectMode&quot;:false,&quot;highWaterMark&quot;:65536,&quot;buffer&quot;:{&quot;head&quot;:null,&quot;tail&quot;:null,&quot;length&quot;:0},&quot;length&quot;:0,&quot;pipes&quot;:[],&quot;flowing&quot;:null,&quot;ended&quot;:false,&quot;endEmitted&quot;:false,&quot;reading&quot;:false,&quot;constructed&quot;:false,&quot;sync&quot;:true,&quot;needReadable&quot;:false,&quot;emittedReadable&quot;:false,&quot;readableListening&quot;:false,&quot;resumeScheduled&quot;:false,&quot;errorEmitted&quot;:false,&quot;emitClose&quot;:true,&quot;autoDestroy&quot;:true,&quot;destroyed&quot;:false,&quot;errored&quot;:null,&quot;closed&quot;:false,&quot;closeEmitted&quot;:false,&quot;defaultEncoding&quot;:&quot;utf8&quot;,&quot;awaitDrainWriters&quot;:null,&quot;multiAwaitDrain&quot;:false,&quot;readingMore&quot;:false,&quot;dataEmitted&quot;:false,&quot;decoder&quot;:null,&quot;encoding&quot;:null},&quot;_events&quot;:{},&quot;_eventsCount&quot;:2}]
  </code></pre>
  <pre class="lang-js prettyprint-override"><code># ./config/middlewares.js
  module.exports = [
    'strapi::errors',
    'strapi::security',
    'strapi::cors',
    {
      name: 'global::single_to_array',
      config: {
        enabled: 'false',
      },
    },
    'strapi::poweredBy',
    'strapi::logger',
    'strapi::query',
    'strapi::body',
    'strapi::session',
    'strapi::favicon',
    'strapi::public',
  ];
  </code></pre>
  <pre class="lang-js prettyprint-override"><code># ./src/middlewares/single_to_array.js
  const singleName = &quot;&quot;;
  
  module.exports = () =&gt; {
    return async (ctx, next) =&gt; {
      await next();
      if (ctx.url.startsWith(&quot;/&quot; + singleName)) {
          ctx.response.body = [ ctx.response.body ];
      }
    };
  };
  </code></pre>
  <ul>
  <li><strong>Strapi Version</strong>:  4.3.4</li>
  <li><strong>Operating System</strong>: Fedora</li>
  <li><strong>Database</strong>: Sqlite</li>
  <li><strong>Node Version</strong>: 16.16.0</li>
  <li><strong>NPM Version</strong>: 8.19.2</li>
  <li><strong>Yarn Version</strong>: 1.22.19</li>
  </ul>