I use Angular and want to retrieve data from PostgresSQL, but I don't know where to store the database credentials correctly and how to connect Angular to PostgresSQL.
Do I need a Asp.net or Node.js backened and, if yes, what would it be like to retrieve data from database and send it to the frontend?
Yes. This logic should contains on backend side.
If you don't have a server side at the moment, then this is also not a problem. In this case, you can use the stub for development purposes. You can use a package like json-server for this.
Related
I've got an NextJS app with NextAuth and TypeORM.
I'm looking for the possibility to retrieve a specific user or custom entity in an api endpoint.
However, i don't know how to do this properly.
I don't want to re-initialize the connection options on every api for TypeORM and would like to use the connection set by the adapter. (idea of a singleton).
Someone has any idea on how to achieve that ?
Have a nice day !
I don’t know if I got your question, but I think the best way of doing it is by creating your Entities, connecting via TypeORM with synchronize option true.
It will create and update all your tables and columns from your defined model.
Then, you can create another connection to use in your api routes.
I don’t think Vercel can deploy it with a single connection without a custom implementation server implementation.
This guy made a solution that you can try
https://github.com/vercel/next.js/discussions/12254#discussioncomment-19769
This is another approach to the same function
https://github.com/typeorm/typeorm/issues/6241#issuecomment-643690383
I have two Symfony projects (a back application and an API).
The back application is the graphic side, it just call API.
The API is connected to database.
I would like to test my back : currently, at each test, I make an API call to reload the database but I have the impression that I make it wrong.... and moreover it's so slow...
There is a better solution ?
Thanks
It depends of the test purpose. If you want to test the logic of your back app I would mock the api client of your back app and simulate responses to be sure all kind of response are well processed.
Still quite new to meteor/coding and I have a question on how to connect meteor to a live api that uses websocket.
The api is from bittrex (exchange for cryptocurrency) and there is a node js package that gives a "subscribtion" to the api in order to get live data:
https://github.com/dparlevliet/node.bittrex.api
I manage to have it run with node with no problem but I would ideally like to connect it to Meteor in order to present the data nicely. The props should be updated live with the data received. (nb: there is a lot of data, it is continuously coming).
Is there a good way to do this or is meteor not suitable for this. It means the props would change continuously.
Would a node/react solution only be better ?
This question might get closed because it's a bit opinion based but...
You have a streaming data source providing data over ws. You could:
(a) have all your clients subscribe directly to that source and not involve your server at all. In this case you'd be just using React on the client and basically ignoring Meteor (even though you'd be building the UI in a Meteor app). I don't know how bitrex charges for access or how they scale across many connections so that may be an issue if there are many connections.
(b) use your Meteor app to proxy then fan-out the bitrex data. In this case you would:
subscribe to the bitrex data source from your server
copy the data into a mongo collection
publish that data using a Meteor publication.
Your clients would subscribe to the Meteor publication and on the front end you would get reactive data updates like any other Meteor app.
The benefits of (b) are that bitrex only sees one subscriber and your app looks like a pretty vanilla Meteor app. Also if you have to use any kind of api key or secret to access bitrex then that key doesn't need to be shared with the client side.
I want to setup a public form to write to Firebase via the Angular Firebase plugin AngularFire but it feels like there needs to be some security added so that data is only posted from that form, I can't see any interface to Whitelist a Domain/URL. Is there a way to only accept writes from a specific Form/URL without getting the User to login first?
Nope.
But it wouldn't help in your scenario anyway: when you're using Angular, all code is running in the user's browser. It might be served from your domain into that browser first, but just as easily the user might have saved the HTML locally and started running it that way.
It sounds like you're trying to secure things so that only your code can modify them, probably because you think that your code is the only thing that can be trusted to follow some of your application-specific business rules. Instead of trying to limit access to just your code, I'd instead recommend capturing the business rules server-side. Firebase has a very powerful security and data validation model just for that purpose. See https://www.firebase.com/docs/security/guide/
Once you enforce these business rules on the server, it doesn't matter how someone access your data. They could be using your code - or somebody could have taken your code (or an API that you've documented) and written a third-party application. Either way: the (security and validation) rules will be enforced by Firebase, so your data will stay valid and secure.
I want to enable an user to be able to communicate with other users through a site. I know that ASP.net is stateless, but what can I use for this synced communication? Java servlets?
I don't think you need to set up Java just to use a servlet for this. I would use AJAX and the database. I don't know ASP.NET but I PHP is similar in this case, being also basically "stateless". If you want to display some kind of asynchronous communication between two different users, say, from two different sessions, without a lot of refreshing (like chat), you can have the AJAX page constantly poll the database for new messages, and display them when they come in. You can also use AJAX to insert the new messages, giving the user read/write access to this messages data structure. Since the "other" user is doing the same thing, user A should see new messages pop up when user B types them in.
Is that what you mean?
You probably don't want to use sessions for things like chat messages but you probably could use some type of implementation of queueing using MSMQ.
The approach to chat could be done in many different ways, this is just a suggesting off the top of my head.
Could do a messaging solution in Java Servlets using the application context. Objects stored as attributes in the application context are visible from anywhere in your webapp.
Update: Chat like functionality... I guess that would be AJAX polling your message structure stored in the app context unless you want to use something like applets.
Don't know if it's any good, but there's a chat servlet here that might be useful to use or learn from if you decide to go the Java route...
ASP.NET is "stateless" but it maintains state using Sessions. You can use them by default just using the Session[] keyword.
Look at ASP.NET Session State for some details from Microsoft.