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


TypeScript gearworks.Server類代碼示例

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


在下文中一共展示了Server類的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: startServer

async function startServer()
{
    //Validate environment variables
    Object.getOwnPropertyNames(config).forEach((prop, index, propNames) =>
    {
        // Ensure config prop isn't optional
        if (config.OptionalProps.indexOf(prop) === -1 && typeof config[prop] === "undefined")
        {
            throw new Error(`Configuration property ${prop} cannot be null or empty. Check modules/config.ts to find the correct environment variable key for ${prop}.`);
        }
    })
    
    //Configure the server's app state
    server.app = {
        appName: config.AppName,
        isLive: config.isLive,
        rootDir: path.resolve(__dirname),
    };
    
    await registerPlugins();
    
    //Configure authentication. Must be done before configuring routes
    configureAuth(server);    
    
    //Filter all responses to check if they have an error. If so, render the error page.
    server.ext("onPreResponse", (request, reply) =>
    {
        const resp = request.response;
        
        if (resp.header)
        {
            resp.header("X-STAGES-API-VERSION", "1.0.0");
        }

        return reply.continue();
    });    
    
    //Register all app routes.
    RoutesToRegister.forEach((register) => register(server));
    
    return server.start((error) =>
    {
        if (error)
        {
            throw error;
        }
        
        console.log(`${server.app.isLive ? "Live" : "Development"} server running at ${server.info.uri}`);
    })
}
開發者ID:nozzlegear,項目名稱:stages-api,代碼行數:50,代碼來源:server.ts

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: registerPlugins

async function registerPlugins()
{
    //Inert gives Hapi static file and directory handling via reply.file and reply.directory.
    await server.register(require("inert"));
    
    //Adds async support to Hapi route handlers.
    await server.register(require("hapi-async-handler"));

    //Yar is a cookie management plugin for Hapi.
    await server.register({
        register: require("yar"),
        options: {
            storeBlank: false,
            cookieOptions: {
                password: config.YarSalt,
                isSecure: server.app.isLive,
                ttl: 7 * 24 * 60 * 60 * 1000, // 7 days in milliseconds
                ignoreErrors: true, //tells Hapi that it should not respond with a HTTP 400 error if the session cookie cannot decrypt
                clearInvalid: true  //tells Hapi that if a session cookie is invalid for any reason, to clear it from the browser.
            }
        }
    })
    
    await registerCaches(server);
}
開發者ID:nozzlegear,項目名稱:stages-api,代碼行數:25,代碼來源:server.ts


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