Yeoman sub generators for MEAN application? - angularjs

I've been playing with Mean.IO (http://mean.io/), and wondered if there was a Yeoman generator (sub-generator?) that I could use to auto-generate code for an "entity" across the entire stack. For example, in the mean.io project there is an "Article" example that contains 7 components related to "Articles" (Model, Controller, Node Routes, Angular Routes/Service/Controller/Views). Is there a generator that will create this "component stack" for a custom entity?
eg, something like:
yo meangenerator:entity 'MyEntity'
would then create 7 different files that tie 'MyEntity' into an existing MEAN application.

Couldn't really find anything that worked how i wanted, so I wrote my own. My first Yeoman generator, as well as first real interaction with github and https://npmjs.org/. Fun!
GitHub:
https://github.com/MartyIce/generator-meancrud
NPM:
https://npmjs.org/package/generator-meancrud

Actually i think they have something similar, like:
$ mean package ThingIWantToModel
Don't know if they created this feature after you asked.
I wonder if we can generate singular controllers, models, and anything else inside this package.

Mean.js (another project that is similar to mean.io) has a great module generator, as does the angular-generator-fullstack project.
I think mean.js is the best, though, as it comes out-of-box with everything you need to actually get started building your application, including user logins, registration, reset password, change password, and a user management interface. Basically, batteries are included and you are ready to get building!

Related

2SXC/DNN - Delete ADAM Files in Entity

We're designing a system for a client where they are allowing authenticated users to upload images. We've created an API to upload the files but the client only wants the latest file and delete all previous ones so that there would only ever be one.
We've looked through the docs and can't come across a way for ADAM to handle this in both 2SXC and DNN's file system.
Internally when deleting images we see API calls like the following to the internal 2SXC API, but we're wondering if this is exposed somewhere within the public API?
https://somedomain.com/api/2sxc/app/auto/data/61393528-b401-411f-a001-f423ea46700a/b7d04e2c-c565-496c-8efb-aa133cf90d33/Photo/delete?subfolder=&isFolder=false&id=189&usePortalRoot=false&appId=3
We could probably use the same endpoint above, but we'd likely run into permission issues or changes to the APIs that could be problematic.
Thank you for any advice you can give! Perhaps #iJungleBoy can provide some thoughts on this.
As a solution from a completely different direction, if you are on the later release of 2sxc (v12.8+, v13+), and comfortable programming in C#, you might consider doing this as a "cleanup" from a Dnn Scheduled Task. This can be done with a relatively easy setup. We have a Gist in place that we use as a starter. You simply put the code in the /App_Code folder then setup a normal Dnn Scheduled Task. NOTE that you can scroll down to the first comment on the Gist to see a screenshot of a complete working setup.
Accuraty's AccuTasks template on GitHub Gists
There are two more key things to note:
You need to install Dnn's CodeDom 3.6 because the example uses the later versions C#'s string interpolation - OR remove the few $"ASL2021 - {this.GetType().Name}, Task Scheduled Email", bits or convert to string.Format() or something.
Since your task's code is NOT running in a (2sxc) module, if needed, you'll do stuff like this: 2sxc Docs - Use 2sxc Instance or App Data from External C# Code
So, if you are comfortable writing code that "finds and deletes stuff older than NN days" - this might be the way to go.

Custom Angular setup for MIT library/project

Hi I need your help trying to figure it out something.
First a little background, I was used to code in Django, it was fast to code and good, but times change and Node is taking over most of new apps, then I move to Express a couple of years ago, however I still miss a lot of the Django functionality, then I start coding a little library to help me with common tasks, then start growing until the current point where you have a core library and plug-able “apps” to do recurrent tasks, like notifications, auth and more, or at least that’s the plan.
Right now an app works something like this:
./controllers (All renders)
./endpoints (Restfull API endpoints)
./models (Static and DB models)
./public (Public files)
./style (Scss styles with bootstrap injected)
./views (Default templates, distributed with the app as example, loaded by default)
…/…/views (Custom views to rewrite the default ones from the app)
On start, JSloth compile everything for you and run the server (hot reload included):
Now, that works fine using an static multipage environment, but I will love to use Angular for that, changes will be needed but I want you guys to lead me in the right direction.
So far I have 2 ideas:
1- Split Routes/Html apps and Restful/Endpoints, then basically use an standard set up on that kind of apps with webpack and AngularSSR.
The big downside is, you can’t give an out the box frontend implementation for apps.
2- Figure it out a way to provide an Angular app for each JSloth app, in this way if you install/copy the auth app you will be provided of user lists, interfaces to update your profile, etc.
I’m thinking that may be a problem talking about performance because in this way you will have a lot of Angular apps, am I wrong?
I need a easy way to allow the final user to share footers and headers at least, maybe even styles or scss variables for colors, in that way it will not look like a huge change.
Do you have any other option? Any better idea?
Thank you so much for the help, this is the repository: https://github.com/chrissmejia/JSloth
Edit 1: Forgot to add the models folder

How to remove the "users" module from meanjs stack generation

The yeoman generators "meanjs" automagically installs a core and a user module when you do a fresh generation. My goal is to remove the user module and only use the core.
Any ideas? I considered sharing code but I'm not sure it would help.
Thanks
More Info:
The reason i'd like to remove this is because the web application I'm creating requires ZERO user management
The easiest option would simply be:
First make sure that you are able to run your code.
Delete the users folder.
Run your code, which will fail probably, and look at the errors.
Go through all the error messages and delete every link to the users module.
Note: this is applicable for MEAN version 0.4.X and above.

Is there an automated way to document Nancy services?

Is there any way to auto-generate Swagger documentation (or similar) for a Nancy service?
I found Nancy.Swagger, but there's no information on how to use it and the demo application doesn't seem to demonstrate generating documentation (if it does, it's not obvious).
Any help would be appreciated. Thanks!
In my current project I've been looking a lot into this problem. I used both nancy.swagger and nancy.swagger.attributes.
I quickly discarded Nancy.swagger, because for me personally it doesn't sound right that you have to create a pure documentation class for each nancy module. The attributes solution was a bit "cleaner" - at least codebase and documentation were in one place. But very fast this became unmaintainable. Module code is unreadable because of many attributes. Nothing is generated automatically: you have to put path, all parameters, even http method as an attribute. This is a huge effort duplication. Problems came very fast, a few examples:
I changed POST to PUT in Nancy and forgot to update [Method] attribute.
I added a parameter but not the attribute for it.
I changed parameter from path to query and didn't update the attribute.
It's too easy to forget to update the attributes (let alone documentation module solution), which leads to discrepancies between your documentation and actual code base. Our UI team is in another country and they had some trouble using the APIs because docu just wasn't up-to-date.
My solution? Don't mix code and documentation. Generating docu from code (like Swashbuckle does) IS ok, but actually writing docu in code and try to dublicate the code in docu is NOT. It's not better than writing it in a Word document for your clients.
If you want Swagger docu, just do it the Swagger way.
- Spend some time with Swagger.Editor and really author your API in
YAML. It looks all-text and hard, but once you get used to it, it's
not.
- Spend some time with Swagger.Codegen and adapt it (it already does a fair job for generating Nancy server code and with a few
adjustments to moustache templates it was just what I needed).
- Automate your process: write a couple of batches to generate your modules and models from yaml and copy them to your repository.
Benefits? Quite a few:
-
Your YAML definition is now the single truth of your REST contract.
If somewhere something is defferent, it's wrong.
Nancy server code is auto-generated
Client code-bases are auto-generated (in our case it's android, ios and angular)
So whenever I change something in REST contract, all codebases are regenerated and added to projects in one batch. I just have to tell the teams something was updated. They don't have to look through some documents and search for it. They just have their code regenerated and probably see some compile errors, in case of breaking changes.
Do I still use nancy.swagger(.annotations)?
Yes, I do use it in another project, which has just one endpoint with a couple of methods. They don't change often. It's not worth the effort to set up everything, I have my swagger docu fast up and running. But if your project is big, API is changing, and you have multiple code-bases depending on your API, my advice is to invest some time into a real swagger setup.
I am quoting the author answer here from https://github.com/khellang/Nancy.Swagger/issues/59
The installation should be really simple, just pull down the NuGet package, add metadata modules to describe your routes, and hit /api-docs. That should get you the JSON. If you want to add swagger-ui as well, you have to add that manually right now.
No. Not in an automated. https://github.com/yahehe/Nancy.Swagger needs lots of manually created metadata.
There is a nice article here: http://www.c-sharpcorner.com/article/generating-api-document-in-nancy-using-swagger/
Looks like you still have to add swagger-ui separately.

How to create basic pages with Symfony and Doctrine

I'm completely new with Symfony and Doctrine. I have generated a project with a the Doctrine ORM, my database schema is fully well generated.
Now I just want to create basic services (in simple .php pages) that do some actions according to parameters in a HTTP POST request.
I tried to create an app through the generate:app command but it seems to be a really ugly way...
I just need a basic .php page where I can use my doctrine objects and interact with my database easly. What is the easiest way to do that (can I do that with some basic require_once or I need to generate something with symfony, like a module ?) ?
Thank you!
I think symfony might not be for you. There is a 'symfony-way' of doing things. Part of that is the MVC seperation of logic.
A simple page would be:
$ ./symfony generate:project yourprojectname
$ ./symfony configure:database "mysql:host=localhost;dbname=yourdbname" root yourpassword
$ ./symfony generate:app frontend
$ ./symfony generate:module frontend yourmodule
Ok, now you have a module. Go to localhost/web/frontend_dev.php/module and you will see that you have setup a basic module and a congratulations message.
Read up on the URI-routing of symfony. localhost/web/frontend_dev.php/module/action/param/value, that's the basic default routing.
So it will call the action in your module and pass the parameter's value.
Do anything you want with it.
That said, you will have to read up on how symfony works. The framework can help you with a lot of things, if you know how it works. If you don't it will be more likely slowing you down.
Start here: http://www.symfony-project.org/get/pdf/jobeet-1.4-doctrine-en.pdf it will walk you through from beginning to end of a rather extensive project. Some of the things might seem a bit clumsy, but that is because in the process they WILL show you most everything that framework can do.

Resources