summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-04-17 18:32:13 +0300
committerGeo Halkiadakis <gchalkiadakis@sklavenitis.co.gr>2024-04-17 18:32:13 +0300
commitd9364679a51ff80db8e5948ab089d749da36a6b2 (patch)
treef847a03a017be8857923aaaae9f8dcf7177b2ba9 /routes
parent6248d2cf7a2214ac32628bc58248694108b4d8bf (diff)
downloadoseine-master.tar.gz
oseine-master.tar.bz2
oseine-master.zip
dockerize the appHEADmasterdevelopment
Diffstat (limited to 'routes')
-rw-r--r--routes/dev.js103
-rw-r--r--routes/index.js26
-rw-r--r--routes/v1.js67
3 files changed, 0 insertions, 196 deletions
diff --git a/routes/dev.js b/routes/dev.js
deleted file mode 100644
index cd40822..0000000
--- a/routes/dev.js
+++ /dev/null
@@ -1,103 +0,0 @@
-/**
- * defines routes
- * exports router
- */
-
-const Router = require('koa-router');
-const urler = require('../utils/url-util.js');
-
-const data = require('../pieces/prepare.js');
-
-const bench = require('../benchmark/find.js');
-const matchStr = require('../benchmark/match-str.js');
-
-
-// Prefix all routes with: /items
-const router = new Router();
-
-
-
-// Routes
-
-/* 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'},
- ];
-
- 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
-
-
-// TEST routes
-////////////////////////////////////////////////////////////////////////////////
-
-router.get('/test', (ctx) => { // easy test route
- // test anything ...
- ctx.body = { params: urler.struct(ctx.request, ctx.url), ctx: ctx }
-});
-
-router.get('/test/do-data', (ctx) => { // 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' };
-});
-
-// 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) => { // easy test route
- // test anything ...
- ctx.body = bench.compare();
- // next();
-});
-
-router.get('/bench/match/:title', (ctx) => { // easy test route
- // test anything ... [ query = 'solokata' ]
- // ctx.body = bench.compare();
- ctx.body = matchStr.run(ctx.params.title);
- // next();
-});
-
-
-// export routes
-
-module.exports = router;
diff --git a/routes/index.js b/routes/index.js
deleted file mode 100644
index e3d6230..0000000
--- a/routes/index.js
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * routes (index)
- */
-const Router = require('koa-router');
-
-const router = new Router();
-
-// Require grouped routes
-
-let v1 = require('./v1.js');
-router.use(v1.routes());
-
-let dev_paths = require('./dev.js');
-router.use(dev_paths.routes());
-
-// define default route
-router.get('/', (ctx) => {
- ctx.body = {
- success: true,
- title: 'oseine',
- description: 'oseine search engine is not elastic',
- message: 'where are you now?'
- }
-})
-
-module.exports = router;
diff --git a/routes/v1.js b/routes/v1.js
deleted file mode 100644
index 9690973..0000000
--- a/routes/v1.js
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * api v1 routes
- */
-
-const Router = require('koa-router');
-const prepare = require('../pieces/prepare.js');
-
-
-// Prefix all routes with: /items
-const router = new Router({
- prefix: '/v1'
-});
-
-
-
-// Routes
-
-router.get('/prepare/:title', (ctx) => {
- let result = false;
- switch (ctx.params.title) {
- case 'products':
- result = prepare.load_products(
- 'https://storage.googleapis.com/pythia-files/uploads/json/emarket-products.json'
- );
- break;
-
- default:
- break;
-
- }
- return { success: result };
-})
-
-
-router.get('/search', (ctx) => {
- ctx.body = [];
-});
-
-router.get('/search/:title', (ctx) => {
- let result = [
- { id: 10, w: 'Ένα Προϊόν' },
- { id: 15, w: 'Άλλο Προϊόν' },
- { id: 20, w: 'Προϊόν 3' },
- { id: 25, w: 'Προϊόν 4' }
- ]
- // 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
- /// };
- ctx.body = result;
-});
-
-
-/** TODO: ?? other routes ??
- * /////////////////////////////////////////////////////////////////////////////
- * + /suggest/<some search string>
- * + /prepare (products, keywords, linked-terms etc)
- * + /stats
- */
-
-
-// export routes
-module.exports = router;