Skip to content
This repository

Any YML example of Mojito? #918

Closed
jianlin opened this Issue · 10 comments

4 participants

jianlin alberto chan Drew Folta Caridy Patino
jianlin

It is said that Mojito can use JSON or YML as the application.json (the config file), but I haven't seen YML examples around?

For example, how to convert:

[
    {
        "settings": [ "master" ],
        "specs": {
            "hello" : {
                "type" : "HelloWorldMojit"
            }
        }
    }
]

to a YML file?

Also, when we use

$ mojito create app Hello

can't we specify that we want YML files as default?


Details:

I used npm's yamljs to convert the file to:

-
  settings: [master]
  specs: { hello: { type: HelloWorldMojit } }

and it doesn't work. And I edited it to

-
  settings: [master]
  specs:
      hello:
          type:
              HelloWorldMojit

It won't work either. The server can start, but the error is:

error: (outputhandler.server): { [Error: Cannot expand instance [hello], 
       or instance.controller is undefined] code: 500 }

(the file routes.json is depending on hello being defined)

alberto chan
Collaborator

I think the config you want is

-
    settings: [ "master" ]
    specs:
        hello:
            type: "HelloWorldMojit"

Here is a more complete example of application and routes YAML config:

jianlin

It still gives me an error even if I use the code above verbatim...

Can I just use YAML for application.yml and use routes.json still?

Another thing that is strange is that, in the code above, isn't hello just a string, and type just a string, then why doesn't hello need to be in double quotes but HelloWorldMojit has to be?

jianlin

what is more is, if I

git clone https://github.com/imalberto/appyamlexample.git

and cd into it, and start a server using mojito start, it won't work if I go to http://localhost:8666/

So I tried again using

sudo npm install yaml -g

and started the server again, and it won't work.

This is all done on a Mac.

alberto chan
Collaborator

What is your mojito version installed ?

The app example works with mojito 0.4.9-2 (https://github.com/imalberto/appyamlexample/blob/master/package.json)

I am guessing you are using a different version.

after you clone the app, do a "npm install", and make sure you start the app with the local installed version.

jianlin

My mojito is 0.5.1 and was installed by sudo npm install mojito -g.

1) So you mean, cd into that folder after git clone, and do a npm install, and then use node_modules/mojito/bin/mojito start to start the server?

2) If I do (1), the website can be accessed... But another question is, then why 0.5.1 cannot handle the simple YAML file application.yaml for my own project? (it is a project pretty much the same as on http://developer.yahoo.com/cocktails/mojito/docs/getting_started/mojito_getting_started_tutorial.html up to the middle part of the page for "starting the server" -- without modifying anything else).

alberto chan
Collaborator

Can you please file a bug for this ?

Include your example app, and error messages you get. Thanks !

jianlin

You mean add an issue on GitHub? I thought that's what I did at the beginning of this post, including the error message.

So what I can do is just git push my project to GitHub, but it is pretty simple, just the sample app as on http://developer.yahoo.com/cocktails/mojito/docs/getting_started/mojito_getting_started_tutorial.html

I might add that the example works fine as long as it is application.json and not work as soon as it is application.yml or .yaml

Drew Folta
Collaborator

Hi jianlin,

Mojito 0.5.0 and 0.5.1 don't support yaml. We'll restore that functionality in 0.5.2 (specifically via pull request #916).

Drew

jianlin

yes, I just reintalled Mojito and it is 0.5.2 and it seems to solve the issue... so I asked the question on Friday or Saturday and it just happened to be solved on Monday? How lucky!

Caridy Patino
Owner

we are that fast @jianlin, heheheh!, closing this.

Caridy Patino caridy closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.