Needs somw work... template strings are in JS, and the use of zod example should probably mention the library. Similar for the call at the end, give a zod validated example.
I may add methods like...
User.fromJSON = (json:string): User {
// parse
// validate or throw
// return User
}
For clearer data handling from untrusted sources. Using a FE/BE shared definitions and validation library even.
Still kinda cool... I've thought about using a similar approach to using a server-side state machine, where each node simply gets the diffs via wss. This way a centralized state machine can be used for interactive games, training courses, etc... without directly exposing the state transition logic, only the result stream and a validated input path.
Lately I just use docker compose with caddy, and have each sub-app running in .watch mode against the source directory.
This does work too though, and if you're in control of the full codebase and don't have other local dependencies (database, redis, etc), then this may be better.
Source is linked from the article towards the bottom.
Interesting... Haven't needed to do this in a while, and frankly try to avoid it, but it can help when you need certain components to match across a corporation/organization in a consistent way with live updates.
Not 100% sure on the live updates without a publish, or if this just caches/forward the federated components, it's still interesting.
Umn... typescript/jsondoc can definitely help you with this issue.
/**
* Function for creating a new user in the system.
*
* @param user The username to generate an account for
* @param isAdmin If the user is an administrator
* @param sendWelcomeEmail If the system should send a welcome email
*/
export function createUser(user: string, isAdmin: boolean, sendWelcomeEmail: boolean) {
...
}
You need to specify the additional documentation at the method's source. With the documentation added above, the language module in your editor should allow for proper autocomplete.
Note: The JSDoc syntax for bare JS is very similar, you just have to define the type within the comment syntax.
That said, using a parameters object is often better for cases like this, where you may want a lot of optional parameters and additional details as part of this.
Looks like a homework assignment. Would probably break up the functionality into at least ES based modules. The source is very procedural looking in nature. Not bad, just could be difficult to enhance within scope.
Needs somw work... template strings are in JS, and the use of zod example should probably mention the library. Similar for the call at the end, give a zod validated example. I may add methods like... User.fromJSON = (json:string): User { // parse // validate or throw // return User } For clearer data handling from untrusted sources. Using a FE/BE shared definitions and validation library even.Umn... typescript/jsondoc can definitely help you with this issue. /** * Function for creating a new user in the system. * * @param user The username to generate an account for * @param isAdmin If the user is an administrator * @param sendWelcomeEmail If the system should send a welcome email */ export function createUser(user: string, isAdmin: boolean, sendWelcomeEmail: boolean) { ... } You need to specify the additional documentation at the method's source. With the documentation added above, the language module in your editor should allow for proper autocomplete. Note: The JSDoc syntax for bare JS is very similar, you just have to define the type within the comment syntax. That said, using a parameters object is often better for cases like this, where you may want a lot of optional parameters and additional details as part of this.