134 points · by tahazsh · 6y ago · 88 comments
1. Add the backend under same repo.
2. Add a root docker-compose.yml instead of sending interested party to "install backend".
root
| - frontend
| - Dockerfile
| - ... code
| - README.md
| - backend
| - Dockerfile
| - ... code
| - README.md
| - .gitignore
| - README.md
| - docker-compose.yml
ThanksEven though simple projects don't necessarily need Docker to work, they are 100 times better off using Docker than doing things by hand, because that alternative means they are only deploying once and never again (updates, new environment, dev/staging/prod) and that's just not true.
The only acceptable alternative to Docker, is, IMHO, a makefile. If I open your project and see a Dockerfile, I'm just going to `docker build && docker run`. If I see a makefile, I'm just going to run `make help ; make run || make`. It greatly reduces the cognitive load if I only want to quickly see what the project does.
Real app built using this - https://github.com/sheshbabu/freshlytics
In a real world situation, I would attach id attributes to the elements for automated QA testing purposes.
And now I am questioning the whole Javascript ecosystem.
With stacks like Vue and Node I always feel I have to do the same work twice. Double models, validation in the front end and validation in the back end, and so on.
With frameworks like Blazor you are much more productive. And I believe this will be the future of developing SPAs.
Then I saw Bolero (F# framework built on Blazor). Now I'm super interested.
I don't even think that bytecode->WASM and Java->JavaScript should be that inherently different for frontend purposes. Then again, I never thought we'd need hyper-optimized JIT compilers for friggin' simplistic UIs, where you'd think that Microsoft BASIC would be fast enough... (Sure, it's great for lunning Linux, Quake or Alexa in the browser…)
But I'll try not ending up sounding facetious. From a code quality and ease of use POV, Blazor might be better, haven't done too much to argue that. And even rebranding the same technology after a few year's of both Moore's law and lessened expectations by users/developers is often a big difference from a marketing standpoint. And that does count, as it increases the community, which is where a lot of projects fail.
I think you can substitute Blazor with a large number of frameworks (RoR, Meteor, django, etc) and find a lot of people who believe it is the future of developing SPAs.
<base-button
v-if="isLoggedIn && currentUser.can('own_topics:write')"
class="new-topic-button"
:to="{ name: 'CreateTopic' }"
>
There is logic embedded in the view. Does this get compile-time checked (assuming you used a compiler such as TypeScript)? In my opinion this is the weak-point of Vue. It is possible to use JSX in Vue. But it is also possible to use non-compile-time-checked expressions. In React you only have compile-time-checkable syntax. That's better because when a code is written using React (by someone other than you) you immediately have some reassurance that some poor coding patterns are excluded.What logic is that? The v-if part? I've done a few larger vue apps where users have many different permissions. I don't see anything wrong with hiding something on the front end if a user doesn't have the permission. What would the alternative be? I remember the days of handling permissions via HTML templating engines... certainly a simple v-if statement in vue is better than that.
https://github.com/vuejs/vetur/pull/681#issuecomment-3631127...
I'm assuming that is so... Only I've seen some crazy stuff in front-end centric tutorials that seem to assume code injection isn't possible (if by malware or the js console..).
And you're doubly correct, the back-end better verify those requests as well. Can't trust user input, which includes HTTP requests from client apps...
I'm sure it's more, it's just not clear to me with my lack of experience in this area.
I'm, obviously, pulling some rabbits out of thin air here but... see this:
import Vue from 'vue'
Not knowing anything about Vue, you can still guess that Vue is serious magic just by looking at the way the code for the project is laid out.That's it.
Ah, but why is it noteworthy?
Cause assume, just for a second, you had a private package, that may also be able to pull rabbits out of dark places, and you had reasons to keep it unpublished. Like, you wouldn't want to release the code, not even in bundled apps. In that case, you would look at this HN item, and repo, and note that, yes, one can release code for a magic based app without releasing the code for the magic lib itself. And that this may allow someone at HN to comment Nice work! Just goes to show how clean and readable [insert magic lib name] code is. And this can start a conversation and lead to opportunities.
And that's worth noting.
But also worth nothing. Cause it's nonsense. You can always do neither.
Edit: I’m not saying this is the reason this specific item is on the front page or commenting on the repo itself (the code looks solid). I’m just herding speculative rabbits.
I apologize for that.
When a rabbit picture is sent over a fax machine, the machine makes a lot of noise. Unfortunately even if one listens intently, one will not be able to see the rabbit. The message still goes through though.
Few weeks ago a colleague suggested Vue for a project. Initially I was skeptical, but as I learn it, my mind is blown. Esp. look at quasar.dev, it's Vue with batteries included.
My reaction was the opposite of yours - I found the syntax to be some confusing "not really JS" that follows hard-to-discover rules and scoping. It felt very much like JSP - simple enough if you're just dropping in values, but as soon as something gets even slightly complex, it gets ugly quick. Error messages were also far less informative than React (to be fair, React has done a ton in the past couple of years to improve their error messaging).
Example: In react, if I want a <ui> with a bunch of <li>s, I tend to output a JSX <ul> with a bunch of <li>s from some JS loop. A 1:1 relationship between the tags I produce and the tags that are generated. My loop logic is pure JS, so no surprises there.
In Vue, the syntax is:
<ul id="example-1">
<li v-for="item in items"> {{ item.message }} </li>
</ul>Which seems perfectly readable, but...The "<li> tag doesn't represent what gets rendered, it's a TEMPLATE of what gets rendered. Can I reference "item" in another "v-" attribute of the <li>? What happens if I wanted to conditionally include/not-include an <li> for the list of items?
A list shouldn't be where "complex" problems start. A list should still be "simple"
My anecdote doesn't beat yours, (and, generally, your anecdote is the more common one), but I wanted to offer an opposing data point, because I expected Vue to be less involved than React, and I found the opposite to be true.
<li v-for="item in items" :title="item.hint"> {{ item.message }} </li>
I really don't have a problem thinking of them as templates. In a sense that's all we can do anyway with dynamic lists— I don't know how React works but it seems disadvantageous to be forced to run the loop again rather than be able to do a diff & DOM insert/splice behind the scenes.My only real complaint is that the HTML attribute gets lost a little too easily. I could probably hack up some syntax highlighting augmentations to fix that, but it doesn't really bother me enough.
For what it's worth, JSX is supported in Vue as well, although I've found it's not really my thing compared to Vue templates.
To take the example from the Vue docs:
// Component with a slot
<ul>
<li v-for="todo in filteredTodos" v-bind:key="todo.id">
<slot name="todo" v-bind:todo="todo">
{{ todo.text }}
</slot>
</li>
</ul>
// Consuming component
<todo-list v-bind:todos="todos">
<template v-slot:todo="{ todo }">
<span v-if="todo.isComplete">x</span>
{{ todo.text }}
</template>
</todo-list>
This can be rewritten in React with much simpler, cleaner code: // Component with a "slot"
<ul>
{filteredTodos.map(todo => props.renderTodo ? props.renderTodo(todo) : todo.text)}
</ul>
// Consuming component
<TodoList todos={todos} renderTodo={todo =>
`${todo.isComplete ? "x " : ""}${todo.text}`
}/>
Simplicity is key. In the React version you don't have to worry about the `slot` syntax, build a mental model of how Vue treats it, or risk running into the limitations of the feature.I just don't like mixing html and js like that, maybe that's why it also seems messy to me.
The vue example also isn't the greatest, some cruft could be removed using default slot and shorter syntax.
Depending on the use-case, I wouldn't want to put the conditional in the template.
Instead, I'd filter the array of `items`. Maybe using a computed property `filteredItems`.
The idea being, you shouldn't be putting Too Much Logic within the template.
Idk though, I started off in Vue and am very much enjoying it; I haven't spent a lot of time dabbling with React yet
<ul id="example-1">
<template v-for="item in items">
<li>{{ item.message }}</li>
</template>
</ul>What you have here does fix the 1:1 issue, but introduces an extra layer of abstraction that still feels unnecessary/less straight-forward compared to the React version.
If you want to display only some items of an array, it is recommended to compute a new array that only includes the items you want to display[1]. A less performant way is to put a v-if into your v-for loop[2].
If you have a v-for loop `item in items` you can access `item` in any attribute. See [3] for an example.
[1] https://vuejs.org/v2/guide/list.html#Displaying-Filtered-Sor...
[2] https://vuejs.org/v2/guide/list.html#v-for-with-v-if
[3] https://vuejs.org/v2/guide/list.html#v-for-with-a-Component
As you say, rendering a list shouldn’t be where the problems start.
Can you summarize what it does? The site isn't clear, but it looks interesting.
I've found out however that unit testing works fine for those cases.
https://jasonwatmore.com/post/2018/07/14/vue-vuex-user-regis...
The explanations are great, and the layered structure is nice and clean.
I've tried React and the learning curve was just too high for me. Learning Vue has been a joy by comparison.
https://hackernoon.com/your-node-js-authentication-tutorial-...