ngrok / ngrok-javascript

Embed ngrok secure ingress into your Node.js apps with a single line of code.
https://ngrok.com
Apache License 2.0
86 stars 17 forks source link

Created Sails.js example #109

Open neonexus opened 7 months ago

neonexus commented 7 months ago

This is a stripped-down version, of my working example I've been cultivating for a bit now, on my open-source repo (terrible name I know, but it gets the point across): sails-react-bootstrap-webpack.

START RANT

I've spent time on this, mostly because I feel like Sails doesn't get enough credit / recognition. The Node-Machine idea that @mikermcneil came up with years ago I always felt was better than TypeScript. It's what drives Sails' main features, and looks like this:

module.exports = {
    friendlyName: 'Create User',

    description: 'Create a new user.',

    inputs: {
        firstName: {
            type: 'string',
            required: true,
            maxLength: 70
        },

        lastName: {
            type: 'string',
            required: true,
            maxLength: 70
        },

        password: {
            type: 'string',
            maxLength: 70
        },

        email: {
            type: 'string',
            isEmail: true,
            required: true,
            maxLength: 191
        }
    },

    exits: {
        created: {
            responseType: 'created'
        },
        badRequest: {
            responseType: 'badRequest'
        },
        serverError: {
            responseType: 'serverError'
        }
    },

    fn: (inputs, exits) => {
           // Run your main controller code here; using `inputs` as pre-validated inputs, and exits as if `async` by default.

            return exits.created({user});
        });
    }
};

It's easily human and computer readable. Can very simply be consumed by documentation generation. Why the world decided TypeScript was better is beyond me.

END RANT