summaryrefslogtreecommitdiff
path: root/paths.js
diff options
context:
space:
mode:
authorGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-04-15 18:41:27 +0300
committerGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-04-15 18:41:27 +0300
commit3894db0824bbb0023bce8402f1c4f578504fb8ce (patch)
treed74e86ea41fb83ede379429e7b9bc3e4408f96ba /paths.js
parentb122279ece06a9381e805c6087f130b41616fe3d (diff)
downloadoseine-3894db0824bbb0023bce8402f1c4f578504fb8ce.tar.gz
oseine-3894db0824bbb0023bce8402f1c4f578504fb8ce.tar.bz2
oseine-3894db0824bbb0023bce8402f1c4f578504fb8ce.zip
refactoring routes; added weighted exact and partial match routines
Diffstat (limited to 'paths.js')
-rw-r--r--paths.js147
1 files changed, 0 insertions, 147 deletions
diff --git a/paths.js b/paths.js
deleted file mode 100644
index 6e5fbef..0000000
--- a/paths.js
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * defines routes
- * exports router
- */
-
-const Router = require('koa-router');
-const urler = require('./utils/url-util');
-
-const data = require('./pieces/prepare-streams');
-
-const bench = require('./benchmark/find.js');
-const matchStr = require('./benchmark/match-str.js');
-
-
-// Prefix all routes with: /items
-const router = new Router({
- // prefix: '/items'
-});
-
-
-
-/* simple route example
-
- let items = [
- { id: 100, iname: 'Quartz Analog Wrist Watch', price: 'US $4.99'},
- { id: 101, iname: 'Leather Peep Pump Heels', price: 'US $33.56'},
- { id: 102, iname: 'Apple iPod', price: 'US $219.99'},
- { id: 103, iname: 'Prince Phantom 97P Tennnis Racket', price: 'US $50.00'},
- ];
-
- // Routes
-
- router.get('/items', (ctx, next) => {
- ctx.body = items;
- next();
- });
-
- router.get('/items/:id', (ctx, next) => {
- let getCurrentItem = items.filter(function(item) {
- if (item.id == ctx.params.id) {
- return true;
- }
- });
- if (getCurrentItem.length) {
- ctx.body = getCurrentItem[0];
- } else {
- ctx.response.status = 404;
- ctx.body = 'Item Not Found';
- }
- next();
- });
-*/
-
-
-// NOTE: set timeout per route (how-to)
-// https://stackoverflow.com/questions/66634123/how-to-add-individual-timeout-value-per-specific-route-using-node-js
-
-
-// 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);
- const kb = require('./utils/kb-util.js');
- let words = kb.keyboardize(kb.clean(ctx.params.title)).split(' ');
- ctx.body = {
- params: ctx.params,
- results: words,
- nxt: next
- };
- next();
-});
-
-
-
-/** other routes
- * /////////////////////////////////////////////////////////////////////////////
- * + /suggest/<some search string>
- * + /prepare (products, keywords, linked-terms etc)
- * + /stats
- */
-
-
-
-// TEST routes
-////////////////////////////////////////////////////////////////////////////////
-
-router.get('/test', (ctx, next) => { // easy test route
- // test anything ...
- ctx.body = { params: urler.struct(ctx.request, ctx.url), ctx: ctx }
- next();
-});
-
-router.get('/test/do-data', (ctx, next) => { // easy test route
- // test anything ...
- // data.create(
- // 'products',
- // 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json'
- // );
- data.load_products(
- 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json'
- );
- ctx.body = { success: true, operation: 'create new data' };
- next();
-});
-
-// benchmark routes;
-// shall be removed from production
-////////////////////////////////////////////////////////////////////////////////
-
-/// router.get('/test/json', (ctx, next) => { // easy test route
-/// // test anything ...
-/// ctx.body = { t: + new Date(), p: products };
-/// next();
-/// });
-
-router.get('/bench/find', (ctx, next) => { // easy test route
- // test anything ...
- ctx.body = bench.compare();
- next();
-});
-
-router.get('/bench/match/:title', (ctx, next) => { // easy test route
- // test anything ... [ query = 'solokata' ]
- // ctx.body = bench.compare();
- ctx.body = matchStr.run(ctx.params.title);
- next();
-});
-
-
-// export routes
-
-module.exports = router;