Write code

>write code
>it's awful
Should I refactor? This is getting out of control.

Attached: 1643646036275.jpg (975x1377, 502.65K)

yes
and write tests
over engineer everything

You're being sarcastic, aren't you?

Attached: 1637942770998.jpg (635x444, 29.78K)

no im not
if you think you need to refactor it, you should do it
post commit i will review it

Attached: 1634081434014.jpg (500x307, 19.46K)

I'll post the repo for you.

It's a hobby project I plan on showing to potential employers. I had just gotten done overhauling most of the CSS but when I looked back to see what I had done it's a complete fucking mess.

github dot com slash vovi-z slash zenonscraper-web
It's a blockchain explorer for an obscure blockchain called Zenon. It actually works... surprisingly. This is the webserver which runs on nextjs.

No. Turn off your monitor. Get a piece of paper and a pen. Design it better.

you expect me to review the whole code base nigga??
just tell me which component

[code]
const pool = new Pool({
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASS,
database: process.env.DB_DATABASE,
port: Number(process.env.DB_PORT)
})
[/code]
this is really bad, have any sensitive data on the backend
or create a proxy server if say you need to expose an api key, i cant imagine having your db pass on the front end
i would not employ you

No unless you are told to (unless it's a personal project, then go nuts and aim for perfection).

If it works, it will remain like that until there's enough time to refactor it.

How would you connect to the database then?

They're all terribly organized, I already know that and I'm not going to ask you to waste your time. If you really do want a peak, just go to pages/index.tsx and you'll see a sea of divs and barely any components being used. That's supposed to be the home page.

>main/pages/token/[token].tsx
user no
wtf are you doing
although it is good that you know how to use sql but you should use orm
i would recommend using prisma
if you can do all this and host it on aws you are more employable than 90% of the people applying for mid level positions
you need to have a backend server
you already know how everything works, why not harness your potential

>main/pages/index.tsx
this is honestly not that bad, just move it to separate components
and dont use a ui framework to make sql queries, honestly why is this a thing

>you need to have a backend server
So
Client frontend nextjs backend database

Where can I read more about this? I assume this is for security by moving the database user authentication to another machine not exposed to the internet? I am not storing any sensitive information in the database (it's blockchain information, it's all public anyway.) so I forgo'd a lot of security.

Also, I wrote the SQL queries myself so I could learn it. Prisma looks nice to use, thanks for the recommendation.

I thought it was ugly too but I wrote the queries specifically meant for each page, so I'm having some trouble thinking how to refactor them to be more universal.

Attached: 1565716795147.jpg (900x1200, 169.71K)

since you already know ts, pick up nestjs and start writing apis
if you are writing a new component on the same page, i would just move it to a new folder say /components
anything you think that can be reused, just move it to a separate component
ok im off now i actually have to work all night today, our sprint ends tomorrow

Thank you for looking at my code, I appreciate it. I will read more up on nestjs. Hope your sprint goes well

Also, for anyone reading I am currently looking for an (paid/unpaid) internship. Please send any help.

Attached: 1625763915250.jpg (750x688, 183.65K)

I'm looking for a remote webdev job but I just started fullstackopen
Is is possible to get a job and learn as I go?
I don't mind doing front end only

Guess I'll bump this thingthing

Imagine die smell

I did more reading on what you said, and I'll post about what I learned in case anyone else is curious.

Accessing the database via REST APIs are much much safer than direct database access because of credential security as mentioned before. If the web server is compromised since the database credentials are stored there an intruder now has access to the database, meaning they could DROP all the tables in the database, or worse, copy all the usernames/passwords if you're storing sensitive data.

Having an API server in between the web server and the database server provides an extra layer of protection because you only expose an API key, which only has permission to pre-specified API endpoints. Further security can be guaranteed by having a proxy server like the other user said to hide API keys.

My next question is can my two servers (frontend/API) share the same domain name? I want to create a nestjs API server so I can connect like this:

nextjs (frontend) nestjs (API) database

However, I don't want to pay for another domain name. How can I expose it using the same base URL? I already have the nextjs application listening on port 80, I guess I could have an nginex reverse proxy point to another port/machine depending on the request (baseurl.com/api). I'm at a lost here because I don't know what keywords to look up on Google.

Attached: 1639557201172.png (1280x720, 972.64K)

refactor?
what it mean?

There are some days where I just throw out everything that I wrote and do it over.
>write tests
How would Anonymous be sarcastic about this?
>over engineer everything
If you're not using a DI/IoC framework and writing every single class to an interface that you register with that framework, you are definitely doing everything wrong, unironically.

just set up a subdomain, api.example.com
shouldn't cost extra if you have a good provider.