typicode / json-server

Get a full fake REST API with zero coding in less than 30 seconds (seriously)
Other
72.93k stars 7.02k forks source link

Not saving snapshot from generator file #320

Closed pedroborges closed 8 years ago

pedroborges commented 8 years ago

The server for my generator file works just fine, but when I try to save a snapshot I get this error:

screen shot 2016-07-01 at 4 51 23 pm

Snapshots for json files works as expected.

When I inspect the src/cli/run.js file and log to the console the state of app.db before the write method is called, the source property is undefined:

{ [Function]
  domain: undefined,
  _events: { mount: [Function: onmount] },
  _maxListeners: undefined,
  setMaxListeners: [Function: setMaxListeners],
  getMaxListeners: [Function: getMaxListeners],
  emit: [Function: emit],
  addListener: [Function: addListener],
  on: [Function: addListener],
  prependListener: [Function: prependListener],
  once: [Function: once],
  prependOnceListener: [Function: prependOnceListener],
  removeListener: [Function: removeListener],
  removeAllListeners: [Function: removeAllListeners],
  listeners: [Function: listeners],
  listenerCount: [Function: listenerCount],
  eventNames: [Function: eventNames],
  init: [Function: init],
  defaultConfiguration: [Function: defaultConfiguration],
  lazyrouter: [Function: lazyrouter],
  handle: [Function: handle],
  use: [Function: use],
  route: [Function: route],
  engine: [Function: engine],
  param: [Function: param],
  set: [Function: set],
  path: [Function: path],
  enabled: [Function: enabled],
  disabled: [Function: disabled],
  enable: [Function: enable],
  disable: [Function: disable],
  acl: [Function],
  bind: [Function],
  checkout: [Function],
  connect: [Function],
  copy: [Function],
  delete: [Function],
  get: [Function],
  head: [Function],
  link: [Function],
  lock: [Function],
  'm-search': [Function],
  merge: [Function],
  mkactivity: [Function],
  mkcalendar: [Function],
  mkcol: [Function],
  move: [Function],
  notify: [Function],
  options: [Function],
  patch: [Function],
  post: [Function],
  propfind: [Function],
  proppatch: [Function],
  purge: [Function],
  put: [Function],
  rebind: [Function],
  report: [Function],
  search: [Function],
  subscribe: [Function],
  trace: [Function],
  unbind: [Function],
  unlink: [Function],
  unlock: [Function],
  unsubscribe: [Function],
  all: [Function: all],
  del: [Function],
  render: [Function: render],
  listen: [Function: listen],
  request: IncomingMessage { app: [Circular] },
  response: ServerResponse { app: [Circular] },
  cache: {},
  engines: {},
  settings:
   { 'x-powered-by': true,
     etag: 'weak',
     'etag fn': [Function: wetag],
     env: 'development',
     'query parser': 'extended',
     'query parser fn': [Function: parseExtendedQueryString],
     'subdomain offset': 2,
     'trust proxy': false,
     'trust proxy fn': [Function: trustNone],
     view: [Function: View],
     views: '/Users/pedro/Code/score-keeper/views',
     'jsonp callback name': 'callback',
     'json spaces': 2 },
  _eventsCount: 1,
  locals:
   { settings:
      { 'x-powered-by': true,
        etag: 'weak',
        'etag fn': [Function: wetag],
        env: 'development',
        'query parser': 'extended',
        'query parser fn': [Function: parseExtendedQueryString],
        'subdomain offset': 2,
        'trust proxy': false,
        'trust proxy fn': [Function: trustNone],
        view: [Function: View],
        views: '/Users/pedro/Code/score-keeper/views',
        'jsonp callback name': 'callback',
        'json spaces': 2 } },
  mountpath: '/',
  _router:
   { [Function: router]
     params: {},
     _params: [],
     caseSensitive: false,
     mergeParams: undefined,
     strict: false,
     stack:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] },
  db:
   LodashWrapper {
     __wrapped__: { posts: [Object] },
     __actions__: [],
     __chain__: true,
     __index__: 0,
     __values__: undefined,
     getState: [Function],
     setState: [Function],
     _:
      { [Function: lodash]
        templateSettings: [Object],
        after: [Function: after],
        ary: [Function: ary],
        assign: [Function],
        assignIn: [Function],
        assignInWith: [Function],
        assignWith: [Function],
        at: [Function],
        before: [Function: before],
        bind: [Object],
        bindAll: [Function],
        bindKey: [Object],
        castArray: [Function: castArray],
        chain: [Function: chain],
        chunk: [Function: chunk],
        compact: [Function: compact],
        concat: [Function: concat],
        cond: [Function: cond],
        conforms: [Function: conforms],
        constant: [Function: constant],
        countBy: [Function],
        create: [Function: create],
        curry: [Object],
        curryRight: [Object],
        debounce: [Function: debounce],
        defaults: [Function],
        defaultsDeep: [Function],
        defer: [Function],
        delay: [Function],
        difference: [Function],
        differenceBy: [Function],
        differenceWith: [Function],
        drop: [Function: drop],
        dropRight: [Function: dropRight],
        dropRightWhile: [Function: dropRightWhile],
        dropWhile: [Function: dropWhile],
        fill: [Function: fill],
        filter: [Function: filter],
        flatMap: [Function: flatMap],
        flatMapDeep: [Function: flatMapDeep],
        flatMapDepth: [Function: flatMapDepth],
        flatten: [Function: flatten],
        flattenDeep: [Function: flattenDeep],
        flattenDepth: [Function: flattenDepth],
        flip: [Function: flip],
        flow: [Function],
        flowRight: [Function],
        fromPairs: [Function: fromPairs],
        functions: [Function: functions],
        functionsIn: [Function: functionsIn],
        groupBy: [Function],
        initial: [Function: initial],
        intersection: [Function],
        intersectionBy: [Function],
        intersectionWith: [Function],
        invert: [Function],
        invertBy: [Function],
        invokeMap: [Function],
        iteratee: [Function: iteratee],
        keyBy: [Function],
        keys: [Function: keys],
        keysIn: [Function: keysIn],
        map: [Function: map],
        mapKeys: [Function: mapKeys],
        mapValues: [Function: mapValues],
        matches: [Function: matches],
        matchesProperty: [Function: matchesProperty],
        memoize: [Object],
        merge: [Function],
        mergeWith: [Function],
        method: [Function],
        methodOf: [Function],
        mixin: [Function: mixin],
        negate: [Function: negate],
        nthArg: [Function: nthArg],
        omit: [Function],
        omitBy: [Function: omitBy],
        once: [Function: once],
        orderBy: [Function: orderBy],
        over: [Function],
        overArgs: [Function],
        overEvery: [Function],
        overSome: [Function],
        partial: [Object],
        partialRight: [Object],
        partition: [Function],
        pick: [Function],
        pickBy: [Function: pickBy],
        property: [Function: property],
        propertyOf: [Function: propertyOf],
        pull: [Function],
        pullAll: [Function: pullAll],
        pullAllBy: [Function: pullAllBy],
        pullAllWith: [Function: pullAllWith],
        pullAt: [Function],
        range: [Function],
        rangeRight: [Function],
        rearg: [Function],
        reject: [Function: reject],
        remove: [Function: remove],
        rest: [Function: rest],
        reverse: [Function: reverse],
        sampleSize: [Function: sampleSize],
        set: [Function: set],
        setWith: [Function: setWith],
        shuffle: [Function: shuffle],
        slice: [Function: slice],
        sortBy: [Function],
        sortedUniq: [Function: sortedUniq],
        sortedUniqBy: [Function: sortedUniqBy],
        split: [Function: split],
        spread: [Function: spread],
        tail: [Function: tail],
        take: [Function: take],
        takeRight: [Function: takeRight],
        takeRightWhile: [Function: takeRightWhile],
        takeWhile: [Function: takeWhile],
        tap: [Function: tap],
        throttle: [Function: throttle],
        thru: [Function: thru],
        toArray: [Function: toArray],
        toPairs: [Function],
        toPairsIn: [Function],
        toPath: [Function: toPath],
        toPlainObject: [Function: toPlainObject],
        transform: [Function: transform],
        unary: [Function: unary],
        union: [Function],
        unionBy: [Function],
        unionWith: [Function],
        uniq: [Function: uniq],
        uniqBy: [Function: uniqBy],
        uniqWith: [Function: uniqWith],
        unset: [Function: unset],
        unzip: [Function: unzip],
        unzipWith: [Function: unzipWith],
        update: [Function: update],
        updateWith: [Function: updateWith],
        values: [Function: values],
        valuesIn: [Function: valuesIn],
        without: [Function],
        words: [Function: words],
        wrap: [Function: wrap],
        xor: [Function],
        xorBy: [Function],
        xorWith: [Function],
        zip: [Function],
        zipObject: [Function: zipObject],
        zipObjectDeep: [Function: zipObjectDeep],
        zipWith: [Function],
        entries: [Function],
        entriesIn: [Function],
        extend: [Function],
        extendWith: [Function],
        add: [Function],
        attempt: [Function],
        camelCase: [Function],
        capitalize: [Function: capitalize],
        ceil: [Function],
        clamp: [Function: clamp],
        clone: [Function: clone],
        cloneDeep: [Function: cloneDeep],
        cloneDeepWith: [Function: cloneDeepWith],
        cloneWith: [Function: cloneWith],
        deburr: [Function: deburr],
        divide: [Function],
        endsWith: [Function: endsWith],
        eq: [Function: eq],
        escape: [Function: escape],
        escapeRegExp: [Function: escapeRegExp],
        every: [Function: every],
        find: [Function],
        findIndex: [Function: findIndex],
        findKey: [Function: findKey],
        findLast: [Function],
        findLastIndex: [Function: findLastIndex],
        findLastKey: [Function: findLastKey],
        floor: [Function],
        forEach: [Function: forEach],
        forEachRight: [Function: forEachRight],
        forIn: [Function: forIn],
        forInRight: [Function: forInRight],
        forOwn: [Function: forOwn],
        forOwnRight: [Function: forOwnRight],
        get: [Function: get],
        gt: [Function],
        gte: [Function],
        has: [Function: has],
        hasIn: [Function: hasIn],
        head: [Function: head],
        identity: [Function: identity],
        includes: [Function: includes],
        indexOf: [Function: indexOf],
        inRange: [Function: inRange],
        invoke: [Function],
        isArguments: [Function: isArguments],
        isArray: [Function: isArray],
        isArrayBuffer: [Function: isArrayBuffer],
        isArrayLike: [Function: isArrayLike],
        isArrayLikeObject: [Function: isArrayLikeObject],
        isBoolean: [Function: isBoolean],
        isBuffer: [Function],
        isDate: [Function: isDate],
        isElement: [Function: isElement],
        isEmpty: [Function: isEmpty],
        isEqual: [Function: isEqual],
        isEqualWith: [Function: isEqualWith],
        isError: [Function: isError],
        isFinite: [Function: isFinite],
        isFunction: [Function: isFunction],
        isInteger: [Function: isInteger],
        isLength: [Function: isLength],
        isMap: [Function: isMap],
        isMatch: [Function: isMatch],
        isMatchWith: [Function: isMatchWith],
        isNaN: [Function: isNaN],
        isNative: [Function: isNative],
        isNil: [Function: isNil],
        isNull: [Function: isNull],
        isNumber: [Function: isNumber],
        isObject: [Function: isObject],
        isObjectLike: [Function: isObjectLike],
        isPlainObject: [Function: isPlainObject],
        isRegExp: [Function: isRegExp],
        isSafeInteger: [Function: isSafeInteger],
        isSet: [Function: isSet],
        isString: [Function: isString],
        isSymbol: [Function: isSymbol],
        isTypedArray: [Function: isTypedArray],
        isUndefined: [Function: isUndefined],
        isWeakMap: [Function: isWeakMap],
        isWeakSet: [Function: isWeakSet],
        join: [Function: join],
        kebabCase: [Function],
        last: [Function: last],
        lastIndexOf: [Function: lastIndexOf],
        lowerCase: [Function],
        lowerFirst: [Function],
        lt: [Function],
        lte: [Function],
        max: [Function: max],
        maxBy: [Function: maxBy],
        mean: [Function: mean],
        meanBy: [Function: meanBy],
        min: [Function: min],
        minBy: [Function: minBy],
        stubArray: [Function: stubArray],
        stubFalse: [Function: stubFalse],
        stubObject: [Function: stubObject],
        stubString: [Function: stubString],
        stubTrue: [Function: stubTrue],
        multiply: [Function],
        nth: [Function: nth],
        noConflict: [Function: noConflict],
        noop: [Function: noop],
        now: [Function: now],
        pad: [Function: pad],
        padEnd: [Function: padEnd],
        padStart: [Function: padStart],
        parseInt: [Function: parseInt],
        random: [Function: random],
        reduce: [Function: reduce],
        reduceRight: [Function: reduceRight],
        repeat: [Function: repeat],
        replace: [Function: replace],
        result: [Function: result],
        round: [Function],
        runInContext: [Function: runInContext],
        sample: [Function: sample],
        size: [Function: size],
        snakeCase: [Function],
        some: [Function: some],
        sortedIndex: [Function: sortedIndex],
        sortedIndexBy: [Function: sortedIndexBy],
        sortedIndexOf: [Function: sortedIndexOf],
        sortedLastIndex: [Function: sortedLastIndex],
        sortedLastIndexBy: [Function: sortedLastIndexBy],
        sortedLastIndexOf: [Function: sortedLastIndexOf],
        startCase: [Function],
        startsWith: [Function: startsWith],
        subtract: [Function],
        sum: [Function: sum],
        sumBy: [Function: sumBy],
        template: [Function: template],
        times: [Function: times],
        toFinite: [Function: toFinite],
        toInteger: [Function: toInteger],
        toLength: [Function: toLength],
        toLower: [Function: toLower],
        toNumber: [Function: toNumber],
        toSafeInteger: [Function: toSafeInteger],
        toString: [Function: toString],
        toUpper: [Function: toUpper],
        trim: [Function: trim],
        trimEnd: [Function: trimEnd],
        trimStart: [Function: trimStart],
        truncate: [Function: truncate],
        unescape: [Function: unescape],
        uniqueId: [Function: uniqueId],
        upperCase: [Function],
        upperFirst: [Function],
        each: [Function: forEach],
        eachRight: [Function: forEachRight],
        first: [Function: head],
        VERSION: '4.13.1',
        __empty: [Function],
        __update: [Function],
        __remove: [Function],
        __id: [Function],
        getById: [Function],
        createId: [Function: createId],
        insert: [Function],
        updateById: [Function],
        updateWhere: [Function],
        replaceById: [Function],
        removeById: [Function],
        removeWhere: [Function],
        save: [Function],
        load: [Function],
        getRemovable: [Function: getRemovable],
        deepQuery: [Function: deepQuery],
        id: 'id' },
     source: undefined } }
typicode commented 8 years ago

Thank you for the bug report 👍 will fix it this week-end

typicode commented 8 years ago

Sorry not as straightforward, so it should take a little bit longer to fix it. If you need to take a snapshot, you can still save http://localhost:3000/db.

pedroborges commented 8 years ago

Ok 👍

typicode commented 8 years ago

Just published v0.8.17 should be good now.