Can I create multiple services or resources in a project

120 views
Skip to first unread message

Henry Nguyen

unread,
Jun 14, 2017, 12:25:25 AM6/14/17
to ngrest
Hi NGREST users and GateKeeper (loentar),

I would like to create a project that can support 10-20 services.

May someone guide me through steps.

So far I can only create one service using ngrest create Users. How can I include Groups as a service and then Roles and then many more.

Thanks  a ton in advanced.

Regards, Henry

Dmitry Utkin

unread,
Jun 14, 2017, 4:48:37 PM6/14/17
to ngrest
If you want to add a service code into the same library as Users service, you just have to add Groups.h/cpp alongside to Users.h/cpp and add Groups.h into inner users/users/CMakeLists.txt:

replace this line:

set(USERS_HEADERS Users.h)

to this

set(USERS_HEADERS Users.h Groups.h)



OR

if you want to make it a distinct library, create a new project in other directory:

ngrest create Groups

copy/move `groups/groups` directory inside `users/` project directory

edit `users/CMakeLists.txt` and append this to the end:

add_subdirectory(groups)
if (APPLE)
    set_target_properties(groups PROPERTIES SUFFIX ".dylib")
endif()





среда, 14 июня 2017 г., 7:25:25 UTC+3 пользователь Henry Nguyen написал:

Henry Nguyen

unread,
Jun 14, 2017, 6:29:56 PM6/14/17
to ngrest
Thank so much NGREST Gatekeeper ie Dmitry Utkin

My NGREST is the front-end towards database. I tested out the second option with fully code generation for every services. I believe that it works well but just need to some test application to confirm with you.

Can the first option support ngrest-db package add and code generation. I am happy to test it out and let you know as well.

Regards, Henry

Dmitry Utkin

unread,
Jun 15, 2017, 4:13:29 PM6/15/17
to ngrest
First options, yes. Definitely.

четверг, 15 июня 2017 г., 1:29:56 UTC+3 пользователь Henry Nguyen написал:

hanchinama...@gmail.com

unread,
Oct 11, 2017, 2:20:40 AM10/11/17
to ngrest
Hi,

do i need to create Groups service inside Users group or outside.?

Thanks,

Dmitry Utkin

unread,
Oct 11, 2017, 4:00:19 PM10/11/17
to ngrest
Hi.

It depends on your task. You can create service within the same shared object, as well as separate library.

среда, 11 октября 2017 г., 9:20:40 UTC+3 пользователь Kumar написал:

Kumar

unread,
Oct 13, 2017, 7:09:13 AM10/13/17
to ngrest
Hi,

Deployed ngrest under nginx. I have create two services(add,get)

santhosh@santhosh-Lenovo-U310:~$ ls restapi/
add  CMakeLists.txt  get

copied the lib to following location
--------------------------------
santhosh@santhosh-Lenovo-U310:~$ ls -l /opt/ngrest/services/
total 652
-rwxr-xr-x 1 root root 310344 Oct 13 11:30 add.so
-rwxr-xr-x 1 root root 353232 Oct 13 11:30 get.so

And added location in site-enabled config
--------------------------------
location ~ /(ngrest|restapi|get|getAll) {
    ngrest /opt/ngrest/services;
}

location ~ /(ngrest|restapi|add|addRecord) {
    ngrest /opt/ngrest/services;
}

loaded ngrest module and added included site-enabled in nginx.conf
--------------------------------
load_module /home/santhosh/.ngrest/ngrest-build/deploy/share/ngrest/modules/nginx/mod_ngrest.so;

include /etc/nginx/sites-enabled/*;

Able to do getAll service from browser

http://localhost/get/getAll

{
"result": [
  {
"empId": 200,
"empName": "jai",
"empOrg": "aticara"
},
  {
"empId": 100,
"empName": "madhu",
"empOrg": "isoke"
},
  {
"empId": 400,
"empName": "mohan",
"empOrg": "isoke"
},
  {
"empId": 300,
"empName": "santhosh",
"empOrg": "aticara“ "
}
],
}

Similarly not able to do for add(POST) service

http://localhost/add/addRecord?id=123&name=skumar&org=aticara

For your reference i have added my source code. pleaes advice how to resolve this.

Thanks,
Kumar
restapi.tar.gz
Reply all
Reply to author
Forward
0 new messages