Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
///
import { Router } from '@vertx/web';
import { home } from './routes';
const app = Router.router(vertx);
console.log(typeof home);
app.route('/').handler(home);
vertx.createHttpServer()
.requestHandler(app)
.listen(8080);
"use strict";
///
Object.defineProperty(exports, "__esModule", { value: true });
const web_1 = require("@vertx/web");
const routes_1 = require("./routes");
const app = web_1.Router.router(vertx);
console.log(typeof routes_1.home);
app.route('/').handler(routes_1.home);
vertx.createHttpServer()
.requestHandler(app)
.listen(8080);
//# sourceMappingURL=index.js.map
// npm install
// docker build -t postgres-tbf postgres
// docker run --rm -it -p 5432:5432 --name codeone-postgres postgres-tbf
// npm start
const util = require('util');
import {Router} from '@vertx/web';
import {PgClient, Tuple} from '@reactiverse/reactive-pg-client';
import {PgPoolOptions} from '@reactiverse/reactive-pg-client/options';
const SELECT_WORLD = "SELECT id, randomnumber from WORLD where id=$1";
const app = Router.router(vertx);
let client = PgClient.pool(
vertx,
new PgPoolOptions()
.setUser('benchmarkdbuser')
.setPassword('benchmarkdbpass')
.setDatabase('hello_world'));
app.get('/').handler(
ctx => {
client.preparedQuery(SELECT_WORLD, Tuple.of(1), res => {
if (res.succeeded()) {
let resultSet = res.result().iterator();
if (!resultSet.hasNext()) {
// no result found
///
// @ts-check
import {Router, StaticHandler} from '@vertx/web';
const DroolsHelper = Java.type('drools.DroolsHelper');
const posts = require('./shared/posts');
import React from 'react';
import {renderToString} from 'react-dom/server';
import {match, RouterContext} from 'react-router';
import routes from './shared/components/routes';
// route all request based on the request path
const app = Router.router(vertx);
// get a drools engine
const engine = DroolsHelper.load(vertx.fileSystem().readFileBlocking("drools/rules.drl"));
app.get('/api/post').handler((ctx) => {
ctx.response()
.putHeader("content-type", "application/json")
.end(JSON.stringify(posts));
});
app.get('/api/post/:id').handler((ctx) => {
const id = parseInt(ctx.request().getParam('id'));
const post = posts.filter(p => p.id == id);
if (post) {
///
// @ts-check
import {Router} from '@vertx/web';
import {PgClient, Tuple} from '@reactiverse/reactive-pg-client';
import {PgPoolOptions} from '@reactiverse/reactive-pg-client/options';
import {HandlebarsTemplateEngine} from '@vertx/web-templ-handlebars'
const util = require('./util');
const SERVER = 'vertx.js';
const app = Router.router(vertx);
const template = HandlebarsTemplateEngine.create(vertx);
let date = new Date().toUTCString();
vertx.setPeriodic(1000, t => date = new Date().toUTCString());
/*
* This test exercises the framework fundamentals including keep-alive support, request routing, request header
* parsing, object instantiation, JSON serialization, response header generation, and request count throughput.
*/
app.get("/json").handler(ctx => {
ctx.response()
.putHeader("Server", SERVER)
.putHeader("Date", date)
.putHeader("Content-Type", "application/json")
.end(JSON.stringify({message: 'Hello, World!'}));
});
///
// @ts-check
import { Router } from '@vertx/web';
import { PgPool } from '@vertx/pg-client';
import { PoolOptions } from '@vertx/sql-client/options';
import { RockerTemplateEngine } from '@vertx/web-templ-rocker'
import { PgConnectOptions } from '@vertx/pg-client/options';
import { Tuple } from '@vertx/sql-client';
const util = require('./util');
const SERVER = 'vertx.js';
const app = Router.router(vertx);
const template = RockerTemplateEngine.create();
let date = new Date().toUTCString();
vertx.setPeriodic(1000, t => date = new Date().toUTCString());
/*
* This test exercises the framework fundamentals including keep-alive support, request routing, request header
* parsing, object instantiation, JSON serialization, response header generation, and request count throughput.
*/
app.get("/json").handler(ctx => {
ctx.response()
.putHeader("Server", SERVER)
.putHeader("Date", date)
.putHeader("Content-Type", "application/json")
.end(JSON.stringify({ message: 'Hello, World!' }));
});
<title>Universal Blog</title>
<div id="app">${appHtml}</div>
`);
} else {
ctx.next();
}
});
});
app.get().handler(StaticHandler.create());
vertx
// create a HTTP server
.createHttpServer()
// on each request pass it to our APP
.requestHandler(function (req) {
app.accept(req);
})
// listen on port 8080
.listen(8080);