ognjengt / build-express-api

A Command line interface for instantly building an express rest api
MIT License
48 stars 9 forks source link

Directly using a .json file to create the files #1

Closed FrancescoSaverioZuppichini closed 6 years ago

FrancescoSaverioZuppichini commented 6 years ago

Hello there! Amazing work!

Would be nice to add a way to pass a .json file with a list of configurations such as:

{
models: [....],
controllers: [....]
}

In order to even quicker define the application structure?

Cheers,

Francesco Saverio

ognjengt commented 6 years ago

Hello Francesco, glad you like the module! This idea is very good, I will look into implementing it. So, for example, when you create beaConfig.json, with the paths such as { controllers: "./folder1/folder2/controllers" }

and run the init function, the CLI would create folder1/folder2/controllers.

Is that what you are aiming at, or am I missing something?

FrancescoSaverioZuppichini commented 6 years ago

Assuming I want to create n controllers and m models, in order to do so I need to call the command like n + m times. Maybe, I could create a .json config files, where I defined each controller and model and then call the command line in order to automatically create all the files.

FrancescoSaverioZuppichini commented 6 years ago

For example:

{
    "controllers": {
        "user": {
            "getUsers": "GET"
            ...
        },
        "auth": {
            "getToken": "GET"
            ...
        },
        "post": {
            "getPosts": "GET"
            ...
        }

    },
    "models": {
        "User": {name: String},
        "Post": {title: String}
    }
}

In order to create three controllers,user, auth, and posts, and two models, User and Post

ognjengt commented 6 years ago

Oh, I understand now. Yes, I think this is a good suggestion, I will start working on it!

Thank you for your idea, Francesco, I will notify you when I update the module, with this functionality.

FrancescoSaverioZuppichini commented 6 years ago

It should be easy, in the end, you just need to parse the .json file and call the functions that you have already implemented. Unfortunately, I am pretty busy studying with my finals so I won’t able to help but I promise you I will also write a short article on medium as soon as this new functionality is implemented since I was looking for a tool like this but I could not find anything. I was also thinking to implement it on my own but you beat me ;)

ognjengt commented 6 years ago

Please send me the article when you write it, I would love to read it. Also is it ok if I add to the changelog, that you suggested this improvement?

FrancescoSaverioZuppichini commented 6 years ago

Yes of course. Thank you

ognjengt commented 6 years ago

Francesco, I implemented the feature and added that you suggested it to the Changelog. Again thank you for your suggestion. I am now closing this issue. :)