Nest JS on Monorepo with common library , can't run sls offline - serverless

I have a working Nest JS project configures as a monorepo , I can run sls offline and sls deploy and everything works ,
everytime I add a library using "nest g lib auth" and reference the Library module on the main module , SLS OFFLINE wont run stating it can't find "Runtime.ImportModuleError: Error: Cannot find module '#app/auth/auth.module'
expecting the library can work with the monorepo setup using serverless

Related

How to seperate React application from Ruby on Rails created with webpack configuration?

I found an open source Ruby on Rails project that is created with command rails new myapp --webpack=react but I am only interested in the React part. How can I seperate it from the rest and enable it to run on its own?
The link to repo: https://github.com/vigetlabs/storyboard
For what I have done so far;
React related files reside in directory ./app/javascript/pack/ but npm script triggers Ruby application first. Ruby, somehow, starts the React application. This is how far I could come.
use create-react-app to create a new react app.
copy and paste /app/javascript/src to the newly created react app. maybe packs folder too.
copy over the package.json file content to get all packages.
do some testing/debugging

aws-cdk: Any good guides or suggestions for folder structure for web applications?

context: I mostly do rails development along with webpacker. Webpacker puts a package.json at the root of the project.
I was wondering what suggestions people might have for adding aws-cdk into a basic rails application (or any type of web application framework) to make a nice deployment pipeline?
This I've thought about for directory structure:
Adding a .infrastructure folder to the root of the project. This is where all my cdk code would reside. What I don't like about this is during the deploy pipeline I would need to cd into that directoy and run yarn install. Also wouldn't like how I'd have to prefix all my paths with ../ if I need to reference resources outside of the directory (e.g. Dockerfile)
Moving cdk.json to the root of my project. This would solve the path prefix problem but I'd still need todo something along these lines cd .infrastructure && yarn install && cd .. && cdk deploy
Use something like lerna or yarn workspaces? Not sure how much I'd need to configure to webpacker to with those tools.
I tend to over think things way too much...
Am I over complicating this or is a "fullstack engineer" really hard work sometimes? 😅
If you are interested in combining your Infrastructure as Code with your application's deployment strategy you should look into cdk-pipelines. This way, you would just run cdk deploy and all of the build commands would be seperate from the deployment and run as part of the CI/CD build project. I work in .NET but this is how I've structured the folders:
my-repo
my-cool-project
src
MyApi
MyWebApp
cdk
cdk.json
...
Dockerfiles live in 'MyApi', and 'MyWebApp'.

Assets folder resolution: Running an application within a project not picking up assets

I created an application within an Angular workspace. When running
ng serve [application-name]
Picks up images and files in asset folder fine. Now I want to run the workspace with just
ng serve
I would expect through having the application lazy loaded the path would resolve but instead I get
zone.js:3243 GET http://localhost:4200/assets/terms.txt 404 (Not Found)
What is the proper setup to access assets of an application within a workspace?
EDIT After talking offline I think we've found a solution. I'll post it here and leave the below for reference even though the original answer I posted doesn't really apply to the problem.
You're trying to run multiple Angular apps and route between them via something like Firebase where you can direct different routes to different apps.
To get this to work locally for development you will need to run each Angular app separately on it's own port. I suggest you control the destination of the route in the environment files. This way when you are running locally you can point to the port the app is running on and then point to the endpoint Firebase uses in production.
Example environment.ts file in your root app
{
...,
OTHER_APP_URL: 'localhost:4201'
}
prod.environment.ts
{
...,
OTHER_APP_URL: '/otherApp'
}
Then in your component
....
import {environment} from '<path to environments file>';
#Component({
selector: 'my-component',
template: '<a [href]="otherAppUrl"></a>'
})
export class MyComponent implements OnInit {
otherAppUrl: string;
ngOnInit() {
this.otherAppUrl = environment.OTHER_APP_URL;
}
}
You will probably need to do something similar in the other apps so you can route from them to the root app or other child apps. You will probably also need to build the other apps with the --baseHref flag when you build for production so their assets are available. See here for more info from the docs: https://angular.io/cli/build
Old answer - doesn't really apply to the question
Looking at your repo I don't see the terms.txt in your root project's assets folder. I checked to see if it was in one of the other libraries in the repo but wasn't able to find it there either.
If this is an asset that is included or referenced by a component or service in one of your libraries you will need to copy that over to the library's output folder as part of your build process since that functionality isn't currently supported by the Angular CLI.
An example of a build script that might do this for you is:
ng build my-lib-with-assets --prod && cp -r projects/my-lib-with-assets/src/assets dist/my-lib-with-assets && ng build --prod
Don't forget that you need to build your libraries before you build your main project.

How do I produce a node module using dotnet-fable

I have a project that I've created with dotnet fable new -n ProjectName and if I run it with webpack server everything works as expected. However I want to create an Express server. For that I thought I would simply create a node module and then run that. But when I look at the help text from dotnet fable --help I can't find a way to tell fable to just compile the js and to let me chose where those files should be placed. So question how do I tell dotnet-fable to produce js files (and do nothing else).
p.s. using the fable-cli results in a null reference (likely due to the project file structure) which is why I haven't just used that
I just wrestled with the same thing. When using the fable template, dotnet fable npm-run build just builds JS files for me. Try removing the devServer section from webpack.config.js, and changing your "start" script in package.json to say webpack && node bundle.js. (The devServer feature in webpack starts up its own simple express.js backend - something I just learned while building my own fable express app)

ZEND2 project not working after cloned to separate machine

I have cloned my office colleague's zend2 project from our server. He used zfcuser, zfcbase, and zfcadmin. But when I tried to run the project in my local machine its giving
<b>Fatal error</b>: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException'
with message 'Module (ZfcBase) could not be initialized.' in C:\xampp\htdocs\coolshop
\vendor\ZF2\library\Zend\ModuleManager\ModuleManager.php:140
Everything is fine to me as the same project 100% working in my colleague's machine. I tried the composer as well. But no luck
This is a result of loading the ZfcBase module as a git submodule. If you fix this module you'll receive the same error for other modules or dependencies you're using in that manner. I've encountered this problem when someone tries to clone the project on a new machine or you delete the project locally and try to re-clone it.
The simple answer here is to use composer as your dependency manager, you'll have a better day. Head over to ZfcBase on Packagist and copy the require statement into your composer.json file (You'll need to run the composer script after saving your .json file). Most modules should have instructions on using composer to grab them in the README.
I should note that if you're using other modules that depend on ZfcBase, you'll likely just need to have a require statement for those, and not their dependencies (like ZfcBase).
Someone had a similar question regarding the ZfcUser module. Using composer solved his issue.

Resources