hapijs

How do I stream data to browsers with Hapi?

馋奶兔 提交于 2019-12-30 08:17:14
问题 I'm trying to use streams to send data to the browser with Hapi, but can't figure our how. Specifically I am using the request module. According to the docs the reply object accepts a stream so I have tried: reply(request.get('https://google.com')); The throws an error. In the docs it says the stream object must be compatible with streams2, so then I tried: reply(streams2(request.get('https://google.com'))); Now that does not throw a server side error, but in the browser the request never

How do Express and hapi compare to each other?

冷暖自知 提交于 2019-12-29 10:04:57
问题 From web application design and development point of view, how do Express and Hapi compare to each other? For basic examples they seem similar, however I'm interested to learn more about key differences in overall application structure. For example, as far as I have learned, Hapi uses a different routing mechanism which does not take registration order into account, can do faster lookups, but is limited comparing to Express. Are there other important differences? There is also an article

Converting MSAL Access Token to Hapi JWT token

末鹿安然 提交于 2019-12-24 22:24:40
问题 We're trying to work out how to consume an MSAL access token from a front-end vue.js application on our hapi.js back-end. Following the documentation for Single Page Applications we are successfully adding the MSAL accessToken to our http requests as a Bearer token. This token can be seen on the back-end if we disable JWT on the API server. How do we validate the MSAL access token so that we can return a valid JWT token? (secondary question is what is the recommended auth strategy for the

Launch angular 4 from Hapi js

跟風遠走 提交于 2019-12-24 21:45:36
问题 I have back-end with hapi js and front-end with angular 4. I have 2 servers to launch my front-end and my back-end. I would like to launch my angular application from hapi js and I don't know how to do that. I found https://github.com/guillaume-chs/angular4-hapijs but it's not working. Do you have more examples? Thank you 回答1: I guess that hapi.js is the parent project and angular 4 is just the "view", so what you need to do is on GET / serve the static index.html file that is under dist

request.auth.session.set(user_info) not working HapiJS

▼魔方 西西 提交于 2019-12-24 13:33:07
问题 This is my strategy, which is defined on a server.register(). I'm basing my work off a tutorial and it is literally copied from it but it doesn't work. server.auth.strategy('standard', 'cookie', { password: 'somecrazycookiesecretthatcantbeguesseswouldgohere', // cookie secret cookie: 'app-cookie', // Cookie name isSecure: false, // required for non-https applications redirectTo: '/login', ttl: 24 * 60 * 60 * 1000 // Set session to 1 day }); server.auth.default({ strategy: 'standard', mode:

JavaScript Cookie absolutely refuses to be deleted

大憨熊 提交于 2019-12-24 10:53:58
问题 This is related to my other question, i'm asking a new question as i've narrowed down the problem and the original question was getting rather convoluted. In a nutshell, i have a cookie that refuses to be deleted! My server sets the cookie " session=abc; domain=example.com; path=/; " I want to edit this cookie client-side, so lets say i want to change abc to xyz then i run the following code document.cookie = "session=xyz; domain=example.com; path=/;" Now, when i inspect the cookies i

validating sub-params dependent on parent params with Joi and Hapi

放肆的年华 提交于 2019-12-24 09:36:24
问题 How can I implement validation for something like the following logic for query params: if (type is 'image') { subtype is Joi.string().valid('png', 'jpg') else if (type is 'publication') { subtype is Joi.string().valid('newspaper', 'book') to get either server/?type=image&subtype=png or server/?type=publication&subtype=book but not both image and publication at the same time? Update: I tried the following code but no luck type: Joi .string() .valid('image', 'publication', 'dataset') .optional

node-oracledb error when executing stored procedure NJS-012

喜欢而已 提交于 2019-12-24 08:07:07
问题 I'm running Node 8.9.4, Hapi 17.4, and Oracledb 2.2. When attempting to call a stored procedure, I get the error "NJS-012: encountered invalid bind data type in parameter 2". Nothing I've been able to do seems to fix the issue. The code that calls the procedure is: async function getSavedViews(req, h, server) { let connection = await server.app.db.getConnection(); let bindVars = { P_USER_NAME: req.payload.user_name, P_CONTENT_TYPE: req.payload.content_type, P_PROJECT_NUMBER: req.payload

Duplicate identifier error when referencing a node library using typescript

允我心安 提交于 2019-12-24 03:33:04
问题 I'm new to typescript and trying to start a hapi.js project but I'm getting an error when trying require('boom') in my code Duplicate identifier 'Boom' /// <reference path="../typings/tsd.d.ts" /> var config = require('../config'), User = require('../models/user'), Boom = require('boom'), joi = require('joi'); my tsd.json { "version": "v4", "repo": "borisyankov/DefinitelyTyped", "ref": "master", "path": "typings", "bundle": "typings/tsd.d.ts", "installed": { "node/node.d.ts": { "commit":

hapi.js - 404 route VS static files route

谁都会走 提交于 2019-12-22 03:23:04
问题 I'm trying to migrate my Express app to hapi.js, and I having trouble with my routes. I just want 2 GET : my index '/', and everything that is not '/' to redirect to '/'. Using Express I had this: // static files app.use(express.static(__dirname + '/public')); // index route app.get('/', function (req, res) { // whatever } // everything that is not / app.get('*', function(req, res) { res.redirect('/'); }); I have issues with hapi.js to get the same behaviour. My "static road" looks like this: