hapijs

Hapi Lab how to test all the required fields

三世轮回 提交于 2021-02-11 15:20:59
问题 Is there a way to check all the required fields without the need of a test each field. validation rules const Confirmation = Joi.any().valid(Joi.ref('password')).required().options({ language: { any: { allowOnly: 'must match password' } } }); const Email = Joi.string().email(); const Firstname = Joi.string().regex(/^[a-zA-Z\']+$/).min(2).max(30); const Lastname = Joi.string().regex(/^[a-zA-Z\']+$/).min(2).max(30); const Password = Joi.string().min(3).max(30); const Username = Joi.string()

Hapi showing undefined variable inside handler

浪尽此生 提交于 2021-02-11 10:50:03
问题 I'm using Hapi.js for a project and a config variable that I'm passing to my handler is coming up as undefined when I call my route. What am I doing wrong? server.js var Hapi = require('hapi'); var server = new Hapi.Server('0.0.0.0', 8080); // passing this all the way to the handler var config = {'number': 1}; var routes = require('./routes')(config); server.route(routes); server.start(); routes.js var Home = require('../controllers/home'); module.exports = function(config) { var home = new

Hapi showing undefined variable inside handler

淺唱寂寞╮ 提交于 2021-02-11 10:48:18
问题 I'm using Hapi.js for a project and a config variable that I'm passing to my handler is coming up as undefined when I call my route. What am I doing wrong? server.js var Hapi = require('hapi'); var server = new Hapi.Server('0.0.0.0', 8080); // passing this all the way to the handler var config = {'number': 1}; var routes = require('./routes')(config); server.route(routes); server.start(); routes.js var Home = require('../controllers/home'); module.exports = function(config) { var home = new

Hapi showing undefined variable inside handler

ε祈祈猫儿з 提交于 2021-02-11 10:46:31
问题 I'm using Hapi.js for a project and a config variable that I'm passing to my handler is coming up as undefined when I call my route. What am I doing wrong? server.js var Hapi = require('hapi'); var server = new Hapi.Server('0.0.0.0', 8080); // passing this all the way to the handler var config = {'number': 1}; var routes = require('./routes')(config); server.route(routes); server.start(); routes.js var Home = require('../controllers/home'); module.exports = function(config) { var home = new

Is it possible to use supertest with hapi?

こ雲淡風輕ζ 提交于 2021-02-08 15:48:13
问题 I'm using hapi, not express. Should supertest still work? If so, is there a quick way to change my code to get it to run? My test looks like this, based on the documentation: import tape = require('tape'); const supertest = require('supertest'); const app = require('../../../../src/app'); tape('creates new user in database', function (assert) { supertest(app) .get('/ekapi/v1/signup') .expect(200) ...... }); but it gives me this error: dist/server/app/node_modules/supertest/lib/test.js:55 var

Integrate all Angular2 and Hapi routes

元气小坏坏 提交于 2021-02-08 07:41:48
问题 Situation I'm developing a web application that uses Hapi server for REST calls and multi-page Angular2 website client-side. Hapi serves all Angular2 files to the client with: let serverDirPath = path.resolve(__dirname); server.route({ method: "GET", path: "/{param*}", config: { auth: false, handler: { directory: { path: path.join(serverDirPath, "../client"), index: true } } } }); Calling the server root successfully returns "index.html", and after that the Angular2 website works perfectly!

Integrate all Angular2 and Hapi routes

不想你离开。 提交于 2021-02-08 07:39:44
问题 Situation I'm developing a web application that uses Hapi server for REST calls and multi-page Angular2 website client-side. Hapi serves all Angular2 files to the client with: let serverDirPath = path.resolve(__dirname); server.route({ method: "GET", path: "/{param*}", config: { auth: false, handler: { directory: { path: path.join(serverDirPath, "../client"), index: true } } } }); Calling the server root successfully returns "index.html", and after that the Angular2 website works perfectly!

Node Docker Runs, but can't see the application

青春壹個敷衍的年華 提交于 2021-02-04 19:28:06
问题 It appears that my Hapi app is running in a Docker container, but I can't hit it in the browser. I thought that docker run -d -p 8080:3000 would have done it, but I guess not. I'm running boot to docker and neither http://localhost:8080/hello nor http://192.168.99.100:8080/hello is working. I've tried tons of variations on this as well. This is what I see when I run docker inspect <container id> : Server running at: http://localhost:8080 Here's my Hapi.js server: 'use strict'; const Hapi =

hapijs joi validation , validate greater than from sum of other property

爱⌒轻易说出口 提交于 2021-01-28 20:26:50
问题 I want to validate a field 'familymemberCount' it should be greater than equal to other fields. I tried below code, but this not allow to use ' + ' operator with Ref. How do we validate with sum of other values ? export const familyMemberRulesSchema = Joi.object({ relationMembers: Joi.object({ motherCount: Joi.number().integer().min(0).max(5).optional(), fatherCount: Joi.number().integer().min(0).max(5).optional(), childrenCount: Joi.number().integer().min(0).max(5).optional() }),

AWS Cognito Mock

一曲冷凌霜 提交于 2020-12-08 06:10:37
问题 I want to write BDD tests for my nodejs based API which uses AWS cognito as user authentication service, but I don't want to hit the real cognito service every time my build runs. Is there an easy and elegant way to mock Cognito calls. Used frameworks : Nodejs (Hapi.js) aws-sdk for nodejs 回答1: We have created an aws-sdk-mock npm module which mocks out all the AWS SDK services and methods. https://github.com/dwyl/aws-sdk-mock It's really easy to use. Just call AWS.mock with the service, method