Can I copy the projects api directory into another strapi project?

System Information
  • Strapi Version: 3.1.0
  • Operating System: Ubuntu 18.04
  • Database: postgres
  • Node Version: 12
  • NPM Version: 6.14.6
  • Yarn Version: 1.22.0

I created a Digitalocean Strapi one-click droplet, pushed it to github and pulled it locally. Here I copied the api directories from my locally developed strapi project into the fresh one from DO. Pushed the code to github and pulled it into the dropled. When I open the admin I see all the copied collection types and single types. But when I test the endpoints (with postman) i get an 404 not found error.
So my question, is this even possible to do like that or am I just missing a step when copying the api directory into the new project?
Thank you very much

Did u move your database also?
did u set the permissions for api endpoints?

Thank you for your reply!
I wasn‘t aware that the routings/endpoints were stored in the db.
Everytime a new Collection or single Type is created, strapi restarts it self. I assume that behind the scene there is some magic involved that the new created endpoints are somehow „registered“ in the config.
When you just copy the types in the api directory this „registration“ is missing and there fore the copied api is not exposed to the outside world.
I think the easiest way is just to recreate the api in the one click droplet.

Hi @dino_deck
I have a similar situation and I also need to copy the api’s from one project to another.
My situation is that I have used strapi since the beta and I think that there are old unused code in my strapi project. I would like to install a fresh ver 3.4.1 and then copy my api definitions.

I se that there is a command:
strapi configuration:dump -f dump.json
that dump configuration. But I don’t think it also dumps my api definitions.

So, as you, I would like to know how to copy my api definitions into a new project.
If you figure out, then please let me know.

Regards

Hi,
To be honest and to save frustration i just went ahead and recreated the api in a fresh strap project. I tried the dump comand but it didn’t yield the desired effect.
It took me 1/2 hour to recreate the api. So it was ok for me. But its a rather uncomplicated one…
Sorry I don’t have better news.
Best, dino

Hi @dino_deck
I figured it out with some advice from @DMehaffy