You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not entirely sure if I'm doing something silly here or if this is something that should be handled differently in the generator. This is mostly just for my enlightenment, perhaps it will be for others as well, but either way this is bugging me.
For the record, I'm in Windows 8.1 using Bash from Cygwin. If I type folder paths myself, I have a bit of a *nix mentality, so this allows me use / as path separators in Windows.
Firstly, to explain what I was trying to achieve.. I wanted an API endpoint of [host]:[port]/api/company/details (with nothing at /api/company directly), but my first attempt failed horribly:
$ yo angular-fullstack:endpoint company/detail
? What will the url of your endpoint to be? /api/company/details
create server\api\company\detail\index.js
create server\api\company\detail\company\detail.controller.js
create server\api\company\detail\company\detail.model.js
create server\api\company\detail\company\detail.socket.js
create server\api\company\detail\company\detail.spec.js
First problem here: folder structure goes haywire.
Checking the contents of routes.js, I see require('./api/company/detail') as one would expect. Checking api/company/detail/index.js, I see require('./company/detail.controller'), also just as one would expect.
This is where the real problem starts though.. The variable used throughout the endoint is now company/detail, so I end up with code such as:
// Get a single company/detail
exports.show = function(req, res) {
CompanyDetail.findById(req.params.id, function (err, company/detail) {
if(err) { return handleError(res, err); }
if(!company/detail) { return res.send(404); }
return res.json(company/detail);
});
};
Quite obviously, this doesn't run.. So in the end I generated the endpoint as simply detail and set the URL to /api/company/detail. From my frontend, I call the info by requesting "company details", so that part is pretty logical. It's just the folder structure that annoys me now.
I know I can simply move files and update paths to get around this, but is there a better way to nest endpoints using the generator itself? Or could someone perhaps give me a reason to not do this..?
The text was updated successfully, but these errors were encountered:
First off, my apologies for taking so long to respond to my initial report.. I was keeping an eye out for the 2.3.0 milestone, but in the meantime it looks like plans changed and a volcano or two erupted and life itself happened, so I simply didn't get around to it.
I've just checked with the latest (3.0.0-rc8), using the exact same steps as my initial report: all files were created correctly and all require(...) references in the new endpoint are correct. Without modifying any code, I checked my new blank endpoint and got a HTTP 200 response, so it looks like everything is good here now. Thanks for sorting this one out. :)
Not entirely sure if I'm doing something silly here or if this is something that should be handled differently in the generator. This is mostly just for my enlightenment, perhaps it will be for others as well, but either way this is bugging me.
For the record, I'm in Windows 8.1 using Bash from Cygwin. If I type folder paths myself, I have a bit of a *nix mentality, so this allows me use
/
as path separators in Windows.Firstly, to explain what I was trying to achieve.. I wanted an API endpoint of
[host]:[port]/api/company/details
(with nothing at/api/company
directly), but my first attempt failed horribly:First problem here: folder structure goes haywire.
Checking the contents of
routes.js
, I seerequire('./api/company/detail')
as one would expect. Checkingapi/company/detail/index.js
, I seerequire('./company/detail.controller')
, also just as one would expect.This is where the real problem starts though.. The variable used throughout the endoint is now
company/detail
, so I end up with code such as:Quite obviously, this doesn't run.. So in the end I generated the endpoint as simply
detail
and set the URL to/api/company/detail
. From my frontend, I call the info by requesting "company details", so that part is pretty logical. It's just the folder structure that annoys me now.I know I can simply move files and update paths to get around this, but is there a better way to nest endpoints using the generator itself? Or could someone perhaps give me a reason to not do this..?
The text was updated successfully, but these errors were encountered: