How to use the @podium/utils.HttpIncoming function in @podium/utils

To help you get started, we’ve selected a few @podium/utils 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 podium-lib / podlet / lib / podlet.js View on Github external
return async (req, res, next) => {
            const incoming = new HttpIncoming(req, res);

            try {
                await this.process(incoming);
                // if this is a proxy request then no further work should be done.
                if (incoming.proxy) return;

                // set "incoming" on res.locals.podium
                objobj.set('locals.podium', incoming, res);

                if (res.header) {
                    res.header('podlet-version', this.version);
                }

                res.podiumSend = (data, ...args) =>
                    res.send(this.render(incoming, data, ...args));
github podium-lib / layout / lib / layout.js View on Github external
return async (req, res, next) => {
            const incoming = new HttpIncoming(req, res, res.locals);

            try {
                await this.process(incoming);
                // if this is a proxy request then no further work should be done.
                if (incoming.proxy) return;

                // set "incoming" on res.locals.podium
                objobj.set('locals.podium', incoming, res);

                res.podiumSend = (data, ...args) =>
                    res.send(this.render(incoming, data, ...args));

                next();
            } catch (error) {
                next(error);
            }
github podium-lib / podlet / __tests__ / podlet.js View on Github external
test('res.podiumSend() - contructor argument "development" is set to "true" - should append default wireframe document', async () => {
    const options = Object.assign({}, DEFAULT_OPTIONS, {
        development: true,
    });
    const podlet = new Podlet(options);
    const server = new FakeExpressServer(podlet, (req, res) => {
        res.podiumSend('<h1>OK!</h1>');
    });

    await server.listen();
    const result = await server.get({ raw: true });

    const incoming = new HttpIncoming(SIMPLE_REQ, SIMPLE_RES);
    expect(result.response).toEqual(template(incoming, '<h1>OK!</h1>'));

    await server.close();
});
github podium-lib / podlet / __tests__ / podlet.js View on Github external
test('.process() - call method with HttpIncoming - should return HttpIncoming', async () => {
    const podlet = new Podlet(DEFAULT_OPTIONS);
    const incoming = new HttpIncoming(SIMPLE_REQ, SIMPLE_RES);
    const result = await podlet.process(incoming);
    expect(result).toEqual(incoming);
});
github podium-lib / layout / __tests__ / layout.js View on Github external
test('.process() - call method with HttpIncoming - should return HttpIncoming', async () => {
    const layout = new Layout(DEFAULT_OPTIONS);
    const incoming = new HttpIncoming(SIMPLE_REQ, SIMPLE_RES);
    const result = await layout.process(incoming);
    expect(result).toEqual(incoming);
});
/*
github podium-lib / podlet / __tests__ / podlet.js View on Github external
this.app = http.createServer(async (req, res) => {
            const incoming = new HttpIncoming(req, res);
            const result = await podlet.process(incoming, process);
            onRequest
                ? onRequest(result)
                : result => {
                      result.response.status(200).json(result);
                  };
        });
        this.server = undefined;

@podium/utils

Common generic utility methods shared by @podium modules.

MIT
Latest version published 13 days ago

Package Health Score

78 / 100
Full package analysis