Directus api and app on same server as front-end - apache

I'm attempting to create a small website using Directus as a back end, since it has a nice interface for managing a database. The front end will be coded in VueJS, and I'd like them both on the same site. I'm using Apache. For example:
www.example.com = VueJS frontend that pulls information from the Directus backend
www.example.com/admin = Directus admin link
www.example.com/api/[whatever] = RESTful api access
I've messed around with virtualhosts a bit but I can only move the entire directus app to a different port, which I don't want to do since I don't want admins to have to type the port number in manually if they want to access the example.com/admin interface.

I think you can put the API on sub-domain like api.example.com that way both will be available on the same server.
I am just starting with the Directus and met with the same issue of putting both components and thought to put as written above.
If you followed some other approach, pls post here so that it can help people like me.

I have created a small mixin library for Vue.JS 3 and Directus API that makes it easier for developers to make API calls quicker and with almost no code needed.
It supports fetchCollection, fetchBtId, Sort, Filter and Search API endpoints.
Check it out. Hope it helps anybody in the future.
https://github.com/Slaveworx/api-rabbit

Related

Storefront event webhooks in Shopware 6 app development

I developing an app and basicly if an user loaded a product in the storefront it should send a request to my server. So i thought thats possible with webhooks. But unfortunately there is no webhook for this case.
The closest thing i could find is the product.written webhook but that seems useless for my case.
Anyone has an idea how i could realize my request?
I use Shopware 6.4.11.1 as development enviroment.
Although I have not found any appropriate webhook in the webhook events reference, this may be doable in a slightly different way, without using the Shopware App Webhook mechanic.
In the Shopware documentation there are shown ways to add Storefront scripts to an app. There is even an example for product-page-loaded. You would be able to execute some of your own code in there, but honestly I have not tried to ping external servers like this and I can't tell you that this will surely work.
You could also potentially add some custom JS code that pings your server with the appropriate info.
Unfortunately I don't think you can compel Shopware to send a request from its backend on a ProductPageLoadedEvent

Where to store an Rest API

So I wrote an app in React Native. Now I have my Django Rest framework and a mysql database. I know: I should pay a hosting service to host my database and put the React Native code in the playstore. (This is meant symbolically) But Now I still have the Django Rest framework project - where should I store that? I may also have profile images in the app. Where should I store those? Sorry if the question seems a bit silly
You just need to get a webserver. For example Digital Ocean or Amazon Webservice, etc.. There you have to upload the project and you access the website over your own domain e.g.: www.yourproject.com
Now you can use your urls for example
www.yourproject.com/api/user
I hope I could help you

How to make API for website that is not mine and also requires a login?

I'm trying to create a react native app that uses data from a website that is not mine. I need to enter a login and password to get into this website.
I was thinking about using a web scraper on the backend to accomplish this, but I wasn't sure this was the best approach or even possible. How should I go about doing this?
If you could find the API from the network tabs, then use that API instead. Web Scrapers are more prone to be unstable, you wouldn't want to change the scraper again and again if someone from the website changes something in their UI. Reach out for API first, scraper should be your last option.

Next.js with express.js or without express.js?

I have seen many people using nextjs with expressjs and without expressjs framwork. Can someone please explain why do we need expressjs with nextjs? Nextjs works as SSR without expressjs. What does expressjs add to nextjs when we use it together? Assuming that we are using different rest api server.
You don't need to use expressjs if all you want is server-side rendering. But if you want to go beyond that by adding an API, as an example, then you need to be able to override the routing and that's when you'd add expressjs in front. Express will get the request and see if it is for the API or if it's just a normal nextjs page. LogRocket has a very good tutorial on this https://blog.logrocket.com/how-to-build-a-server-rendered-react-app-with-next-express-d5a389e7ab2f/
You most likely don't need to override Next's default server. For edge cases where you do, you'll see examples showing a custom server extending Next's default. You can use whatever server framework you want – Express, Hapi, etc.
https://nextjs.org/docs/advanced-features/custom-server

To build an App for an Internet site without its API and Schema

I was asked to build a control-system for a Ebay-like Finnish auction-site huuto.net.
The system would reopen closed auctions by a specific rules. It would be completely external from the main site, running at an external website.
The site is however unwilling to release its API and Schema. I know no way to build such a system without knowing its API.
How do you build an internet site without its API and Schema?
You could try some form of automatic browsing: mechanize
Edit:
Examples here.
I think you're asking about building a site that interacts with another site without using a well-defined API. Is that right?
You can interact with an external site without using an official API - in order to do so, you need to imitate a normal site visitor and send your requests to the site frontend (in much the same way as a web crawler does). Tools like hpricot, mechanize and curl can help you parse the content of pages and send requests, but in doing so your system may be quite brittle. Any change to the target site might mean you have to rewrite portions of your system.
It might be possible to get the data you need by screen scraping the site. You could perform the operations you want to do by POSTing data into their forms or using a WebClient type API to make your program act like a web browser but that's likely to be an extremely brittle solution.
Honestly though, without an API, there really is no good solution.
you either need access to the database or an API, otherwise no point in even trying.