Add server route validation test file.

This commit is contained in:
Rafael S. Fijalkowski
2018-01-03 18:08:50 -03:00
committed by Justin Simms
parent ab78281950
commit b7757327fd
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
// from https://hapijs.com/tutorials/validation?lang=en_US
import { ServerRouteConfig, Request, ResponseToolkit, Server, ServerOptions, ServerRoute } from "hapi";
import * as Joi from "joi";
const options: ServerOptions = {
port: 8000,
};
const configObject: ServerRouteConfig = {
validate: {
params: {
name: Joi.string().min(3).max(10)
}
}
}
const serverRoute: ServerRoute = {
path: '/',
method: 'GET',
handler: (request: Request, h: ResponseToolkit) => {
return 'ok: ' + request.path;
},
config: configObject
};
const server = new Server(options);
server.route(serverRoute);
server.start();
console.log('Server started at: ' + server.info.uri);

View File

@@ -39,6 +39,7 @@
"test/route/handler.ts",
"test/route/route-options.ts",
"test/route/route-options-pre.ts",
"test/route/validation.ts",
"test/server/server-app.ts",
"test/server/server-auth-api.ts",
"test/server/server-auth-default.ts",