diff options
Diffstat (limited to 'paths.js')
| -rw-r--r-- | paths.js | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -1,8 +1,10 @@ const Router = require('koa-router'); + const kb = require('./pieces/kb-util.js'); const data = require('./pieces/prepare-streams'); const products = require('./data/products.json'); const bench = require('./benchmark/find.js'); +const macthStr = require('./benchmark/match-str.js'); // Prefix all routes with: /items const router = new Router({ @@ -48,16 +50,29 @@ const router = new Router({ // Routes + +router.get('/', (ctx, next) => { + ctx.body = { + success: true, + title: 'oseine', + description: 'oseine search engine is not elastic', + message: 'where are you now?' + } + next(); +}) + router.get('/search', (ctx, next) => { ctx.body = []; next(); }); router.get('/search/:title', (ctx, next) => { + // console.log(ctx); let words = kb.keyboardize(kb.clean(ctx.params.title)).split(' '); ctx.body = { params: ctx.params, - results: words + results: words, + nxt: next }; next(); }); @@ -105,7 +120,14 @@ router.get('/test/json', (ctx, next) => { // easy test route router.get('/bench/fe', (ctx, next) => { // easy test route // test anything ... // ctx.body = bench.compare(); - ctx.body = bench.byFor(); + ctx.body = bench.compare(); + next(); +}); + +router.get('/bench/match', (ctx, next) => { // easy test route + // test anything ... + // ctx.body = bench.compare(); + ctx.body = macthStr.run(); next(); }); |
