Git Product home page Git Product logo

his_node's People

Contributors

haithhawk avatar idantb101 avatar sophiavocado avatar

Watchers

 avatar  avatar  avatar

his_node's Issues

log of the port should be in listen

listen is an asynchronous function so you're logging, so it can take a callback, the right way would be to log from that callback once it executes

Redundant function in server.js

const router = require('./router');

var app = function (request, response) {
    router(request, response);
};

http.createServer(app).listen(port);

Is functionally the same as:

const router = require('./router');

http.createServer(router).listen(port)

Autocomplete from existing data

The project spec is to autocomplete to the front end from a large file of words. I'm glad that you went out of your comfort zone and used the request module to hit the wiki api, but that should have been in a different section of the app. For example after the autocomplete you could have hit search and been given a wiki result. The project spec says:

A large data file is required to search through - consider the best data structure for this (e.g. .txt or .json).

Currently that's not happening.

Auto Complete words

Apparently the auto complete words are always starting with 'O'

and it only shows the same 10 words: ๐Ÿ˜“

  • Obama
  • Obama, Fukui
  • Obama Doctrine
  • Obama (genus)
  • Obama Anak Menteng
  • Obama nungara
  • Obama logo
  • Obama Domain
  • Obamadon
  • Obama Zombies

Great work!

Looks like all the issues your project had have been raised. I am impressed by the amount of work you guys have put into the project. Keep it up.

Host the site on Heroku

At the moment there's no way to run the site without cloning the site and running locally. It's on the the learning outcomes for the week so I'd strongly encourage sorting it within the time for responding to code review issues.

Clear element on new search results

Something like the function below can be used to clear old results when a new autocomplete comes in:

function removeChildren(element) {
  while (element.hasChildNodes()) {
    element.removeChild(element.lastChild);
  }
}

Should have a start script as well as devStart

It's common practice to have both a start script and some sort of dev script in your package.json. You'll need one to host on Heroku (#37) and also it's generally the first thing people try when they clone a node project -- devStart should be for developing, not running the project.

Love how small and simple the router file is!

The only thing I'd change is that your accessing the object multiple times. It would be better to do this once, and within the function, and you could also add destructuring for nicer naming. Something like:

const {staticFiles, model, html, notFound} = require('./handlers');

module.exports = function(request, response) {

    const route = {
        '/' : html,
        '/style.css' : staticFiles,
        '/logic.js'  : staticFiles,
        '/model.js' : model,
    }[request.url]


    if (route) {
       route(request, response);
    } else {
       notFound(request, response);
    }
}

comments and console.logs

I think you should remove all the extra codes (comments and console.logs)

i.e.
index.html -- line 15
<!-- <img class="groupePhoto" src="" alt="groupe photo"> -->

data.js -- line 1 - 5

// <script src="http://en.wikipedia.org/w/api.php?action=opensearch&limit=10&format=json&callback=getData&search="></script>
//
//
// <input type="text" id="searchbox">
// <div id="output"></div>
//this part will go to html file later

html and staticFile code repeats

The html function could be massively simplified by changing staticFile to take a url as a third argument and then calling it within html, something like this:

handlers.html = function (request, response) {
  handlers.staticFiles(request, response, '/index.html');
}

handlers.staticFiles = function (request, response, url) {
    const extension = url.split('.')[1];
    const extensionType = {
        'html': 'text/html',
        'css': 'text/css',
        'js': 'javascript/application'
    }[extension];

    fs.readFile(__dirname + '/../public/'+ url,
    function (error, file) {
        if (error) {
            console.log(request.url);
            console.log('oh there is an error', error);
            return;
        }
        response.writeHead(200, { 'Content-Type': extensionType });
        response.end(file);
    });
}

vs

handlers.html = function (request, response) {
    const endpoint = request.url;
    if (endpoint === '/') {
        fs.readFile(__dirname + '/../public/index.html',
            function (error, file) {
                if (error) {
                    console.log(request.url);
                    console.log('oh there is an error', error);
                    return;
                }
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.end(file);
            });
     }
}

handlers.html = function (request, response) {
    const endpoint = request.url;
    if (endpoint === '/') {
        fs.readFile(__dirname + '/../public/index.html',
            function (error, file) {
                if (error) {
                    console.log(request.url);
                    console.log('oh there is an error', error);
                    return;
                }
                response.writeHead(200, { 'Content-Type': 'text/html' });
                response.end(file);
            });
     }
}

Replace the for loop

In model.js you have a for loop that could be replaced with something like this if you wanted (die for loops die):

const result = Array.from({length:10}, (el, index) => {
  return {
    title: parsedData[1][index],
    link: parsedData[3][index]
  };
});

I usually only recommend for loops when break is necessary.

We love good git flow!

Issues
Awesome, lots of issues with descriptions. I would say a lot of the issues are very small and some could be joined together.

Commits
I โค๏ธ seeing almost all of your commits linked to issues. They mostly all have descriptive messages so I know what you did which is great ๐Ÿฅ‡.

Pull Requests
You guys are linking your pull requests to issues ๐Ÿ‘. Just a minor point on this, you can't link to issues in the title of the PR so in future you only need it in the description rather than the title. PRs should be reviewed by your team members before you merge. You should assign your team as reviewers where they can approve โœ… , request changes โŒ or just ask questions โ“ about specific parts of the code they don't understand. The final reviewer should merge the PR. I understand in a small team like this it may seem like a waste of time but it is a good way to ensure the whole team understands the code.

Contributions
It would be great to see a more equal spread of contributions between team members on the graph ๐Ÿ“ˆ . Keep swapping who is typing and the laptop you are working on throughout the project โญ.

Keep up the awesome git flow โœจ

Submit

Shouldn't there be a submit button to execute the search input? ๐Ÿค”

Responsive

The webpage dont seem to be responsive ๐Ÿ˜“

We also love good READMEs yay

The readme looks great ๐Ÿ’ฏ A few minor notes though:

In the installation instructions you have some markdown within backticks ## like this. I'm guessing that was just a mistake.

There's also this line in the readme:

https://github.com/FACN3/HIS_node (needs to be changed)

Which should probably just be removed. You explain how to use the project below including cloning the repo so there isn't really a need for this.

Creating server files skeleton

creating skeleton files for the server side including :
.gitignore
handlers.js
model.js
package.json
router.js
server.js

.vscode should be .gitignored

It's a vscode specific file that isn't necessary to run the project so should probably be in the .gitignore. The master branch should only contain files necessary to run the project.

Create ReadMe.md file

creating a ReadMe.md file that will include:
how to clone, install, run.
explanation about the project.
the planing process.
and other nice things.

CSS

I think you should give some colors to the webpage
make it more "lovely" ๐Ÿ˜

Only one handler handles errors

In handlers.model you handle file read errors:

        if (error){
            response.writeHead(404, { 'Content-Type': 'text/html' });
            response.end('error geting data from wiki', error);   
        }
        response.writeHead(200, { 'Content-Type': 'application/json' });
        response.end(JSON.stringify(purpose));

But none of your other handlers do this. Every branch a request can take should have a response.end so the request never hangs.

README assets should be stored in issues

You have an assets folder with images that are readme specific. These should be hosted in issues rather than the repository to to stop users who want to clone your project from having to download them.

Happy to show you the process for this ๐Ÿ‘

serverTest.js & clientTest.js

i think the test aren't really testing anything? ๐Ÿ˜…

by my understanding it only checks if the tape is working?

but what about the server/client functionality ๐Ÿ˜“

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.