當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Server.route方法代碼示例

本文整理匯總了TypeScript中gearworks.Server.route方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Server.route方法的具體用法?TypeScript Server.route怎麽用?TypeScript Server.route使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gearworks.Server的用法示例。


在下文中一共展示了Server.route方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        method: "GET",
        path: Routes.GetShopify,
        config: {
            auth: {
                strategies: [strategies.basicAuth, strategies.shopifyRequest],
            }
        },
        handler: {
            async: (request, reply) => connectShopify(server, request, reply),
        }
    });
    
    server.route({
        method: "GET",
        path: Routes.GetShopifyActivate,
        config: {
            auth: {
                strategies: [strategies.basicAuth, strategies.shopifyRequest],
            }
        },
        handler: {
            async: (request, reply) => activateShopifyPlan(server, request, reply),
        }
    })
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:28,代碼來源:connect-routes.ts

示例2: registerRoutes

export default function registerRoutes(server: Server)
{
    server.route({
        path: "/users",
        method: "POST",
        config: {
            auth: strategies.masterAuth,
            validate:{ 
                payload: joi.object().keys({
                    name: joi.string().label("Name"),
                    username: joi.string().email().label("Username"),
                    password: joi.string().min(6).label("Password"),
                    accountId: joi.string().label("Account Id"),
                })
            },
        },
        handler: {
            async: (request, reply) => createUser(server, request, reply)
        }
    })

    server.route({
        path: "/users/{id}",
        method: "GET",
        config: {
            auth: strategies.accountAuth,
            validate: {
                params: joi.string().required().label("User Id")
            }
        },
        handler: {
            async: (request, reply) => getUser(server, request, reply)
        }
    })

    server.route({
        path: "/users/{id}",
        method: "PUT",
        config: {
            auth: strategies.accountAuth,
            validate: {
                params: joi.string().required().label("User Id")
            }
        },
        handler: {
            async: (request, reply) => updateUser(server, request, reply),
        }
    })
}
開發者ID:nozzlegear,項目名稱:stages-api,代碼行數:49,代碼來源:users-routes.ts

示例3: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        method: "GET",
        path: Routes.GetSetup,
        config: {
            auth: strategies.basicAuth,
        },
        handler: {
            async: (request, reply) => getSetupForm(server, request, reply)
        }
    });

    server.route({
        method: "POST",
        path: Routes.PostSetup,
        config: {
            auth: strategies.basicAuth,
        },
        handler: {
            async: (request, reply) => setup(server, request, reply)
        }
    });
    
    server.route({
        method: "GET",
        path: Routes.GetPlans,
        config: {
            auth: strategies.basicAuth,
        },
        handler: {
            async: (request, reply) => getPlans(server, request, reply)
        }
    });
    
    server.route({
        method: "POST",
        path: Routes.PostPlans,
        config: {
            auth: strategies.basicAuth,
        },
        handler: {
            async: (request, reply) => selectPlan(server, request, reply)
        }
    })
}
開發者ID:yashodhank,項目名稱:deliver-on,代碼行數:46,代碼來源:setup-routes.ts

示例4: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        path: Routes.GetHome,
        method: "GET",
        handler: {
            async: (request, reply) => getHomepage(server, request, reply)
        }
    })
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:10,代碼來源:home-routes.ts

示例5: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        method: "POST",
        path: Routes.GetAppUninstalled,
        config: {
            auth: strategies.shopifyWebhook
        },
        handler: {
            async: (request, reply) => handleAppUninstalled(server, request, reply)
        }
    })
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:13,代碼來源:webhook-routes.ts

示例6: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        method: "OPTIONS",
        path: Routes.AppConfig,
        config: {
            auth: false,
            plugins: {
                crumb: false,
            }
        },
        handler: {
            async: (request, reply) => options(server, request, reply)
        }
    })

    server.route({
        method: "GET",
        path: Routes.AppConfig,
        config: {
            auth: false,
            plugins: {
                crumb: false,
            }
        },
        handler: {
            async: (request, reply) => getAppConfig(server, request, reply)
        }
    });

    server.route({
        method: "PUT",
        path: Routes.AppConfig,
        handler: {
            async: (request, reply) => updateAppConfig(server, request, reply)
        },
    })
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:38,代碼來源:api-v1-routes.ts

示例7: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        method: "GET",
        path: Routes.GetTag,
        config: {
            auth: false,
            plugins: {
                crumb: false,
            }
        },
        handler: {
            async: (request, reply) => getTag(server, request, reply)
        }
    });
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:16,代碼來源:tag-routes.ts

示例8: registerRoutes

export function registerRoutes(server: Server)
{
    server.route({
        path: "/account",
        method: "GET",
        handler: (request, reply) => reply.redirect(Routes.GetSettings),
    })

    server.route({
        path: Routes.GetSettings,
        method: "GET",
        handler: {
            async: (request, reply) => getSettings(server, request, reply),
        }
    })

    server.route({
        path: Routes.PostSettings,
        method: "POST",
        handler: {
            async: (request, reply) => postSettings(server, request, reply)
        }
    })

    server.route({
        path: Routes.GetBilling,
        method: "GET",
        handler: {
            async: (request, reply) => getBilling(server, request, reply),
        }
    })

    server.route({
        path: Routes.PostBilling,
        method: "POST",
        handler: {
            async: (request, reply) => postBilling(server, request, reply),
        }
    })

    server.route({
        path: Routes.UpdatePlan,
        method: "GET",
        config: {
            auth: {
                strategies: [strategies.basicAuth, strategies.shopifyRequest],
            }
        },
        handler: {
            async: (request, reply) => updatePlan(server, request, reply)
        }
    })
}
開發者ID:nozzlegear,項目名稱:deliver-on,代碼行數:53,代碼來源:account-routes.ts

示例9: registerRoutes

export default function registerRoutes(server: Server)
{
    server.route({
        path: "/",
        method: "GET",
        config: {
            auth: false,
        },
        handler: (request, reply) => {
            reply({
                stages: "Welcome!",
                url: "https://getstages.com",
                version: Version,
                uuid: "68e02e55-37f6-4ee3-a8b2-62690cdbf31a",
            })
        }
    })
}
開發者ID:nozzlegear,項目名稱:stages-api,代碼行數:18,代碼來源:home-routes.ts

示例10: registerRoutes

export default function registerRoutes(server: Server)
{
    const createValidation = joi.object().keys({
        planId: joi.string().only(Plans.map(p => p.id)).required(),
    });
    const putValidation = joi.object().keys({
        
    })

    server.route({
        path: "/accounts",
        method: "GET",
        config: {
            auth: strategies.masterAuth,
        },
        handler: {
            async: (request, reply) => listAccounts(server, request, reply)
        }
    })

    server.route({
        path: "/accounts",
        method: "POST",
        config: {
            auth: strategies.masterAuth,
            validate: {
                payload: createValidation,
            }
        },
        handler: {
            async: (request, reply) => createAccount(server, request, reply)
        }
    })

    server.route({
        path: "/accounts/{id}",
        method: "GET",
        config: {
            auth: strategies.accountAuth,
            validate: {
                params: joi.object().keys({
                    id: joi.string().required().label("Account Id"),
                })
            }
        },
        handler: {
            async: (request, reply) => getAccount(server, request, reply)
        }
    })

    server.route({
        path: "/accounts/{id}",
        method: "PUT",
        config: {
            auth: strategies.masterAuth, //Master auth so an account can't change its own plan without going through OAuth process.
            validate: {
                params: joi.object().keys({
                    id: joi.string().required().label("Account Id"),  
                }),
                payload: putValidation
            }
        },
        handler: {
            async: (request, reply) => updateAccount(server, request, reply)
        }
    })
}
開發者ID:nozzlegear,項目名稱:stages-api,代碼行數:67,代碼來源:accounts-routes.ts


注:本文中的gearworks.Server.route方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。