@tasolutions/express-core
Version:
All libs for express
38 lines (35 loc) • 1.09 kB
JavaScript
const fieldsToExclude = [
'__v',
'_id',
'created_at',
'updated_at',
'createdAt',
'updatedAt',
'is_deleted',
'deleted_at',
'created_by_identifier',
'deleted_by_identifier',
'restored_at',
'restored_by_identifier',
'organization_identifier',
'agency_identifier',
'user_identifier'
];
const getActions = (schema) => {
const hasImageField = Object.values(schema).some(field =>
field.options && field.options.field_type === 'IMAGE'
);
return {
CREATE: { method: 'POST', type: 'CREATE', content_type: hasImageField ? 'multipart/form-data' : 'application/json' },
LIST: { method: 'GET', type: 'LIST' },
DETAIL: { method: 'GET', type: 'DETAIL' },
UPDATE: { method: 'PUT', type: 'UPDATE', content_type: hasImageField ? 'multipart/form-data' : 'application/json' },
DELETE: { method: 'DELETE', type: 'DELETE' },
EXPORT: { method: 'GET', type: 'EXPORT' },
COUNT: { method: 'GET', type: 'COUNT' },
};
};
module.exports = {
fieldsToExclude,
getActions,
};