本文整理汇总了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),
}
})
}
示例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),
}
})
}
示例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)
}
})
}
示例4: registerRoutes
export function registerRoutes(server: Server)
{
server.route({
path: Routes.GetHome,
method: "GET",
handler: {
async: (request, reply) => getHomepage(server, request, reply)
}
})
}
示例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)
}
})
}
示例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)
},
})
}
示例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)
}
});
}
示例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)
}
})
}
示例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",
})
}
})
}
示例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)
}
})
}