JHipster - Can I add websocket support to my existing generated application? - jhipster

I have an existing JHipster application that was generated without adding the websocket option. A need has come about for this functionality to be added to the application for a realtime data view, is there a way to bolt this functionality into my existing generated app?
I tried adding toggling on the websocket: false value in the .yml file and re-running yo jhipster but this did not add in any new files and the example user tracker was not added into the project so assuming this cannot be accomplished this way
Thanks

The generator is looking for settings in the .yo-rc.json file which is located at root level in the folder of your app. Depending on your IDE it can be that is not shown and you need to show it over otehr perspective or to view it in a terminal/cmd.
In the .yo-rc.json you will need to change the value of the websocket property from no to spring-websocket i.e.
"websocket": "spring-websocket",
Now when you run your generator it should generate the parts need it for websockets. Also have a look at the jhipster doc for websockets

Related

How to modify template in jHipster entity subgenerator for angular2?

I have got some work to modify default html generated by Jhipster for Angular2 more specifically,i want to modify styles for grid generated by Jhipster for Entity's.
I have gone through tutorial creating module in Jhispter documentation.
https://jhipster.github.io/modules/creating-a-module/
generator for creating subgenerator is also their can someone please give me pointers on this problem?
e.g
yo jhipster:entity Author
from above command jhipster creates all necessary files at server and client like JPA Entity,REST controller,Service, at client side it creates CRUD UI for Author entity using Angular2(i opted for anular2)
I want to modify client generation Code, i just want to modify HTML templates which gets generated by jhipster entity sub:generator
you need to run Yarn and start modifying your author.component.html
which will automatically refreshed in your Browser.
https://jhipster.github.io/development/
You could also consider using git prior to running the generator and then reverting the server side code once the generator has ran

How to remove db initialization and connection step/code from JHipster microservice app?

I have created java microservices app using JHipster with options jwt, mysqldb, elastic search etc.., I want to remove db related stuff. I just want to use this searvice for indexing user given data to elastic search and apply search on it.
I'm new to java and so need help to remove db related stuff from this kind of app. Please help
You can try to edit .yo-rc.json file from your project, and change "databaseType": "sql" to "databaseType": "no" and re-generate your app using yo jhipster but there's no guarantee that it will work as "no db + ElasticSearch" is probably not a supported use case.
You may have also to remove "devDatabaseType" and "prodDatabaseType".
To be safer, you should rather copy your modified .yo-rc.json file to an empty directory and run yo jhipster from there.

adding social login to exising JHipster app

I've been developing a JHipster app for a number of days and I realize now that it was initially created without the Social login option. What is the best approach for adding it after the fact? Can I simply add "enableSocialSignIn": true to .yo-rc.json and re-run yo jhipster (everything is checked into git), or are the changes too significant?
Rather than clobber my app, I ended up creating a new temporary JHipster app, doing a diff of the two apps, and selectively copying over only the code that pertained to social logic (and eliminating the code that pertained to OAuth2, since I also switched to session based / spring security authentication as well).

How to efficiently update the API when Swagger spec file is updated? (express, nodejs)

I'm trying to setup a nodejs-express boilerplate for my new project, and this time I want to try doc-driven flow. I've checked couples of packages like swagger-node, swaggerize-express ...etc. They all provide great functionalities.
However, I don't see anything that could support incremental scaffolding when the Swagger file is updated. That means when the spec changes I have to manually check the diff and manually add/modify the new specs. That doesn't sound cool.
Does anyone could share something that is more reasonable? Thanks!!!
Edit:
After trying some frameworks, I decided to use swagger-express-middleware. This framework offers a convenient way to automatically check routes/parameters for your service.
You can use tools like swagger-maven-plugin to incrementally rebuild your server code, which means reading from your api definition and updating/building code as necessary. There are SAAS products like SwaggerHub which enable this as well, by merging code and pushing to git.

what's the best way to implement loopback on an existing node.js project

I have successfully created a few loopback projects using
slc lb project *myproject*
command but now I have a pre-existing node project that I would like to use loopback in.
Is there a recommended best practice around the migration to loopback?
Is it just a matter of including the relevant module references in my package.json and running npm install? Or do also need to make some changes to my app.js?
Will I need to manually create the models.json and datasources.json?
Any insignts appreciated.
Edit: I added the relevant loopback modules to my package.json, replaced my express requires with loopback, manually added a datasources.json, and models.json and it all seems to have worked.
The only remaining issue is that when I bring up my explorer view the shell comes up but no api endpoints even though I have models defined in my models.json file.
Edit: I added the relevant loopback modules to my package.json, replaced my express requires with loopback, manulally added a datasources.json, and models.json and it all seems to have worked.
The only remaining issue is that when I bring up my explorer view the shell comes up but no api end points even though I have models defined in my models.json file.
To load and process models.json and datasources.json, you have to "boot" your LoopBack application.
Assuming you have installed loopback 2.x in your project, and you want to use the old 1.x project layout scaffolded by slc lb, here are the instructions:
Install loopback-boot 1.x. Make sure you are not using 2.x or newer, as 2.x changed the project layout.
npm install --save loopback-boot#1.x
Modify your main application file (e.g. app.js) and add the following lines:
// at the top
var boot = require('loopback-boot');
// after you have created `app` object
// and configured any request-preprocessing middleware
boot(app, __dirname);
Please consider using the new 2.x project layout, see Migrating apps to version 2.0 for information on how to migrate your "models.json" into the new format.
Is there a recommended best practice around the migration to loopback?
I suggest scaffolding a new app using slc loopback and moving your old apps files to the relevant directories.
is it just a matter of including the relveant module references in my package.json and running npm install or do also need to make some changes to my app.js?
This will be part of the migration process, you will also need to configure app.js to meet your needs (like setting up middleware, etc)
will I need to manually create the models.json and datasources.json?
No, when you scaffold the app using slc loopback, they will be automatically generated in the new project.
The only remaining issue is that when I bring up my explorer view the shell comes up but no api end points even though I have models defined in my models.json file.
Did you create the files in commmon/models manually? Try creating them through slc loopback:model and the tool will add the configurations in server/model-config.json for you.

Resources