Under the “Setup a service API” the place-my-order-api
is installed:
npm install place-my-order-api --save
The guide continues by saying that the service is started as follows:
donejs api
That does not work. Instead the following works (seemed like something to try from the usage output):
donejs place-my-order-api
The guide then says that the site is host on http://localhost:7070/restaurants
but mine, locally, seems to be on port 3030.
This may need updating
Never mind… I see I missed the line that adds the “api” bit into the package.json
file.
Can’t see where to delete the post.
Ah! Scared me for a second!
Just another point:
It isn’t all too apparent that one needs to run both the ‘api’ and ‘develop’ bits. From the docs I thought that adding the proxy bit to the package.json would run both when I execute ‘donejs develop’. Perhaps it should just be made explicit so that it doesn’t appear as though the application isn’t working.
I am still a little scared, Matthew. I’ve been through this very carefully and still…
The “donejs api” does not start the api server. It requires “donejs place-my-order-api”.
The api is running on 3030, not 7070 as it says in the text. You have to access localhost:3030, not localhost:7070. At minimum, this is a typo.
Editing package.json does not appear to change these behaviors at all. Eben_roux says ‘never mind’, but I don’t see why. I cannot run the api server any other way and running ‘donejs develop’ does the same thing. I changed the code from the web page to use port 3030. I don’t know if that had any effect. (In fact, this tutorial doesn’t tell me any way to demonstrate the consequence of those changes. I suggest that something like that be added.)
Let me tell you that I think the tutorial is a beautiful, if a little bit raggedy, thing. I think it’s really important that it work flawlessly. Watching the guys do the plugin demo/tutorial with anticipation of doing this one myself was the final experience that made me choose donejs. I hope you won’t mind if I carefully document my experiences here.
what versions of operating system, node, and npm are you using?
I’ve only ever run donejs api
and it has worked for me. Did you change your package.json like it says in the guide: https://donejs.com/place-my-order.html#section=section_SetupaserviceAPI
"scripts": {
"api": "place-my-order-api --port 7070",
"test": "testee src/test.html --browsers firefox --reporter Spec",
"start": "done-serve --port 8080",
"develop": "done-serve --develop --port 8080",
"document": "documentjs",
"build": "node build"
},
Our guide should work flawlessly. Each step is tested with every commit. It’s possible our writing isn’t doing a good enough job getting people to follow all the steps. But the steps should be right.
Just to make sure, I’ve had reports of some broken pages on slow connections on linux. Setup a service api
looks like this:
If it doesn’t look like that for you, let us know.
The ‘place-order-from-assets’ problem fixed itself. I commented out the import so that I could move on. After I got to the routing installation, I uncommented it for no particular reason. It works.
I now suspect that it was a glitch in the automatic browser update/restart mechanism. FYI.
@tqwhite,
The reason I said never mind was because I actually missed the bit from the guide where the “api” script is added into the package.json
file
"scripts": {
"api": "place-my-order-api --port 7070", // <-- THIS BIT OVER HERE
"test": "testee src/test.html --browsers firefox --reporter Spec",
"start": "done-serve --proxy http://localhost:7070 --port 8080",
"develop": "done-serve --develop --proxy http://localhost:7070 --port 8080",
"document": "documentjs",
"build": "node build"
},
It seems that when running donejs {arg1}
it finds the script called {arg1}
and executes that. Well, assuming that {arg1}
isn’t a donejs
command such as add
.
If you do not have the api
script bit and you execute donejs place-my-order-api
I have a sneaky it is somehow ending up executing the actual node_module
and the package.json
in there has the following in its script
hash:
"start": "PORT=3030 bin/place-my-order-api",
That is where the port 3030 is coming from.
I hope that helps. In my case it is a matter of not having much node/npm experience so I do not quite understand all the moving parts even though, would you believe, I have written a couple of node modules
OK, I got through the main implementation. Now working on test and CI.
The one note I would like to leave for future users of this guide is that some noticeable part of my trouble resulted from the hot code injection not being 100%. I eventually found that I had to restart the server and reload the browser sometimes (no apparent pattern) to get results.
Once i figured out to do those things before I started trying to change things for debug, it was easy.
Thanks. It was my being stupid - three times in a row. I think it’s the same problem my wife complains about, “The mayonnaise was right on the top shelf!!! What is wrong with you and obvious stuff.”
I’ll try to be better for the rest of this learning experience and really appreciate your help here. I’ll appreciate your patience even more. Hopefully the question about assets doesn’t show me to be as dopy as this one does.