<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Basil</title>
    <description>The latest articles on DEV Community by Basil (@nadar).</description>
    <link>https://dev.to/nadar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F492908%2F29aabe82-17df-41c6-9860-aa520e585206.jpeg</url>
      <title>DEV Community: Basil</title>
      <link>https://dev.to/nadar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nadar"/>
    <language>en</language>
    <item>
      <title>Use Openapi Generator SDK  for Javascript within Nuxt.Js Project</title>
      <dc:creator>Basil</dc:creator>
      <pubDate>Mon, 26 Jul 2021 09:40:18 +0000</pubDate>
      <link>https://dev.to/nadar/use-openapi-generator-sdk-for-javascript-within-nuxt-js-project-j63</link>
      <guid>https://dev.to/nadar/use-openapi-generator-sdk-for-javascript-within-nuxt-js-project-j63</guid>
      <description>&lt;p&gt;Its very common to use an OpenApi SDK Client directly in your project - but the SDK Generators is mainly made to publish to generated code as a library on f.e. GitHub. Therefore the following steps will help you to install and use the generated SDK directly within your Nuxt.Js app:&lt;/p&gt;

&lt;p&gt;1) Run the Openapi-generator-cli command inside your project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;openapi-generator-cli generate &lt;span class="nt"&gt;-i&lt;/span&gt; https://path/to/openapi.json &lt;span class="nt"&gt;-g&lt;/span&gt; javascript &lt;span class="nt"&gt;-o&lt;/span&gt; oa/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Since that generated SDK module requires &lt;code&gt;superagent&lt;/code&gt; install that dependency in your project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add superagent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Generate a &lt;a href="https://nuxtjs.org/docs/2.x/directory-structure/plugins"&gt;NuxtJS plugin&lt;/a&gt; file which helps to include the library and also makes it more easy to access in your app. Create &lt;code&gt;~/plugins/oa.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;WebsiteSDK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;~/oa/src/index.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;defaultClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;WebsiteSDK&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ApiClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bearerAuth&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;defaultClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;authentications&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bearerAuth&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
  &lt;span class="nx"&gt;bearerAuth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;YOUR ACCESS TOKEN&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

  &lt;span class="nx"&gt;inject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WebsiteSDK&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make your SDK client available in nuxt.js as &lt;code&gt;this.$sdk&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4) Add the plugin in nuxt.config.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;plugins:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;src:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'~/plugins/oa.js'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;mode:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;'client'&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="err"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5) Now use your new plugin to make API calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;api&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;$sdk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;TheApi&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;UniqueOperationIdFromOpenApi&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;ps: Maybe there are better solutions, its more an a note for myself - maybe helps others too. Improvements are welcome!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>openapi</category>
      <category>nuxt</category>
      <category>sdk</category>
    </item>
    <item>
      <title>Compile SCSS and JS inside a PHP Project</title>
      <dc:creator>Basil</dc:creator>
      <pubDate>Fri, 20 Nov 2020 08:19:47 +0000</pubDate>
      <link>https://dev.to/nadar/compile-scss-and-js-inside-a-php-project-aic</link>
      <guid>https://dev.to/nadar/compile-scss-and-js-inside-a-php-project-aic</guid>
      <description>&lt;p&gt;There are still Projects which do not utilize all those fancy JavaScript Frameworks and their environments. No NPM, no YARN, just PHP (and HTML, CSS)&lt;/p&gt;

&lt;p&gt;But of course, SCSS might be used and some JavaScript parts you'd like to compile into minified files.&lt;/p&gt;

&lt;p&gt;How to compile your SCSS and JS files? Install a grunt workflow, Gulp or Webpack? You could... &lt;/p&gt;

&lt;p&gt;... but you don't need to mix up your well organized PHP project with Node stuff. Its possible to just install &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/unglue-workflow"&gt;
        unglue-workflow
      &lt;/a&gt; / &lt;a href="https://github.com/unglue-workflow/client"&gt;
        client
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      The client binary which sends the data to the server and creates the output from the API response.
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;
 and compile right from your console, no need for a package.json file (which is instantly outdated anyhow) inside your PHP Application.

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_cVRdX0S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/cq7w8py491pozb4ypvjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_cVRdX0S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/cq7w8py491pozb4ypvjk.png" alt="Alt Text" width="800" height="333"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  And this is why we cam up with &lt;a href="https://unglue.io"&gt;unglue.io&lt;/a&gt; an API based compile service for JS and SCSS.
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Forget the hassle of installing Node on your local system just to compile some SCSS files and minify/uglify JS code. A composer package which is seamless installed along with other depencies does all the job.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can either host your own API (there is a docker server image or just install the node package somewhere) or just use the public API we offer, its completely free and open source.&lt;/p&gt;
&lt;h2&gt;
  
  
  Using Unglue
&lt;/h2&gt;

&lt;p&gt;In order to use unglue you just need 3 things:&lt;/p&gt;

&lt;p&gt;1) Install the composer package &lt;code&gt;unglue/client&lt;/code&gt; (&lt;code&gt;composer require --dev unglue/client&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;2) Create an &lt;code&gt;.unglue&lt;/code&gt; file in the directory you would like to have your compiled files and let unglue know what to compile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "css": [
          "../scss/main.scss"
    ],
    "js": [
        "../js/main.js"
    ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) And run the &lt;code&gt;compile&lt;/code&gt; or &lt;code&gt;watch&lt;/code&gt; command right from your vendor folder: &lt;code&gt;./vendor/bin/unglue watch&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l8IHB807--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ay596bh69jtjc2zon5m5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l8IHB807--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/i/ay596bh69jtjc2zon5m5.png" alt="Compile with Unglue" width="800" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you are running your own server (locally or on a public URL) use &lt;code&gt;./vendor/bin/unglue watch --server=yourunglueserver.com&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For the full documentation and usage see &lt;a href="https://unglue.io"&gt;unglue.io&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;This is just another option to handle your frontend code workflow, the common workflows are not wrong, its just: &lt;em&gt;Frontend workflow done different&lt;/em&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>css</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
