mirror of
https://github.com/strapi/strapi.git
synced 2025-07-15 13:02:42 +00:00
45 lines
794 B
JavaScript
45 lines
794 B
JavaScript
![]() |
'use strict';
|
||
|
|
||
|
/**
|
||
|
* Body parser hook
|
||
|
*/
|
||
|
|
||
|
module.exports = function (strapi) {
|
||
|
const hook = {
|
||
|
|
||
|
/**
|
||
|
* Default options
|
||
|
*/
|
||
|
|
||
|
defaults: {
|
||
|
parser: {
|
||
|
encode: 'utf-8',
|
||
|
formLimit: '56kb',
|
||
|
jsonLimit: '1mb',
|
||
|
strict: true,
|
||
|
extendTypes: {
|
||
|
json: ['application/x-javascript']
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
|
||
|
/**
|
||
|
* Initialize the hook
|
||
|
*/
|
||
|
|
||
|
initialize: function (cb) {
|
||
|
strapi.app.use(strapi.middlewares.bodyparser({
|
||
|
encode: strapi.config.parser.encode,
|
||
|
formLimit: strapi.config.parser.formLimit,
|
||
|
jsonLimit: strapi.config.parser.jsonLimit,
|
||
|
strict: strapi.config.parser.strict,
|
||
|
extendTypes: strapi.config.parser.extendTypes
|
||
|
}));
|
||
|
|
||
|
cb();
|
||
|
}
|
||
|
};
|
||
|
|
||
|
return hook;
|
||
|
};
|