summaryrefslogtreecommitdiff
path: root/src/hooks/formatDate.ts
blob: ada8502bb53405d4d2f5253bb067078096605fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
import { HookContext } from '@feathersjs/feathers';
import { populate, alterItems } from 'feathers-hooks-common';
import moment from 'moment';
import _ from 'lodash';

const formatDate = (fieldName = 'date') => alterItems(item => {
  const date = _.get(item, fieldName);
  return _.set(item, fieldName, moment(date).format('YYYY-MM-DD'));
});

export default formatDate;