How to use the webiny-api.app.endpoints function in webiny-api

To help you get started, we’ve selected a few webiny-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webiny / webiny-js / examples / api / src / express.js View on Github external
app.get("/api/discover", async (req, res) => {
        const onlySpecificEndpoints = Array.isArray(req.query.include);
        const excludeEndpoints = Array.isArray(req.query.exclude);
        const usages = req.query.usages;

        const endpoints = [];
        for (let i in webiny.endpoints) {
            const endpoint = webiny.endpoints[i];
            if (onlySpecificEndpoints) {
                if (!req.query.include.includes(endpoint.classId)) {
                    continue;
                }
            }
            const current = { classId: endpoint.classId, url: i, methods: [] };
            const instance = new endpoint.versions[endpoint.latest]();
            const apiMethods = instance.getApi().getMethods();
            Object.keys(apiMethods).forEach(name => {
                current["methods"].push(apiMethods[name].toJSON());
            });

            if (excludeEndpoints) {
                if (req.query.exclude.includes(current.classId)) {
                    continue;
                }
github webiny / webiny-js / examples / api / src / express.js View on Github external
app.get("/api/discover", async (req, res) => {
        const onlySpecificEndpoints = Array.isArray(req.query.include);
        const excludeEndpoints = Array.isArray(req.query.exclude);
        const usages = req.query.usages;

        const endpoints = [];
        for (let i in webiny.endpoints) {
            const endpoint = webiny.endpoints[i];
            if (onlySpecificEndpoints) {
                if (!req.query.include.includes(endpoint.classId)) {
                    continue;
                }
            }
            const current = { classId: endpoint.classId, url: i, methods: [] };
            const instance = new endpoint.versions[endpoint.latest]();
            const apiMethods = instance.getApi().getMethods();
            Object.keys(apiMethods).forEach(name => {
                current["methods"].push(apiMethods[name].toJSON());
            });

            if (excludeEndpoints) {
                if (req.query.exclude.includes(current.classId)) {
                    continue;