Giter VIP home page Giter VIP logo

makemehapi's Introduction

Make Me Hapi

NPM

Learn all about hapi through a series of self-guided challenges.

makemehapi

Getting Started

  1. Install makemehapi by running npm install -g makemehapi
  2. Run makemehapi

makemehapi will run you through a series of challenges ranging from a basic "hello world" server then move on to more advanced exercises dealing with rendering views, handling uploads, and managing cookies.

Getting Help

Run into a problem or want to discuss the exercises? Open an issue on this repository!

makemehapi's People

Contributors

adriantoine avatar akihito-takeuchi avatar arb avatar austinmcorso avatar ccarruitero avatar chetandhembre avatar davidspiess avatar dependabot-preview[bot] avatar dylancwood avatar eunsucking avatar fiveisprime avatar geek avatar jenymzo avatar kohei-takata avatar linclark avatar lloydbenson avatar manonthemat avatar musgravejw avatar nelsonic avatar nkamc avatar nvcexploder avatar oobert avatar paulgrock avatar rodrigo-medeiros avatar tdd avatar thegoleffect avatar tmpvar avatar tsantef avatar yereby avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

makemehapi's Issues

Validation exercises

I just installed makemehapi earlier this evening using npm and the validation exercise doesn't show up at all. Has anyone run into this issue? I'm thinking maybe it's something to do with npm not having the latest updates to the repo? I'm a newbie so I could be completely mistaken.

Instructions for Validation exercise confusing. :-(

Hi Ben/Lin,

While helping a student through the makemehapi validation exercise 9,
The problem https://github.com/hapijs/makemehapi/blob/master/exercises/validation/problem.md hint suggests:

var routeConfig = {
    path: '/a/path/{with}/{parameters}',
    method: 'GET',
    handler: myHandler,
    validate: {
        params: {
            with: Joi.string().required(),
            parameters: Joi.string().required()
        }
    }
}

but the https://github.com/hapijs/makemehapi/blob/master/exercises/validation/solution/solution.js wraps the handler & validation in a config object:

server.route({
    method: 'GET',
    path: '/chickens/{breed}',
    config: {
        handler: function (request, reply) {
            reply('You asked for the chicken ' + request.params.breed);
        },
        validate: {
            params: {
                breed: Joi.string().required()
            }
        }
    }
});

_Confusing_ to students.
Can I tidy it up an submit a PR?

Update 'engines' values

It looks like the expected type for the 'engines' property of the server options has changed. I am now getting the error message "Error: Invalid view options "handlebars" value must be an object".

When you npm update, this change affects the views and helping exercises.

plugins

i.e. writing two plugins, exposing something in one, using it in the other?

handling and directories exercises

Motivation

The handling ex. has the html formatted with 4 space indentation and the directories ex. has the html formatted with 2. It's frustrating when during verification you fail because the indentation is different.

Solution

Have the spacing in verified html files conform to either 2 space indentation or 4 space indentation.

Instructions on Proxies exercise confusing.

Hi Ben/Lin,

While going through the Makemehapi proxy exercise the student I was helping was stuck because the instructions suggest one port when the solution is another.

The Problem: https://github.com/hapijs/makemehapi/blob/master/exercises/proxies/problem.md
gives the hint code:

handler: {
    proxy: {
        host: '127.0.0.1',
        port: 8080
    }
}

But the solution https://github.com/hapijs/makemehapi/blob/master/exercises/proxies/solution/solution.js
is actually:

handler: {
    proxy: {
        host: '127.0.0.1',
        port: 65535
    }
}

This was confusing/frustrating to the student... :-(
Can I change it and submit a PR?

Progressive development

After running through the steps in makemehapi last night, I thought it might be nice if the routes for each step were prefixed by the step number or in some other way distinct. That way, you can keep adding routes to the same file and building up the app along the way. If the routes were distinct each step would still run and verify.

hapi requires stream2 streams, rot13-stream is a stream stream

Debug: internal, implementation, error
    TypeError: Cannot read property 'objectMode' of undefined
    at internals.Response._streamify (/project/node_modules/hapi/lib/response.js:450:34)
    at internals.Response._marshal (/project/node_modules/hapi/lib/response.js:433:21)
    at /project/node_modules/hapi/lib/transmit.js:119:18
    at /project/node_modules/hapi/lib/transmit.js:529:20
    at Object.exports.parallel (/project/node_modules/hapi/node_modules/items/lib/index.js:47:9)
    at Object.internals.state (/project/node_modules/hapi/lib/transmit.js:498:11)
    at Object.internals.marshal (/project/node_modules/hapi/lib/transmit.js:96:15)
    at Object.exports.send (/project/node_modules/hapi/lib/transmit.js:27:15)
    at /project/node_modules/hapi/lib/request.js:367:18
    at /project/node_modules/hapi/node_modules/hoek/lib/index.js:781:22

this error occurs when you try to use an old stream with hapi8 (related to #99). rot13-stream is a very old implementation. https://github.com/ajcrites/rot13-transform works better.

cookies

managing basic, non-yar* sessions

  • unless extra dependency okay

Running/verifying solutions errors out with ECONNREFUSED

I'm having problems when trying to run or verify solutions:

⚡ makemehapi run exercises/routes/solution/solution.js 
✗ Error connecting to http://localhost:23478: ECONNREFUSED

Error: connect ECONNREFUSED
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)

I have no problems running solutions with node.

Details follow.

/usr/local/lib/node_modules/makemehapi:master⚡ node -v
v0.10.23
/usr/local/lib/node_modules/makemehapi:master⚡ ps aux | grep node
joyrexus        34430   0.0  0.0  2423368    188 s001  R+   11:52PM   0:00.00 grep node
joyrexus        34419   0.0  1.4  3028248  28472 s001  S    11:52PM   0:00.74 /usr/local/Cellar/node/0.10.23/bin/node exercises/hello_hapi/solution/solution.js 29844
/usr/local/lib/node_modules/makemehapi:master⚡ node -v
v0.10.23
/usr/local/lib/node_modules/makemehapi:master⚡ makemehapi version
[email protected]
/usr/local/lib/node_modules/makemehapi:master⚡ kill -9 34419
/usr/local/lib/node_modules/makemehapi:master⚡ ps aux | grep node
joyrexus        34455   0.0  0.0  2423368    260 s001  R+   11:54PM   0:00.00 grep node
/usr/local/lib/node_modules/makemehapi:master⚡ makemehapi run exercises/hello_hapi/solution/solution.js 
✗ Error connecting to http://localhost:30885: ECONNREFUSED

Error: connect ECONNREFUSED
    at errnoException (net.js:901:11)
    at Object.afterConnect [as oncomplete] (net.js:892:19)
/usr/local/lib/node_modules/makemehapi:master⚡ ps aux | grep node
joyrexus        34467   0.0  0.0  2423368    304 s001  R+   11:54PM   0:00.00 grep node
joyrexus        34461   0.0  1.4  3029296  28548 s001  S    11:54PM   0:00.76 /usr/local/Cellar/node/0.10.23/bin/node exercises/hello_hapi/solution/solution.js 30885

Any suggestions would be greatly appreciated.

just a question

for the last exercise (#8) i have to install rot13-stream? i don't understand that hint. I just want to learn good because a get lose in that part.

Views solution not passing

When running the example solution to views I get this error

/Users/matthewmckenna/Documents/strenode/mehapi/node_modules/hapi/node_modules/joi/lib/errors.js:136
var annotated = JSON.stringify(obj, null, 2);
                     ^
TypeError: Converting circular structure to JSON
    at Object.stringify (native)
    at Error.internals.annotate (/Users/matthewmckenna/Documents/strenode/mehapi/node_modules/hapi/node_modules/joi/lib/errors.js:136:26)
at Object.exports.assert (/Users/matthewmckenna/Documents/strenode/mehapi/node_modules/hapi/lib/schema.js:15:104)
at new module.exports.internals.Server (/Users/matthewmckenna/Documents/strenode/mehapi/node_modules/hapi/lib/server.js:79:12)
at Object.exports.createServer (/Users/matthewmckenna/Documents/strenode/mehapi/node_modules/hapi/lib/index.js:14:12)
at Object.<anonymous> (/Users/matthewmckenna/Documents/strenode/mehapi/cheat.js:13:19)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)

I also get the same error when just trying to start the server using port 8080 not running it with makemehapi.

Using node 0.10.29

HTTP UPPERCASER

I can parse the POST body and have it print to the console just fine, but when I comment out the console.log line and comment in the response.end line it only works for the first request, then the rest of tests come back empty (not even as "" - see results after code)

Here's my code:

var http = require('http');

var server = http.createServer(function callback (request, response)
{
  request.on('data', function (chunk)
  {
    chunk = chunk.toString().toUpperCase();
    //console.log(chunk);
    response.end(chunk);
  });
});

server.listen(process.argv[2]);

Here are my results:

             ACTUAL                                  EXPECTED

────────────────────────────────────────────────────────────────────────────────

"NOT MY BOWL OF RICE" == "NOT MY BOWL OF RICE"
"" != "BUSH TELLY"
!= "MOKKIES"
!= "CHUNDER"
!= "DILL"
!= "DOB"
!= "BLUDGER"
!= "JUG"
!= "JACKAROO"
!= "DIGGER"
!= ""

────────────────────────────────────────────────────────────────────────────────

✗ Submission results match expected

Node process stays open in the background

I was just checking the open system processes and found quite a few "makemehapi" processes were still running. Seems like some process doesn't shut down properly?!

Test for simple strings, not HTML

Because we're using the workshopper functionality to test output, learners can have a solution that is conceptually correct but still fail. For example, the indentation might be different or they might not have new lines where the solution file expects them.

Instead, we can just set up the exercises to use simple strings, like the first two exercises do.

Update to hapi 6.x.x?

Currently, if you run npm install or npm update in the submission directory, it will download 6.0.0. However, package.json is set to 5.x.x. This causes problems due to #45.

I'm guessing that we should up package.json to 6.0.0.

Hello Hapi, not

NodeSchool and makemehapi are cool, but the hinting mechanism needs to evolve if this is expected to be used at home for newbs. I asked about the following in #Hapi but no wanted wanted to deal with me at the time, which is completely fine. Problem with NodeSchool and makemehapi is they're made by leading industry experts, but this can be a bad perspective to create a app for a potential complete noob alone at home. That's just my 2cents, now the issue:

I'm following everything to the tee and tried a handful of variations for the Hello Hapi course but I am pro at getting the following error:

stream.js:94
      throw er; // Unhandled stream error in pipe.

I created a repo for this which contains the source producing the error here:
mikeumus/hellohapi#1

Helping verification fails

I forgot to run verify on the helping exercise. It currently fails because the solution server returns a 500 error.

It turns out that the server created in solution.js is looking for the helpersPath directory in the makemehapi directory tree, not in the directory that the user is running verify from. I would expect this to work in the same way as the templates path but it doesn't seem to.

Handling seems buggy

1.    ACTUAL:  "<html><head><title>Hello Handling</title></head><body>Hello Handling</body></html>"
1.  EXPECTED:  "<html>"

2.    ACTUAL:  ""
2.  EXPECTED:  "    <head><title>Hello Handling</title></head>"

3.    ACTUAL:  
3.  EXPECTED:  "        Hello Handling"

4.    ACTUAL:  
4.  EXPECTED:  "    </body>"

5.    ACTUAL:  
5.  EXPECTED:  "</html>"

6.    ACTUAL:  
6.  EXPECTED:  ""

There is no opening body tag and the html should optionally have a replaced whitespace as valid answer.
(The html is minify, because I use jade as template engine. But still my html looks valid to me.)

I use the latest makemehapi

Cannot select exercises in menu

I believe this issue is with workshopper and I have added a PR there (workshopper/workshopper#53) which fixes it, but I wanted to note the issue here too in case anyone runs into it.

When I try to select any of the menu options, I get the following error:

/usr/local/lib/node_modules/makemehapi/node_modules/workshopper/menu.js:63
    if (opts.extras.indexOf(name.toLowerCase()) != -1)
                    ^
TypeError: Cannot call method 'indexOf' of undefined

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.