loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Static file config in middleware.json is remove after update datasource

Open phuongnl opened this issue 11 years ago • 10 comments

After i update datasource by use slc arc, all config static file in middleware.json is removed. I use strongloop v5.0.0 (node v2.4.0). Please fix it.

phuongnl avatar Aug 05 '15 02:08 phuongnl

This sounds like a serious issue. Are you saying that the middleware.json file is removed or something within the middleware.json is? Do you have some reproduction steps for this? Are you using arc and editing the file at the same time?

ritch avatar Aug 06 '15 22:08 ritch

Only config static file in field "files" is remove. I use slc arc in my project then go to datasource choice Test Connection after that filed "files" in middleware.json is become "files": {}.

Are you using arc and editing the file at the same time? I only use arc

phuongnl avatar Aug 07 '15 02:08 phuongnl

This sounds like an issue in the workspace API.

@raymondfeng can you take a look since you added middleware support recently?

ritch avatar Aug 07 '15 18:08 ritch

I was unable to reproduce this. I modified the files property in middleware.json then added a new datasource in Arc and clicked Test. The middleware.json file was unaffected.

@PhuongNL By default the middleware.json created by slc loopback has

  "files": {
  },

So unless you are manually editing middleware.json, that's what you should see. See http://docs.strongloop.com/display/LB/Add+a+static+web+page.

crandmck avatar Aug 07 '15 20:08 crandmck

I know the problem. Here is my config static file in middleware.json:

"files": {
    "loopback#static": [
      {
        "paths": [
          "/"
        ],
        "params": "$!../client"
      },
      {
        "paths": [
          "/bower_components"
        ],
        "params": "$!../bower_components"
      }
    ]
  },

when i test connection in arc all static file is remove. After that i edit middleware.json to:

"files": {
    "loopback#static": 
      {
        "paths": [
          "/"
        ],
        "params": "$!../client"
      }
  },

Everything is still there. Maybe has issue in static file at version 5.0.

One more thing, please support iojs >= 2.4.

phuongnl avatar Aug 10 '15 08:08 phuongnl

@PhuongNL It seems loopback#static entries pointing to non-existent files are removed. I'll check.

raymondfeng avatar Aug 10 '15 15:08 raymondfeng

OK, I reproduced the problem with the above "files" entry. As soon as I click Test Connection the entry disappears from middleware.json. It didn't seem to matter if I had a client or bower_components directory.

crandmck avatar Aug 10 '15 17:08 crandmck

Hi @crandmck, I was unable to reproduce the files entries being removed, not sure if I'm following the procedures wrong or if the issue has been resolved.

Moving the follow block of text to correct issue #1833 instead,

But on the otherhand, any keys in the following object seems to be removed if the user uses them, in one case the user was using name in their middleware.json it was removed from middleware.json where it doesn't happen from node . only from workspace-api

{
        "configFile": "server/middleware.json",
        "phase": "initial",
        "facetName": "server",
        "name": "compression",
        "order": 2049,
        "index": 0,
        "id": "initial.compression"
}

Just to note some behaviors in my investigation of the current version.

  • collection with only one object becomes an object
  • parameters such as configFile,name,order,index,id are reserved and does not preserve upon middleware.json rewrite from Middleware.seralize()
  • parameters such as phase, subPhase in a loopback#static entry seems to break the code.
  • file->loopback#static entries pointing to non-existent folders do preserve

davidcheung avatar Dec 07 '15 15:12 davidcheung

Hi @crandmck, I believe this(non-existing path files entry removed) is no longer as issue, would you be able to see if you also can no longer reproduce this issue, then this issue can be closed . Thanks!

davidcheung avatar Dec 14 '15 22:12 davidcheung

@davidcheung I tried it again and was not able to reproduce. So, I assume the problem is fixed in the latest release.

crandmck avatar Dec 17 '15 00:12 crandmck