Skip to content

Commit

Permalink
Merge pull request #2 from terry0022/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
terry0022 authored May 21, 2021
2 parents 0a36459 + 97cf434 commit c9d40ce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
File renamed without changes.
19 changes: 12 additions & 7 deletions src/routes/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
const { Router } = require('express');
const router = Router();
let jsonNenek = require('../public/neneks.json');
const dictionary = require('../words.js');
let jsonNenek = require('../public/dictionary.json');

// Get all diccionary
router.get("/dictionary", (req, res) => {
router.get("/", (req, res) => {
res.render("dictionary", {
title: 'Diccionario',
words: jsonNenek
})
});

router.get("/dictionary", (req, res) => {
res.send(dictionary.allDictionary())
});

router.get("/es/:query", (req, res) => {
var index = searchname(jsonNenek, req.params.query, "pal_esp");
if(index == -1) {
Expand Down Expand Up @@ -41,12 +46,12 @@ var searchname = function(json, query, index){
for(var i = 0; i < json.length; i++) {
if (json[i][index].indexOf(query)>-1){
const data = {
_id: json[i]['_id'],
num_pal: json[i]['num_pal'],
id: json[i]['_id'],
number_word: json[i]['num_pal'],
query: query,
pal_tenek: json[i]['pal_tenek'],
pal_esp: json[i]['pal_esp'],
significado: json[i]['significado']
tenek_word: json[i]['pal_tenek'],
spanish_word: json[i]['pal_esp'],
description: json[i]['significado']
}
array.push(data)
}
Expand Down
7 changes: 7 additions & 0 deletions src/words.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let dictionary = require('./public/dictionary.json');

module.exports = { allDictionary }

function allDictionary() {
return dictionary;
}

0 comments on commit c9d40ce

Please sign in to comment.