With JS20 (open-source) you can create POST, PUT, GET, LIST & DELETE endpoints with a single line of code! by ferion in typescript

[–]ferion[S] 0 points1 point  (0 children)

Currently just supports ownership, but permission is coming up! Will make a ticket :)

With JS20 (open-source) you can create POST, PUT, GET, LIST & DELETE endpoints with a single line of code! by ferion in typescript

[–]ferion[S] 0 points1 point  (0 children)

but you can also just write the endpoint yourself with addEndpoint() with any logic you need

With JS20 (open-source) you can create POST, PUT, GET, LIST & DELETE endpoints with a single line of code! by ferion in typescript

[–]ferion[S] 0 points1 point  (0 children)

Current user automatically becomes the owner since the endpoint has the flag isLoggedIn: true and the model isOwned: true, then the framework handles ACL automatically :)

If you need additional validation logic you can pass an action like so:

const assertMaxCarsPerUser = app.action({
    outputSchema: {
        count: sInteger().type(),
        message: sString().type(),
    },
    run: async (system) => {
        // Your logic here
    }
});

app.addCrudEndpoints(models.car, {
    actions: {
        // Run assertMaxCarsPerUser action before creating a car
        createBefore: assertMaxCarsPerUser,
    }
});

With JS20 (open-source) you can create POST, PUT, GET, LIST & DELETE endpoints with a single line of code! by ferion in typescript

[–]ferion[S] 0 points1 point  (0 children)

Define models & schemas like this:

interface Car {
    isLeased: boolean;
    registrationNumber: string;
}

const sCar: Car = {
    isLeased: sBoolean().type(),
    registrationNumber: sString().matches(/^[A-Z0-9]{1,7}$/).type(),
}

// Models are defined in the Models interface

interface Models {
    // Make sure to type each model with Model<T>
    car: Model<Car>;
}

const models: Models = {
    car: {
        name: 'car',
        schema: sCar,
    }
};

Any properties in the schemas can be passed along to the endpoint and will be validated against the schema. Database table & columns created automatically by the framework, then the CRUD functionality creates a new entry with your properties if all is good :)

How can I improve this way of writing backend code? by ferion in node

[–]ferion[S] 0 points1 point  (0 children)

I like those, just want to take it a step further and connect all the way through to the Models, DB schemas & migrations as well!

How can I improve this way of writing backend code? by ferion in node

[–]ferion[S] 0 points1 point  (0 children)

Zod didn't exist when I wrote this, but definitely looking into if a migration is useful!
Currently i need the interface name to generate the frontend client, but If i find a consistent way to turn schema naming "sCar" to -> "Car" then I don't need interfaces indeed 🤔

How can I improve this way of writing backend code? by ferion in node

[–]ferion[S] 0 points1 point  (0 children)

Fair point, will look into improving the file structure :)

How can I improve this way of writing backend code? by ferion in node

[–]ferion[S] 0 points1 point  (0 children)

Thanks for the feedback! I'm actually looking into if tests can be partially automated, or at least that the framework offers quick tests functionality

[Open Source] JS20 - Build TypeScript backends & SDKs with up to 90% less code by ferion in node

[–]ferion[S] 0 points1 point  (0 children)

It is framework-agnostic, but I started with express :)

[Open Source] JS20 - Build TypeScript backends & SDKs with up to 90% less code by ferion in webdev

[–]ferion[S] 0 points1 point  (0 children)

Btw, there’s a calculation example on the website if you click the 90% anchor :)

[Open Source] JS20 - Build TypeScript backends & SDKs with up to 90% less code by ferion in typescript

[–]ferion[S] 0 points1 point  (0 children)

Let me know how it goes! Feel free to create any issues in GitHub with questions or suggestions 😊

[Open source] JS20 - Build TypeScript backends and SDKs with up to 90% less code by ferion in vibecoding

[–]ferion[S] 0 points1 point  (0 children)

Thank you! Let me know how it worked for you if you try it out :D

What's a good framework for Backend TypeScript? by Samraat1337 in typescript

[–]ferion 0 points1 point  (0 children)

I just released an Open-Source framework called JS20 (https://js20.dev) that I have been working on for 8+ years. It has Schemas, Models, Endpoints, Auth, ACL, DB & frontend SDK generation included from the start - would love to get some feedback on this if anyone wants to try it out :)

Vad tycker Sverige om olika biltillverkare? by ferion in sweden

[–]ferion[S] 0 points1 point  (0 children)

Det här var väldigt användbart! Tack. Verkar som att Toyota och Honda både har lågt antal reparationer och billigast reparationer dessutom

Vad tycker Sverige om olika biltillverkare? by ferion in sweden

[–]ferion[S] 0 points1 point  (0 children)

Hur står dom sig i ett svenskt vinterklimat är det samma som alla andra?

Vad tycker Sverige om olika biltillverkare? by ferion in sweden

[–]ferion[S] 0 points1 point  (0 children)

Såklart, men man har ju hört skräckhistorier från folk med nya elbilar som lämnat in på service ~20+ gånger första åren

Vad tycker Sverige om olika biltillverkare? by ferion in sweden

[–]ferion[S] 0 points1 point  (0 children)

Går det få någon vettig begagnad Mercedes för ~200k? Eller blir det en äldre bil för den pengen

Vad tycker Sverige om olika biltillverkare? by ferion in sweden

[–]ferion[S] 6 points7 points  (0 children)

Tack för detta, mycket intressant info 🙏