thisissoon / FM-Frontend-API

A node js middle layer between FM Frontend and FM API
1 stars 0 forks source link

Feature: find blueprint #9

Closed jamesjwarren closed 8 years ago

jamesjwarren commented 8 years ago

This demonstrates my idea for making our calling logic reusable. It moves it to a custom find blueprint which is then configured for that route. It also implements sails local DB models if not in production mode, we could use this for mocking data before the API is ready.

This could act as a default, if we need to add additional behaviour to a particular endpoint we could add this is the controller as normal.

The FM API wrapper is moved to a service to make it reusable across the system.

Steps to try out:

  1. run sails lift --prod to forward requests to FM API running on localdocker
  2. run sails lift data will be returned from local sails model using the simple development localDiskDb
edoparearyee commented 8 years ago

LGTM! :+1:

edoparearyee commented 8 years ago

@jamesjwarren i get an error when running sails lift. Any ideas why?

/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/api/services/fmAPI.js:25
module.exports = new fmAPI('', '');
                     ^
ReferenceError: fmAPI is not defined
    at Object.<anonymous> (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/api/services/fmAPI.js:25:22)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at /Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/include-all/index.js:129:29
    at Array.forEach (native)
    at requireAll (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/include-all/index.js:44:9)
    at buildDictionary (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
    at Function.module.exports.optional (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/node_modules/sails-build-dictionary/index.js:160:9)
    at Hook.loadServices (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/lib/hooks/moduleloader/index.js:310:23)
    at Hook.bound [as loadServices] (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
    at Hook.loadModules (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/lib/hooks/services/index.js:35:18)
    at Hook.bound [as loadModules] (/Users/ed/Documents/Projects/thisissoon/FM-Frontend-API/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
jamesjwarren commented 8 years ago

@edwardoparearyee sorry about that, must have renamed the variable without changing this, should be new FM() https://github.com/thisissoon/FM-Frontend-API/pull/9/files#diff-ac6a1e7e35aefba065f6b20564c32c29R25

Fixed in my upcoming update.

jamesjwarren commented 8 years ago

Closing to reopen in develop branch.