<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Lyrid - Medium]]></title>
        <description><![CDATA[Lyrid Company Publication - Medium]]></description>
        <link>https://medium.com/lyrid?source=rss----7fa5bb202bab---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Lyrid - Medium</title>
            <link>https://medium.com/lyrid?source=rss----7fa5bb202bab---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 16 May 2026 23:09:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/lyrid" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[LYRID H1 2021 — Aurora v1.1 Release]]></title>
            <link>https://medium.com/lyrid/lyrid-h1-2021-aurora-v1-1-release-783f296e56e0?source=rss----7fa5bb202bab---4</link>
            <guid isPermaLink="false">https://medium.com/p/783f296e56e0</guid>
            <category><![CDATA[lyrid-tutorials]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[infrastructure]]></category>
            <dc:creator><![CDATA[Handoyo Sutanto]]></dc:creator>
            <pubDate>Tue, 18 May 2021 03:33:16 GMT</pubDate>
            <atom:updated>2021-05-18T03:34:36.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4Gh7I3uCInTnGrOtEoCew.jpeg" /></figure><h3>LYRID H1 2021 — Aurora v1.1 Release</h3><p>Hello everyone!</p><p>We are dropping some exciting news that we have been brewing for a couple of months now to bring you our next evolution of the Lyrid Platform as we make it even more accessible for everyone to get their codes built, deployed, and running serverless applications.</p><p>Right after our first Medium post back in December, we have gained many early users and feedbacks that allow us to focus on what we should build for our next iteration. We are truly grateful to our early believers and we made sure that they are heard. And our goal has always been the same:<strong> anything we do is to make it easy and simple for any developers that want to deploy their applications on the cloud as serverless applications.</strong></p><p>Some of these updates have been pushed out at the end of March 2021, and we have been ironing out the release, getting more feedback, as well as getting our partners ready to use these new features for their own solutions.</p><p>With that, let us dive into the updates!</p><h3>Lyrid Execution Domain (*.lyr.id)</h3><p>If I have to pick which of the feature is the most important, I will have to say this one. In this update, we created a new domain (lyr.id) for our end-users to access their applications in the public domain. This shapes how we serve the serverless function HTTP endpoint. We put a wildcard rule and certificate and created a new HTTP Proxy Service that maps a randomly generated string as a subdomain name into the serverless deployment on any public cloud that we support. Here is how the flow looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOZhwKBD6e57ISVbn9xnhA.png" /></figure><p>This is a publicly generated endpoint that is accessible by default, every single submission will generate these URLs. Your applications will be instantly available to the end-users without the need to configure any virtual machine, container instance, or network firewalls. We host this endpoint *.lyr.id with Geo-distributed DNS on multiple clouds.</p><p>There&#39;s an option to turn this off during submission if you want to keep the endpoint hidden. Check out our documentation for further information about this: <a href="https://docs.lyrid.io">https://docs.lyrid.io</a></p><h3>Custom Domain DNS Support</h3><p>A custom domain can be mapped to the execution subdomain name. All the user has to do is to create a DNS record (either CNAME or A record) that maps their application DNS name into the subdomain name.</p><p>Once the name is mapped, at the first call, the platform automates the certificate request with LetsEncrypt CertBot APIs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*Ey4P-xSSi_90FnifpG0l7Q.png" /><figcaption>LetsEncrypt certificate is issued for the domain name that is hosted within the Lyrid Platform</figcaption></figure><p>The issued certificate is stored internally within the platform and we apply account level at rest encryption to save and distribute these certificates within our platform.</p><p>In the future, we will support users to be able to upload their own certificates, but if you do require those capabilities, please let us know and we will be happy to support your own certificates.</p><h3>Additional Support for Node.JS Server-Side Rendered (SSR) Platforms</h3><p>Another thing that we have been working on over the past few months is adding new support for a Single-page Application (SPA) that is built using Server-Side Rendered (SSR) frameworks.</p><p>The rise and success of these frameworks for single-page applications is a natural progression to building web-native applications. Creating a scalable web application that has a high performance and search-engine-optimized is no longer something that requires long development cycles. And we definitely see the value of supporting these frameworks natively in our platform.</p><h4>Next.JS</h4><p>We choose first to support Next.JS inside our platform:</p><p><a href="https://nextjs.org/">Next.js by Vercel - The React Framework</a></p><p>Next.js is an open-source React front-end development web framework created by Vercel that enables functionality such as server-side rendering and generating static websites for React-based web applications.</p><p>Supporting SSR frameworks require us to modify our Node.JS workflow to support a chain of commands to builds the SSR assets and saves them to be served inside an Express.JS application.</p><p>We did that following update into our own landing page lyrid.io:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Us0qhjoVUDW5ZnXpdzV9vQ.png" /><figcaption>Our updated Landing Page is driven by the Next.JS framework</figcaption></figure><p>Once we knew we can support one SSR framework, we tested the new workflow against all these frameworks and most of them can be naturally supported in our new SSR workflow such as:</p><h4>Nuxt.JS</h4><p><a href="https://nuxtjs.org/">The Intuitive Vue Framework</a></p><h4>Gastby.JS</h4><p><a href="https://www.gatsbyjs.com/">The Best React-Based Framework | Gatsby</a></p><p>We will write guides as well as tutorials for these, but in the meantime, check into our updated documentation on how to get your Next, Nuxt, Gatsby project running inside our platform as Lyrid Serverless Application.</p><h3>Managed Environment Variables Supports</h3><p>Within this period, we also introduced a way to securely set environment variables in the platform. This allows our users to not rely on a file to set their environment variables. Environment variables can be injected into the platform using our API and Web:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bc8RyvNYck21BHiKo3lZ4A.png" /></figure><p>And it will be set at the deployment time of application into the appropriate platform. Users will also able to override values for the environment for each deployment.</p><h3>AWS Lambda Defaults to Container Deployment</h3><p>Back in December 2020, Amazon Web Services Lambda announces Container Image is publicly available:</p><p><a href="https://aws.amazon.com/blogs/aws/new-for-aws-lambda-container-image-support/">New for AWS Lambda - Container Image Support | Amazon Web Services</a></p><p>We decided to take full advantage of this as soon as we can spend some engineering cycle. We were quite excited about this because building containers not only allows us to build a larger package (we hit the 50MB upload limit in a lot of instances), it also streamlines our build and deployment process as it fits into our workflow pipeline.</p><h3>UI/UX Improvements</h3><p>Along with environment and policy management for applications, we also implemented various improvements in the application user interface to improve the serverless application experience.</p><h4>App Overview</h4><p>A new application overview that shows the detail of a serverless application. From the size of the submission to the size of the builds for each platform to the details on where it is being deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTve2a-uWd_DPeGlWF4Sug.png" /></figure><h4>Execution Domain Management</h4><p>We also added a user interface for the user to add and attach their custom domain and previews their application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M4MOJh8FFQF0ngqp7BSgUA.png" /><figcaption>Running our Landing Page inside our own platform</figcaption></figure><h4>Console View</h4><p>We brought our console monitoring into the UI to be able to do monitor the console output of their applications:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EWXPUQWeIAuUFCaj6XtAcA.gif" /><figcaption>Console output of the account running serverless applications</figcaption></figure><h4>Code View</h4><p>And lastly, in our new code viewer, users will be able to check the running revision of the submission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B5dsW9XtSflbla5xK3vFow.png" /><figcaption>Code Preview</figcaption></figure><h3>Tighter Deployment and Various Infrastructure Improvements</h3><p>As for updates in our backend infrastructures:</p><ul><li>We updated our infrastructure deployment codes.</li><li>Integrate and repacked our modules into our own Serverless Application.</li><li>Utilize more of the Kubernetes Cluster automatic scaling in our backend platform.</li></ul><p>Here’s the anatomy of how Lyrid is managing a Kubernetes cluster with our services installed inside them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z16ggJAfTOHGM_AqAWL4yA.png" /></figure><p>The tighter integrations into the services resulted in a massive performance increase for our</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*KDNdqn7ZP2ceucMn5yhu6w.png" /></figure><p>As shown in our latency metrics, we successfully brought back our services with reduced jittery-ness and improved the latency for almost every call into the platform upward of 80%.</p><p>These tighter Kubernetes integrations are a sneak peek into our ability to bring Lyrid on-premise solutions a step closer into your data center and harnessing the same capabilities of what we produced in the SaaS that is available at the moment.</p><h3>Conclusion</h3><p>The past few months have been quite a busy time for us and we have been expanding our reach and our partner networks to constantly improving the platform. Here are some of the focus for the product that we identified for the near future:</p><ul><li>Improving our onboarding and embedding tutorials</li><li>Support for submission using Git URLs</li><li>Native CRON Scheduling Event</li></ul><p>We strive to be the most fluid and agnostic platform to deliver any applications. There’s so much potential of where we can go from here. And with that, you can register a Free Lyrid account to get started with the following link and try these all yourself:</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q22021">Register Here To Start Lyrid</a></p><p>Lastly, please do not be shy to contact me at hsutanto@lyrid.io or join our <a href="https://api.lyrid.io/slack">Slack </a>channel to say hi. Thank you for reading, stay tuned for more, updates, tutorials, and how-to guides!</p><p>Handoyo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=783f296e56e0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyrid/lyrid-h1-2021-aurora-v1-1-release-783f296e56e0">LYRID H1 2021 — Aurora v1.1 Release</a> was originally published in <a href="https://medium.com/lyrid">Lyrid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Securing CRUD API With JSON Web Token (JWT) On Express and Lyrid Serverless Function]]></title>
            <link>https://medium.com/lyrid/securing-crud-api-with-json-web-token-jwt-on-express-and-lyrid-serverless-function-67ad4c759aa5?source=rss----7fa5bb202bab---4</link>
            <guid isPermaLink="false">https://medium.com/p/67ad4c759aa5</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[lyrid-tutorials]]></category>
            <dc:creator><![CDATA[Handoyo Sutanto]]></dc:creator>
            <pubDate>Mon, 25 Jan 2021 15:21:19 GMT</pubDate>
            <atom:updated>2021-02-25T21:33:41.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h-j5KZKSkh-_Ayjb_eQO9Q.jpeg" /></figure><p>In most cases, when building API for your services, you will need a way to verify if the user is properly authenticated to read the data that belongs to the user. The calls will need to be authenticated and the identity of the caller needs to be passed down to the service to make the appropriate database calls that only show relevant data to that user.</p><p>In this tutorial, we will continue our Lyrid Serverless Function builds from our previous NodeJS post to build an API endpoint that is protected, able to identify its caller user identity, and only update fields that belong to this user.</p><p>For this post, I am crediting these 2 blog posts as I am creating a remix of these 2 posts to show how to create a login, along with the protected routes that do CRUD (Create-Read-Update-Delete) API using standard NodeJS Express and to publish them into Lyrid Function:</p><ol><li>Tutorial for creating NodeJS protected routes using JWT by Jason Watmore:</li></ol><p><a href="https://jasonwatmore.com/post/2018/08/06/nodejs-jwt-authentication-tutorial-with-example-api">https://jasonwatmore.com/post/2018/08/06/nodejs-jwt-authentication-tutorial-with-example-api</a></p><p><a href="https://jasonwatmore.com/post/2018/08/06/nodejs-jwt-authentication-tutorial-with-example-api">NodeJS - JWT Authentication Tutorial with Example API</a></p><p>2. Tutorial for NodeJS CRUD API using PostgesSQL by Geshan Manandhar:</p><p><a href="https://geshan.com.np/blog/2021/01/nodejs-postgresql-tutorial/">https://geshan.com.np/blog/2021/01/nodejs-postgresql-tutorial/</a></p><p><a href="https://geshan.com.np/blog/2021/01/nodejs-postgresql-tutorial/">Node.js Postgresql tutorial: Build a simple REST API with Express step-by-step</a></p><p>These 2 blog posts are an excellent starter to grasp the concepts that are usually required to understand how we build API services that know the “user” and its scope on how to read/write/update his record in the backend database. The full code for this is hosted on this GitHub page:</p><pre><a href="https://github.com/LyridInc/lyrid-jwt-crud-expressjs.git">https://github.com/LyridInc/lyrid-jwt-crud-expressjs.git</a></pre><h3>What is JWT and Why?</h3><p>In an effort to make this post shorter, I will not dive too deep into how JWT works. In short, it describes the flow of authentication and authorization in HTTP calls, example are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*txkVkch2V2WSSSiN.png" /></figure><p><a href="https://developer.okta.com/blog/2019/02/14/modern-token-authentication-in-node-with-express">Modern Token Authentication in Node with Express</a></p><p>JWT is a 2 step authentication and authorization process that uses standard HTTP Request and Response to grant a user access into restricted API calls. The steps are as follows:</p><ol><li><strong>Authentication</strong>: <br>Usually requires the user to pass in username and password (in some systems it can be a verification token from email or SMS) into an authentication endpoint of the service. <br>This authentication endpoint will check for the credentials and grant access by creating an authorization token in form of a signed JWT that is generated by a private key in form of a secret string or certificate. Anyone can read the JWT information but only systems that have the secret string or certificate can verify these tokens.<br>Internally, the JWT can contain information regarding the scope of the API call (user id, email address, etc), along with token issue time and expiration time. A shorter expiration time is usually better for security, but it does introduce more calls into the authentication endpoint.</li><li><strong>Authorization</strong>:<br>During any authenticated API call, the caller will need to pass authorization in the form of an Authorization Bearer token header. This contains the JWT that is generated on the first step. <br>The API service will need to share the same secret or certificate that allows the API server to verify the token without the need to communicate with the authentication service. This way, the REST API will actually carry an identity without containing any information about the credential of the user.</li></ol><p>By decoupling the Authentication and Authorization step, developers will then have the ability to also decouple their APIs with their user authentication and management that has major advantages like:</p><blockquote><a href="https://dzone.com/articles/jwtjson-web-tokens-are-better-than-session-cookies">https://dzone.com/articles/jwtjson-web-tokens-are-better-than-session-cookies</a></blockquote><blockquote><strong>No Session to Manage (stateless): </strong>The JWT is a self contained token which has authetication information, expire time information, and other user defined claims digitally signed.</blockquote><blockquote><strong>Portable:</strong> A single token can be used with multiple backends.</blockquote><blockquote><strong>No Cookies Required, So It’s Very Mobile Friendly</strong></blockquote><blockquote><strong>Good Performance: </strong>It reduces the network round trip time.</blockquote><blockquote><strong>Decoupled/Decentralized: </strong>The token can be generated anywhere. Authentication can happen on the resource server, or easily separated into its own server.</blockquote><p>JWT is one of the techniques that is commonly used in HTTP authorization and there are other tutorials there that explain JWT on how it is being used. Here are some additional information on the topic:</p><p><a href="https://auth0.com/docs/tokens/json-web-tokens">JSON Web Tokens</a></p><p>We want to show how these standard techniques can also be applied to the serverless function that you build in the Lyrid platform.</p><h3>Prerequisites</h3><ul><li>A laptop or PC (Mac/Windows/Ubuntu don’t really matter)</li><li>NodeJS 12.x or above installed: <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a></li><li>npm: <a href="https://www.npmjs.com/get-npm">https://www.npmjs.com/get-npm</a></li><li>Lyrid account: you can <a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">register here</a> for free, no credit card required, along with Lyrid CLI downloaded.</li><li>Git: <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">https://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a></li><li>Any of your favorite IDE, I use Visual Studio Code in this example.</li><li>Some HTTP testing tool (I will use Insomnia in this example, but either one works):<br>Postman: <a href="https://www.postman.com/downloads/">https://www.postman.com/downloads/</a> or<br>Insomnia: <a href="https://insomnia.rest/download/">https://insomnia.rest/download/</a></li><li>PostgreSQL Database: Using a Postgres-as-a-Service database is the easiest and quickest way to get started. As the post from Geshan suggested, I will also create a small free instance over at ElephantSQL: <a href="https://www.elephantsql.com/">https://www.elephantsql.com/</a></li></ul><h3>Setup</h3><p>First, let&#39;s clone our repository and run them:</p><pre>git clone <a href="https://github.com/LyridInc/lyrid-jwt-crud-expressjs.git">https://github.com/LyridInc/lyrid-jwt-crud-expressjs.git</a><br>cd lyrid-jwt-crud-expressjs<br>npm install</pre><p>The next step is that we need to inject seed data into this SQL for testing the application. You can do that by pasting the data inside db/init.sql into the SQL browser of ElephantSQL and click on execute:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MZt6FyM_flk614zMoCaFMQ.png" /></figure><p>For those who can’t read SQL queries, all this script does is create a new table and inserts data into the database.</p><p>If you read and follow Geshan’s post, you will notice that the original SQL query from the original post does not have user-id information, and this modified query has an ID of 1 or 2 in the database that represents the user ID.</p><p>The next step is to copy the connection string into the environment file. Open your .env file and put your PostgreSQL URL. You will also need to generate a string that will be used to sign the JWT, you can use a randomly generated string of 32–64 characters. The final environment file looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*jW5hSLAmWprcg4Yej9zh-w.png" /></figure><p>Now you can run your REST API to test them by calling:</p><pre>npm start</pre><p>Now that it is running, we dive deeper into the additional middlewares and routes from our previous post. We added a few additional configurations in our src/entry/entry.js that does the following:</p><ul><li>Configures JWT middleware to secures the API with rules.</li><li>Create login endpoint.</li><li>Create protected CRUD endpoints.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*rV1me0yiUCPJw0ZhYpzQqg.png" /></figure><p>Let’s dive deeper into this middleware and endpoint.</p><h3>Authentication Endpoint</h3><p>Inspired by the blog post from Jason @ <a href="https://jasonwatmore.com/">https://jasonwatmore.com/</a>, we created the middleware that handles POST request with the path of /login as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*8RvCHf2kmXTmROekGT-JOQ.png" /></figure><p>The login will take in the username and password as a body of the request, and create a JWT (using a library called jsonwebtoken) that has the user ID that expires in 7 days. This response is then signed by the secret string that is inside our environment.</p><h3>Configuring Protected/Unprotected Routes</h3><p>After coding the login endpoint, we need to configure our Express application to be able to handle JWT bearer tokens in the header by adding a middleware library called express-jwt.</p><p>This middleware allows every single request to be authenticated, and we are able to configure the endpoints that don’t need to be authenticated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*7KZamlA3Zksdjfdg1yhCtA.png" /></figure><p>The login endpoint will not be authenticated and for backward compatibility, we will include the original routes from our first blog post to be unprotected.</p><h3>Protected Routes and CRUD API</h3><p>Since these calls are protected by JWT middleware, all the internal APIs have information about the user context, and the internal SQL queries can be generated using that context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*6Z9FDuH3_woIwX9ElQvnWg.png" /></figure><p>Here are the resulting protected endpoints:</p><p>GET /quotes — Get a page that contains quotes for the following user. It employs pagination as a technique to keep response small and faster user experience.</p><p>POST /quotes — Inserts a quote for the following user with data from the request body.</p><p>PATCH /quotes/:quoteId — Updates an existing quote with id with data from the request body.</p><p>DELETE /quotes/:quoteId — Deletes a quote with id.</p><p>Internally, the update and delete verify the id and only does the operation if the user id is the same as the id in the database.</p><p>Digging deeper into one of the quotes will show the SQL commands that are generated. For example, opening the src/protected/service.js, and looking at the code flow, validating the input, and injects the parameters into a SQL query, and passed the query into the db.query() function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*q_M_kO7H27FZ63MTkKpA_A.png" /></figure><p>Where the db.query() code is as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*tDCjHYcJ21040YfGXjH3vw.png" /></figure><p>It has a connection to the database and this is where the SQL queries are executed against the PostgreSQL URL that is configured early in the tutorial.</p><p>That’s it, we are ready to run and test this out.</p><h3>Test and Deployment</h3><p>Let’s test this login with the same username and password that is hardcoded into src/users/list.js,</p><pre>{</pre><pre> &quot;username&quot;: &quot;user1&quot;,<br> &quot;password&quot;: &quot;password&quot;</pre><pre>}</pre><p>Your response will be like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*40rvPOcGQFbfBjtW20PFZQ.png" /></figure><p>The JWT token to authorize the subsequent requests will be in the response as shown above.</p><p><strong><em>Pro Tip:</em></strong><em> Anyone can read the content of your JWT using any tools out there (example: </em><a href="https://jwt.io/"><em>https://jwt.io/</em></a><em>) as it is a standard. Only the servers that have the secret strings can verify if this token is actually valid, so do not share your secret key with any system that is not authorized to do verify the token.</em></p><p>Run GET /quotes for the next request, but you will need to copy and paste the token generated into the Bearer token Authorization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*kciqjqFbBvhYywK4jLAQDA.gif" /></figure><p>As you can see, the API request will only return the quotes that belong to the user that is associated with the user.</p><p>To insert new quotes data for the following user, call the following endpoint with the same token:</p><p>POST /quotes —</p><pre>{</pre><pre> &quot;quote&quot;: &quot;Where is the beef?&quot;,<br> &quot;author&quot;: &quot;Handoyo Sutanto&quot;</pre><pre>}</pre><p>As you insert them, you can call GET /quotes again to see the quote that you inserted.</p><p>Now we tested the new endpoints, let&#39;s submit this function into Lyrid platform by calling:</p><pre>lc code submit</pre><h3>Passing Authorization Header in Lyrid API Gateway</h3><blockquote>This part of the tutorial is specific to Lyrid and the Universal API Gateway implementation.</blockquote><p>Now that your function is up there in our platform, how do you pass the Authorization Bearer token? As you recall from our previous posts, the Authentication header is already used by our platform to identify the execution against the Lyrid account.</p><p>For this purpose, we developed an additional header that our users can use to pass the Authorization into their serverless function. X-Lyrid-Authorization is a Lyrid specific header that will be handled by the platform. The platform will pass down the value of this header as an Authorization header.</p><p>Set the X-Lyrid-Authorization Header as following (remember to include the Bearer string in there):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhYLVf9E1U8HyDuRkL7pyQ.png" /></figure><blockquote>We are currently working on creating a unique execution endpoint that works on a top subdomain of Lyrid that doesn’t require you to pass Basic Authentication header.</blockquote><h3>Conclusion</h3><p>Obviously, we won’t use a hardcoded username and password in production. Since the authentication service is decoupled, there are options to do a managed authentication services (example: Okta, Auth0, or AWS Cognito). These services can help developers to authenticate their username and password in a separate secured environment and generates JWT without the need to host in their own environment.</p><p>This allows developers to offload the user and password management and focus more on the API that they are building. As shown in this tutorial, we support the usage of any external authentication services into your Lyrid Serverless Function using this method.</p><p>As for Lyrid, we utilize JWT heavily inside our connected services that drive all the function build, execution, and deployment. We have developed a modification of this open-source GraphQL Authentication :</p><p><a href="https://django-graphql-auth.readthedocs.io/en/latest/">Django GraphQL Auth</a></p><p>This enables us to do our own self-hosted authentication management that does the following:</p><ul><li>Python 3.8, Django 3.0.5 application on Lyrid Serverless platform.</li><li>Uses GraphQL endpoint and mutations for authentication API.</li><li>Connects to almost any database, e.g.: PostgreSQL, MySQL, or even MongoDB.</li><li>Manages user ID, logins, and tokens.</li><li>Connects user ID to other Single-Sign-On services to enable login with external login services (GitHub, Facebook, Google).</li><li>2-Factor-Authentication plugin.</li><li>Configuring communication settings (Email or SMS).</li><li>Administrator dashboard to be able to reset any user’s password.</li></ul><p>All of them, packed into the Lyrid Serverless application. We will show you how to instantiate, run, and use this service easily inside your Lyrid Account. This is for our future blogs, but please don’t be shy to contact me hsutanto@lyrid.io or join our <a href="https://api.lyrid.io/slack">Slack </a>channel to say hi if you want to learn more about this!</p><p>Thank you for reading!🐱‍🏍Stay tuned in for more tutorials!</p><p>Handoyo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67ad4c759aa5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyrid/securing-crud-api-with-json-web-token-jwt-on-express-and-lyrid-serverless-function-67ad4c759aa5">Securing CRUD API With JSON Web Token (JWT) On Express and Lyrid Serverless Function</a> was originally published in <a href="https://medium.com/lyrid">Lyrid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Driving Lyrid Function Execution From a React Single Page Application (SPA) Hosted in Github Pages]]></title>
            <link>https://medium.com/lyrid/driving-lyrid-function-execution-from-a-react-single-page-application-spa-hosted-in-github-pages-3f15fd45fc8f?source=rss----7fa5bb202bab---4</link>
            <guid isPermaLink="false">https://medium.com/p/3f15fd45fc8f</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[lyrid-tutorials]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Handoyo Sutanto]]></dc:creator>
            <pubDate>Wed, 30 Dec 2020 03:39:28 GMT</pubDate>
            <atom:updated>2021-01-21T18:24:31.829Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KPcWS3YL75NEw830_1l4lg.png" /></figure><p>Let’s continue from our previous tutorial by building a front-end web application from what we learned. We went through how to build a serverless NodeJS 12.x Express application backend that utilizes Sharp image processor:</p><p><a href="https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122">https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122</a></p><p>In this tutorial, we will use GitHub’s awesome feature that helps web application developers to host their static page applications onto a working website for free. Just like our services, no credit card is required to host your static page.</p><p>We will show you how to build a simple React SPA that calls into the API that was built in the previous tutorial.</p><h3>Prerequisites</h3><ul><li>Lyrid Account: <a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></li><li>Go through our previous post: <a href="https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122">https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122</a></li><li>GitHub Account: <a href="https://github.com/join">https://github.com/join</a></li></ul><h3>Create an Execute Only Access</h3><p>First thing to do is to create an execute only access and secret key. Why execute only access?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-W1gQk680M_G40ksC5CjuA.png" /></figure><p>The reason is because we will be hosting the access key and secret on our front end, and the credential will be exposed by anyone that are able to open your front-end application. The execute only access keys will only be able to execute function inside your account, and this access key will not be able to do any administrative functionality.</p><p>To do this, go to your account settings page, and click on the IAM tabs: <a href="https://app.staging01.lyrid.io/app/settings/account">https://app.lyrid.io/app/settings/account</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsorVXvJyeI9pVtSh8NIXw.png" /><figcaption><a href="https://app.staging01.lyrid.io/app/settings/account">https://app.lyrid.io/app/settings/account</a></figcaption></figure><p>Give the key some name, and make sure the restrict access flag is checked, and then click on Generate Keys.</p><p>Store the access key and secret someplace, and we will use them on the later part of the tutorial.</p><h3>Setup GitHub Pages</h3><p>For this tutorial, we have setup a GitHub repo template that can help you bootstrap the project faster:</p><p><a href="https://github.com/LyridInc/react-staticpage">https://github.com/LyridInc/react-staticpage</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pNlbHZ097v6ZiWsewniUYg.png" /></figure><p>Click on Use this template button. And fill the appropriate form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bfi9kIushPBPn_yaAd6eUg.png" /></figure><p>When creating a new repository with this template, please ensure that you check that “<strong>Include all branches</strong>” settings. This will copy the branch that is hosting the static files as well.</p><p>Now that you have copied this template, you will need to clone them into your local machine:</p><pre>git clone https://github.com/{GitHub-Username}/{GitHub-ProjectName}.git<br>cd {GitHub-ProjectName}</pre><p>And there’s a few things your will need to change in this template:</p><ul><li>.env — This is where you will be putting your execute only access and secret key.</li></ul><pre>REACT_APP_LYRID_EXECUTE_KEY=&lt;RestrictedAccessKey&gt;<br>REACT_APP_LYRID_EXECUTE_SECRET=&lt;RestrictedSecretKey&gt;</pre><ul><li>package.json — Change the homepage settings URL at the very top. The format for the URL is as follows:</li></ul><pre>&quot;homepage&quot;: &quot;<strong>https://{GitHub-Username}.github.io/{GitHub-ProjectName}/</strong>&quot;,</pre><p>In our case, it will be:</p><pre><a href="https://lyridinc.github.io/react-staticpage/">https://lyridinc.github.io/react-staticpage/</a></pre><ul><li>src/helpers/api.js — (Optional) This is where you put Lyrid API endpoint URL if you changed any names in the previous tutorial.</li></ul><p>Now, lets test and run this locally by running:</p><pre>npm install<br>npm start</pre><h3>React App Template</h3><p>Now, let’s explain a little bit about this react application template that you just copied into your GitHub account. This template is created using create-react-app @ <a href="https://create-react-app.dev/">https://create-react-app.dev/</a>, and modified to host our components to drive the API calls.</p><p>There are some libraries that we want to mention for this front-end:</p><ul><li>Axios Instance Routing</li></ul><p>At src/helpers/api.js, we use this library called axios (<a href="https://github.com/axios/axios">https://github.com/axios/axios</a>) to call into our API that we developed on the previous post.</p><p>During development, you can change the axios instance to call into your localhost by commenting out the production instance and use the localhost instance instead:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*BDl97eFkNYLgkxOP9Hxecg.png" /></figure><ul><li>React Hooks</li></ul><p>Most of the components for the UI are built using the newer way of building react functional components with React Hooks (useState and useEffect). Which allows a more flexible and easier to understand code.</p><p>We created simple controls that loads an image URL and binds user’s input into the query parameter requests of the backend API. We then show the output of API which is the processed image as the user changes the input.</p><p>More about React Hooks here: <a href="https://reactjs.org/docs/hooks-intro.html">https://reactjs.org/docs/hooks-intro.html</a></p><h3>Modifying CORS for Server Side</h3><p>Because we will be running API calls from a browser hosted on a cross-site resource, we will be requiring to setup Cross-Origin Resource Sharing (<strong>CORS</strong>). This allows your front-end to pass authenticated messages using the browser into your serverless function call.</p><p>Cross-Origin Resource Sharing (<strong>CORS</strong>) is an HTTP-header based mechanism that allows a server to indicate any other origins (domain, scheme, or port) than its own from which a browser should permit loading of resources.</p><p><strong>CORS is a server side settings</strong>, and we will need to make these changes on the backend project. Open the <strong>src/entry/entry.js</strong> file and add these following code snippet and change the Origin URL appropriately to your hosted GitHub Pages URL:</p><pre>var cors = require(&#39;cors&#39;)</pre><pre>var corsOptions = {</pre><pre>origin: [ &#39;http://localhost:5000&#39;, &#39;https://{GitHub-Username}.github.io&#39; ],</pre><pre>  credentials: true,</pre><pre>}</pre><pre>app.use(cors(corsOptions))</pre><p>Here is how our CORS settings looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*VKaSF1lgMvW_jtHe1hqbvg.png" /></figure><p>After making the appropriate CORS changes and run the code submit again to update the server side API:</p><pre>lc code submit</pre><h3><strong>Deploy the Static Page</strong></h3><p>Now that we setup all the required codes and backend, we can deploy the react static pages using this following command on the react project:</p><pre>npm run deploy</pre><p>You may be prompted with GitHub credential login to authenticate if you have access to check into your repository. Just fill in your GitHub username and password and viola! Once the deployment is complete, you can access your web application at:</p><pre><a href="https://{GitHub-Username}.github.io/{GitHub-ProjectName}/">https://{GitHub-Username}.github.io/{GitHub-ProjectName}/</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bGRSGckcm4YHwkpRNIbumQ.png" /></figure><p>That’s it! You have just hosted a full web application that has a React front-end and ExpressJS Serverless back-end! Check out the output GitHub page that we deployed for this tutorial:</p><p><a href="https://lyridinc.github.io/react-staticpage/">https://lyridinc.github.io/react-staticpage/</a></p><p>And with that, you can start hacking away and let us know what you are building with our platform!</p><h3>Conclusion</h3><p>This tutorial translates to any static page hosting service that you can think of. We like GitHub Pages just because it is free and straight-forward, and there are more features available in GitHub Pages that we have not explored in this tutorial: <a href="https://pages.github.com/">https://pages.github.com/</a></p><p>We would like to also add that we also have support for our own domain support for static pages with the ability to add your own custom domain into your functions or web servers. We are still working on the release for this feature, but if you like us to help you set up a custom domain, just let us know!</p><p>And with that, you can register a Free Lyrid account to get started with this following link and try these all yourself:</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></p><p>Lastly, please do not be shy to contact me at hsutanto@lyrid.io or join our <a href="https://api.lyrid.io/slack">Slack </a>channel to say hi and let us know if there are any issues for you following this example.</p><p>Thank you for reading, stay tuned for more tutorial and how-to guides!</p><p>Merry Christmas and Happy New Year! Stay safe!</p><p>Handoyo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f15fd45fc8f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyrid/driving-lyrid-function-execution-from-a-react-single-page-application-spa-hosted-in-github-pages-3f15fd45fc8f">Driving Lyrid Function Execution From a React Single Page Application (SPA) Hosted in Github Pages</a> was originally published in <a href="https://medium.com/lyrid">Lyrid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building and Distributing NodeJS 12.x Express Serverless Application With Lyrid]]></title>
            <link>https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122?source=rss----7fa5bb202bab---4</link>
            <guid isPermaLink="false">https://medium.com/p/5ed18345b122</guid>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[lyrid-tutorials]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Handoyo Sutanto]]></dc:creator>
            <pubDate>Mon, 21 Dec 2020 04:55:13 GMT</pubDate>
            <atom:updated>2021-01-07T21:24:40.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xb83SdJIX1CMxqhuktezCA.png" /><figcaption>No…that’s not me</figcaption></figure><h3>Introduction</h3><p>This is a series of tutorials that I will start building mainly focusing on showcasing how things work and how to build an application using Lyrid. This example specifically will show you how to deliver a standard NodeJS 12.x running Express Web Server as a Lyrid application.</p><p>Although these blogs are about our own technology, you will soon see that there is nothing in this platform that requires you to conform with a non-standard method of building an application. Everything you do here can still carry forward to writing an application on your own Virtual Machine. For instance, Docker Container, or Kubernetes.</p><h3>Prerequisites</h3><ul><li>A laptop or PC (Mac/Windows/Ubuntu don’t really matter)</li><li>NodeJS 12.x or above installed: <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a></li><li>npm: <a href="https://www.npmjs.com/get-npm">https://www.npmjs.com/get-npm</a></li><li>Lyrid account: you can <a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">register here</a> for free, no credit card required, along with Lyrid CLI downloaded.</li><li>Git: <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git">https://git-scm.com/book/en/v2/Getting-Started-Installing-Git</a></li><li>Any of your favorite IDE, I use Visual Studio Code in this example.</li><li>Some HTTP testing tool (I will use Insomnia in this example, but either one works):<br>Postman: <a href="https://www.postman.com/downloads/">https://www.postman.com/downloads/</a> or<br>Insomnia: <a href="https://insomnia.rest/download/">https://insomnia.rest/download/</a></li></ul><h3><strong>Initial Setup</strong></h3><p>First you will need to register your Lyrid account:</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></p><p>And go through the 3 sections:</p><ul><li>Registration: <a href="https://docs.lyrid.io/docs/en/registration/">https://docs.lyrid.io/docs/en/registration/</a></li><li>Installation: <a href="https://docs.lyrid.io/docs/en/installation/">https://docs.lyrid.io/docs/en/installation/</a></li><li>Client Initialization: <a href="https://docs.lyrid.io/docs/en/initialization/">https://docs.lyrid.io/docs/en/initialization/</a></li></ul><p>This whole guide assumes that you already registered with Lyrid, downloaded our command line client, and initialized the client with your access and secret key.</p><p>You will then need to clone the base project. For this example, it is hosted at GitHub:</p><pre>git clone <a href="https://github.com/LyridInc/lyrid-expressjs.git">https://github.com/LyridInc/lyrid-expressjs.git</a></pre><h3>Local Build and Test</h3><p>To run the sample locally, simply run these commands:</p><pre>cd lyrid-expressjs<br>npm install<br>npm start</pre><p>Simple…so far so good…lets dig into what we have in the code. This sample REST API is quite simple:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*VX9aPNSr7QgkWw_-vW7nuQ.png" /></figure><p>It contains a basic index.js where it will initialize an express web server application instance, and the function entry point (entry.js) will define how this instance is built along the routes. There’s a logging middleware (morgan: <a href="http://expressjs.com/en/resources/middleware/morgan.html">http://expressjs.com/en/resources/middleware/morgan.html</a>) that logs every request for this application.</p><p>This service has two routes:</p><p><strong>/echo/* </strong>: This endpoint will just echo all your request url, and method then prints it out as a text response. Test it with Insomnia by passing HTTP POST Method and /echo/hello_world request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*VtrdBdCCmZS57dMZPVKnrA.png" /></figure><p>Looks good!</p><p><strong>/sharp/ </strong>: We will get into this endpoint in the later portion of the tutorial.</p><p><strong>Lyrid Definition File and Entry Point</strong></p><p>Let’s explain a bit about this GitHub project example. The structure of the code is similar to our initial code when you run:</p><pre>lc code init --name &quot;$AppName&quot; --module &quot;$ModuleName&quot; --function &quot;$FunctionName&quot; --language &quot;nodejs12.x&quot; --web &quot;express&quot;</pre><p>Except in this case we already prefilled all those names and description.</p><p>A few things to explain in this template is the .lyrid-definition.yml file, and inside it there is an entry point called entry.js</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*u6YN7_Wb8N48sLF6p3CnQw.png" /></figure><p>Changing this definition file is not required, but it is crucial to explain how this file is being used by our platform.</p><p>The definition file contains descriptors that will be used in our platform to identify how the function will be built and packed. In this scenario, because it is an Express Project, our build will expect an express server instance application to be returned from the entry point (entry.js). The user has the flexibility to modify the entry point to include more routes and middleware inside the project, and our platform will take in the express server instance and wrap the instance for different types of serverless platforms.</p><p>The definition file determines how your function will be called inside our API Gateway.</p><p><strong>NOTES: </strong>This is specific for our NodeJS 12.x Support. Our current support for NodeJS and Express is only for non-asynchronous function execution, and continues until the <a href="https://nodejs.org/en/docs/guides/event-loop-timers-and-nexttick/">event loop</a> is empty or the function times out. We will have support for asynchronous Promise based type of wrapper soon.</p><h3>Public Cloud Deployment</h3><p>Now your code is working locally, the next question is: how to make this API run on a publicly accessible endpoint?</p><p>Run our submission command from the folder that contains our definition file:</p><pre>lc code submit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*tB11f1kMtNFmGX6ePgI-qQ.gif" /></figure><p>In this stage, your function will be zipped, and wrapped by our platform and the platform will perform a build to create a build artifact for all the public cloud serverless platforms that we support.</p><p>At the end of the submission, save the endpoint generated by the platform.</p><p>In this stage, we went through a standard serverless function build. This runs the pre-built installation using npm install and packages the function as an application.</p><p>Run the following command to monitor your build output:</p><pre>lc monitor -c &#39;*.build.*&#39;</pre><p>When your build is deployed to your default execution platform, your function is published and ready to use.</p><h3>Public Cloud Execution</h3><p>Now that your application is deployed, execute it using our endpoint. Remember the structure of our endpoint is currently:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqDUDwYsIJOs5tSGi8efmw.png" /></figure><p>This turns your endpoint to (if you didn’t change any names in the lyrid definition): <a href="https://api.lyrid.io/x/node/express/latest/entry/">https://api.lyrid.io/x/node/express/latest/entry/</a></p><p>When testing with HTTP client like Insomnia, remember to change the authorization to Basic on this tab and fill in your Lyrid access key as username and Lyrid secret key as the password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qM3EAz4BRAZUAoZnL_Bg-w.png" /></figure><p>Let’s execute this by clicking on the Send button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V-SweBX_nw_o_C2xokoXVg.png" /></figure><p>Looks good! The app is now hosted inside our platform.</p><p>Similarly, you can also test out calling the application using cURL command like this (on Mac or Linux):</p><pre>curl -u $LYRID_ACCESS:$LYRID_SECRET <a href="https://api.lyrid.io/x/node/express/latest/entry/echo/hello_world">https://api.lyrid.io/x/node/express/latest/entry/echo/hello_world</a></pre><p>Where $LYRID_ACCESS and $LYRID_SECRET corresponds to your access key and secret key.</p><p>You can monitor your LYR execution logs using our lc monitor function and filter for all LYR execution in your account:</p><pre>lc monitor -c &#39;*.execute.LYR&#39;</pre><p><strong>Express Sharp Endpoint</strong></p><p>The other endpoint that we have in this example is our implementation of an image processing that uses a high performance Node.js image processing called Sharp: <a href="https://sharp.pixelplumbing.com/">https://sharp.pixelplumbing.com/</a></p><p>We take inspiration from this GitHub page: <a href="https://github.com/pmb0/express-sharp/tree/3.1.1">https://github.com/pmb0/express-sharp/tree/3.1.1</a></p><p>And made little modifications to the endpoint to be able to support any URL given to the function. The URL format is as follows:</p><pre>/resize/:width/:height?format=$format&amp;progressive=true&amp;quality=90&amp;crop=false&amp;gravity=center&amp;url=$image_url</pre><p>Where:</p><ul><li>width: integer, the fixed width of the output image.</li><li>height (optional): integer, the fixed height of the output image. If not provided, it will maintain the aspect ratio of the image.</li><li>format (optional): string enum, valid values are one of the format supported by sharp: <a href="https://sharp.pixelplumbing.com/api-output#toformat">https://sharp.pixelplumbing.com/api-output#toformat</a>. Default: webp if supported else, the output format of the requested image.</li><li>progressive (optional): boolean, only for jpeg and png. Use &amp;progressive=true to enable progressive scan.</li><li>quality (optional): integer (1–100). quality is a Number between 1 and 100. Default if 80.</li><li>crop (optional): boolean. Use &amp;crop=true to enable the sharp cropping feature. Default is false. Note: Both width and height params are neccessary for crop to work.</li><li>gravity(optional): string enum. When the crop option is activated you can specify the gravity of the cropping. Possible attributes of the optional gravity are north, northeast, east, southeast, south, southwest, west, northwest, center and center. Default is center;</li><li>url: string. URL to original image.</li></ul><p>Lets test this function locally and look for a publicly accessible image URL at Imgur. I will use this one: <a href="https://i.imgur.com/3a0qwRe.jpeg">https://i.imgur.com/3a0qwRe.jpeg</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fimgur.com%2F3a0qwRe%2Fembed%3Fpub%3Dtrue%26ref%3Dhttps%253A%252F%252Fembed.ly%26w%3D701&amp;display_name=Imgur&amp;url=https%3A%2F%2Fimgur.com%2F3a0qwRe&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=imgur" width="701" height="895" frameborder="0" scrolling="no"><a href="https://medium.com/media/ab32ac2bfd50e69d543ac789e7359da2/href">https://medium.com/media/ab32ac2bfd50e69d543ac789e7359da2/href</a></iframe><p>The original image has resolution of 701x701 pixel and 56KB in size.</p><p>Lets run though this image with a few different parameters locally first with base URL of <a href="http://localhost:3000/sharp">http://localhost:3000/sharp</a> and HTTP method of GET in your Insomnia Client:</p><pre>GET /resize/250/150?crop=true&amp;gravity=north&amp;url=https://i.imgur.com/3a0qwRe.jpeg</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*uQvFixyDzJned0if5-PeWw.png" /><figcaption>Resize to 250x150 and crop with gravity=north</figcaption></figure><pre>GET /resize/500?format=webp&amp;quality=25&amp;url=https://i.imgur.com/3a0qwRe.jpeg</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*CyV8HU8_V12ZEwkUSZpfXA.png" /><figcaption>Scale the image with fixed height of 500, converts it to WEBP format and quality=25</figcaption></figure><p>The cropped and resized imaged above is much less than the original image (4.9KB and 6.3KB). Change the endpoint with base URL to <a href="http://api.lyrid.io/x/node/express/latest/entry/sharp">http://api.lyrid.io/x/node/express/latest/entry/sharp</a> and add your Access Key and Secret just like the previous section, and test it again. You just hosted an image processing service that you can use to dynamically resize, crop and convert any publicly accessible image.</p><p>Sharp is a very complex image processing library, and unfortunately we will not dive further into the what it can/cannot do. We just want to show you in this blog that we are able to integrate complex libraries and package them into a simple API using Lyrid.</p><h3><strong>Conclusion</strong></h3><p>In this tutorial, we want to show a basic use-case of our platform. Hopefully, this has given something that can be easily followed and to show how our platform works. More of these upcoming tutorial series will touch on examples that:</p><ul><li>Connects to a Database</li><li>Connects to a Storage</li><li>More Middlewares: CORS, JWT Authentication, etc2.</li><li>Seamlessly moves your application to another public cloud (AWS or GCP) while maintaining the same endpoint.</li></ul><p>Notice in this whole process, apart from our command line client, you did not even touch or download any library, framework, or tool to make this work on a different cloud provider. This follows our philosophy of <strong>“Only Focus on Your Code — BUT It Still Should Be Able to Run Anywhere”. </strong>We are abstracting anything that is not related to your code (the build, distribution and execution).</p><p>Along with NodeJS 12.x + ExpressJS, the same flow can be done with our support for:</p><ul><li>Django + Python 3.8</li><li>Flask + Python 3.8</li><li>Gin + Golang 1.x</li><li>ASP.NET + .NET Core 3.1</li><li>And more upcoming support</li></ul><p>And with that, you can register a Free Lyrid account to get started with this following link and try these all yourself:</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></p><p>Lastly, please do not be shy to contact me at hsutanto@lyrid.io or join our <a href="https://api.lyrid.io/slack">Slack </a>channel to say hi and let us know if there are any issues for you following this example.</p><p>Thank you for reading and stay safe!</p><p>Handoyo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ed18345b122" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyrid/building-and-distributing-nodejs-12-x-express-serverless-application-with-lyrid-5ed18345b122">Building and Distributing NodeJS 12.x Express Serverless Application With Lyrid</a> was originally published in <a href="https://medium.com/lyrid">Lyrid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LYRID]]></title>
            <link>https://medium.com/lyrid/lyrid-85e9b07121fe?source=rss----7fa5bb202bab---4</link>
            <guid isPermaLink="false">https://medium.com/p/85e9b07121fe</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[Handoyo Sutanto]]></dc:creator>
            <pubDate>Thu, 17 Dec 2020 21:32:55 GMT</pubDate>
            <atom:updated>2021-01-07T21:12:07.788Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKUJq6PTK6cf54wQrFCXEg.jpeg" /></figure><p>Let me start first with who we are and what we do.</p><p>Hi!</p><p>My name is Handoyo Sutanto and I am the co-founder and creator of Lyrid. Today has only been the 2nd week of December of 2020 and there are already so many announcements from different aspects of our lives. Ranging from COVID-19 vaccine news, to AirBnb, and Doordash IPOs. But on top of all the big news, we have bigger news of our own! This month is where we decided to publicly start allowing access to our platform without any restrictions!</p><p>Yes, really! You can register to our platform and deploy your own serverless applications in less than 5 minutes without any credit card requirements!</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></p><h3><strong>Firstly…What is Lyrid?</strong></h3><p>We are a collection of tools and frameworks that are put together as a SaaS platform. You will be able to use these to help build your cloud-native serverless application that can run on multiple, serverless public cloud platforms (such as AWS Lambda or Google Cloud Run).</p><p>Lyrid is first and foremost a platform provider for anyone to run their application servers. We create a seamless experience for anyone to develop their idea as efficient and frictionless as possible without compromising security, inter-operationality, and scalability. Multi-cloud serverless compute is one of the tools to get there.</p><p>We perform all the build and deployment process for different cloud platforms for our users. So, they can just focus on what is important for them, which is, <strong>their business</strong>. We mean it when we say, they should just focus on their business and operations, not figuring out things like:</p><ul><li>Which cloud platform to use?</li><li>Where they need to deploy their services?</li><li>How much resource they will need? CPU? RAM? How many instances? And where?</li></ul><p>We achieve this by managing and driving your cloud build, deployment and executions using policies, and building more intelligence into the platform on how/where/when your application should be built, distributed and executed. We also deploy and execute your functions using our Universal API Gateway.</p><h3><strong>Understanding The Motivation</strong></h3><p>Prior to Lyrid, my background for the past 15 years was working on enterprise infrastructure and distributed system software. The workload varied from software that distributes media, transcoding jobs to building scalable storage, and, compute and networking subsystem using various technologies.</p><p>I love experimenting with new technologies, but the more I wrote and deployed my code in the cloud, the more I started to realize something.</p><p><strong>Reducing Repetition and Guesswork</strong></p><p>That is…most of the things we (Cloud Engineers and DevOps) do is actually repetition. We like to think that what we do is so revolutionary, but in most cases are just a combination of your muscle memory (repetition) and guesswork. The challenge of knowing exactly what kind of resources and the amount needed at a given point in time is an ongoing battle for us. There are tons of tools/analytics/monitoring solution software that revolves around these problems.</p><p>Here’s what you feel like doing when you guess wrong:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bsC-qhMU4py-krikiPNcCQ.gif" /><figcaption>Credit: Office Space (Watch it if you haven’t!)</figcaption></figure><p>We are not condoning property destruction, but boy I can really relate to them!</p><p>I am sure we can do better than this…It was about 4 years ago that I got my first exposure to serverless by AWS Lambda, and was immediately drawn into the technology. Especially, on how it can remove almost all of the guesswork (at least on the question of “how many instances do I need?”). The baked-in efficiency that is inherited from pay-per-execution cost structure is just something that I had never seen before!</p><p><strong>Clearing Misconceptions about Serverless Technology</strong></p><p>However, the benefits that I mentioned above does comes with a cost, almost every managed serverless platform out there (AWS Lambda, Google Cloud Function, Azure Function, etc.) needs to confirm with the cloud’s specifications on how to “run” your function. Case and point, check out these different entry points for your function input/output that the user has to put together in order to make their code work inside the platform:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t_tDedwFCeEAClzzhVJ4fg.jpeg" /><figcaption>Different Ways For Different Platform to even write a Hello World Function in Go</figcaption></figure><p>And because of that, serverless is probably the most misunderstood technology in the past 4 years. The amount of conflicting information floating around the internet is toxic for the growth of the technology itself. Here are some of the information titbits that I found from my personal experience with some of my colleagues that resist deploying a serverless solution:</p><ul><li><strong>How tied it is to the platform dependency.</strong> Which means that you can only fully benefit from serverless only if you put all your workload in the same platform.</li><li><strong>Which leads to:</strong> investing in making something into serverless will pretty much lock you into the platform further.</li><li><strong>Along with non-upfront and complex pricing calculations.</strong> The scale to zero and pay as you scale is actually a double-edged sword to the adoption. There is actually some comfort about knowing what the upfront cost is. Check out this recent blog by written by Sudeep at <a href="https://tomilkieway.com/">Milkie Way, Inc.</a> on how it can get out of control: <a href="https://medium.com/milkie-way/we-burnt-72k-testing-firebase-cloud-run-and-almost-went-bankrupt-part-1-703bb3052fae">https://medium.com/milkie-way/we-burnt-72k-testing-firebase-cloud-run-and-almost-went-bankrupt-part-1-703bb3052fae</a></li><li><strong>And lastly,</strong> there is still no clear understanding on what can or cannot run as serverless.</li></ul><p>And here are some examples of the conflicting information about serverless that confuses most people:</p><ul><li>Why do I need to learn about the platform? Isn’t the point of serverless is to focus on your business logic?</li><li>Why do I really still have to know how big I should scale my machine? Isn’t the platform supposed to take care of that?</li><li>Why do I really still have to know where it is deployed? Isn’t the platform supposed to take care of that as well?</li></ul><p>One more misconception about the technology is an association that people make. We also want to create this new way of thinking that AWS Lambda != Serverless. AWS Lambda is a compute platform that runs a serverless workload.</p><p>They were the one that coined that term so a lot of people associate them together, and this association is a hinderance to the adoption.</p><p>We will get into more detail about what we think to be the common misconceptions about serverless on the next upcoming blogs.</p><p><strong>Don’t get us wrong…we are actually strong believer in serverless! And we believe everyone should write more of them! </strong>So I had a vision of what serverless should be. With that I start this company, and our views are that serverless is a piece of technology and a philosophy on how a developer should build an application:</p><ul><li>Never have any infrastructure to manage from the end-user side.<strong> </strong>No infrastructure is needed to build and distribute your application. Not even containers are required. Just build your code on your machine.</li><li>Standardized input/output interfaces regardless where it is run.</li><li>Universally accessible tools, platforms and frameworks that can be used and scaled by anyone from college students, scrappy start-ups, to Fortune 500 companies.</li><li>Focus on your code! Optimize there! Really…and not in how it is being built, distributed, deployed, and executed. Those should be the platform’s job to optimize.</li><li>The platform itself should self-expand, shrink, and auto-load balance with geographical awareness in the background with the ability to scale to zero if there are no requests. Thus, further reducing any guess work.</li><li>Privacy and security needs to be baked into the platform and users will be able to harden their deployment as much as they need to. The platform should always facilitate this without getting in the way.</li></ul><p><strong>Building Platform For Everyone</strong></p><p>This is pretty much the driving force that makes us wants to create Lyrid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tlPcqpdnO6w1b4LB5T_y8Q.jpeg" /></figure><p>At the end, what we want to create is a platform for everyone to test and build their ideas rapidly while still keeping all the best cloud practices built in.</p><p>We believe in the power of serverless that given the right tools built around it, that we can make your application run on serverless on any given platform.</p><p>We see an opportunity here where we can provide the ecosystem of tools necessary for running applications as efficiently as possible (using serverless on any cloud), thus removing all the guesswork and excess as much as possible.</p><h3><strong>How does it work?</strong></h3><p>The bulk of what our platform does, runs after the user submits their application into our platform. Our command line client at this point will zip and upload your code to be submitted into our pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*x9iRBlOa67wE9UB5-qACHA.gif" /><figcaption>Lyrid CLI — Code Submission</figcaption></figure><p><strong>Build</strong></p><p>At the code submission, our platform will wrap the users application with a lightweight wrapper that makes your function run on different cloud vendors that we support.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Xd0dD4cfH2fAcet7WMGOA.png" /></figure><p>This wrapped code will be stored inside our infrastructure to be built inside our platform. Then we will execute recipes depending on your current programming language, web server framework, and the target cloud infrastructure. The output of these builds are build artifacts that can be directly deployed into the appropriate cloud vendors.</p><p><strong>Deployment</strong></p><p>We will then use those builds to run our deployment process. During the deployment process, our platform will determine how your function application will be distributed globally based on the policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FL28lFExISV1Xf44ga1iIA.png" /><figcaption>Lyrid Policy Driven Distribution and Execution</figcaption></figure><p>This allows the application or service creator the flexibility to determine what is important for their application. Some users need deployment policies that are able to run their compute as close as possible to the end-users while others need to have something that can utilize all the public cloud resources as much as possible.</p><p><strong>Execution</strong></p><p>For execution, your request will be routed to our closest managed region (currently we are managing 3 major regions: US West, South-East Asia and Europe Central) and executed based on the policy that you set globally on your account or at the application level.</p><p>In addition, for execution, we have an implementation of Universal HTTP API Gateway. In short, it is a translation layer for your pure HTTP calls (Request Path URI, Queries, Headers, and Body) and wrap them into the appropriate serverless native input/output format that is understood by the execution platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJlTTEfSs3RrQW0l1IDazg.png" /><figcaption>Universal HTTP API Gateway for Serverless Functions hosted in Lyrid</figcaption></figure><p>Read more about it here in our <a href="https://docs.lyrid.io/docs/en/invokinguniversalgateway/">Universal HTTP API Gateway Documentation</a>.</p><p><strong>Pricing/Limit</strong></p><p>Naturally, your first question would be: how much does this cost?</p><p>Free. Really… Free</p><p>Well… Free with limits, then there’s the next tier limits of Pro access of $49 a month (or $499 a year). On top of higher limits, Pro access will unlock more features. We also offer 30-day Free Trial to our Pro subscription.</p><p>Here is a quick summary of what is the difference between Free, Pro and above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-TDuTI6K9UbaWwOdVnJRXA.png" /></figure><p>As shown there, almost all the core features is available in Free tier. In addition, both Free and Pro accounts implement rate limiter functionality for LYR platform execution: <a href="https://en.wikipedia.org/wiki/Token_bucket">https://en.wikipedia.org/wiki/Token_bucket</a></p><p>We calculate your requests and refills based on these parameters:</p><ul><li>Deployed RAM size</li><li>Time taken to execute a function</li><li>Account type (Pro/Free/Enterprise)</li></ul><p>We will get into detail about these Lyrid rate limiters and the limit behaviors in the next few topics.</p><p>Above Pro, feel free to contact us for the following things for our Enterprise Solutions:</p><ul><li>If you require performance higher than our Pro accounts or requires additional infrastructure to run your workload.</li><li>Managing and supporting dedicated infrastructure clusters for your workload (Compute, Database, Storage, etc2).</li><li>Connecting your own infrastructures on your cloud (on-premise, public or hybrid cloud) to Lyrid to run closer to your data for high IOPS and throughput sensitive operations.</li><li>Building and designing a resilient self-expanding/sustaining application on your own cloud or datacenters.</li></ul><p><strong>What is next for us?</strong></p><p>The mark of good and successful platform companies are its ability to let their users experience the power of the platform and successfully repeat them with consistency.</p><p>And with that in mind, <strong>we are building an ecosystem with the platform. </strong>An ecosystem of reusable components that is built using our serverless-first mindset.</p><p>We are also looking to expand our pricing, and build more cost predictability and consistency using analytic data for all tiers of our users that are looking to burst up and down in more efficient way.</p><p>Here are some topics that I will be covering, along with some examples of the components that we have successfully integrated or use inside our platform along with some projects from our early adopters:</p><ul><li>We will dive into more details about Lyrid and its components that we built to create this platform.</li><li>We will walk you through an experience of building a full application using an example of our authentication service endpoint:(https://id.lyrid.io). This service was previously hosted on Auth0 and prior to release but we decided to host this ourselves using our own technology and create a fork from this Django project: <a href="https://django-graphql-auth.readthedocs.io/en/latest/">Django GraphQL Auth</a>, and put our serverless spin to build the component. We will show you the steps for how we have successfully migrated from Auth0 into this.</li><li>Learn how we package our Docusaurus <a href="https://docs.lyrid.io">documentation </a>static files and serve them as a serverless web server function using Golang 1.x and Gin.</li><li>Integrated our build and deployment process using GitLab CI/CD and our tools to continuously update our services.</li><li>Our distributed analytics and metrics collections for all our infrastructure monitoring are based of our own serverless function built with Golang 1.x that extend the metric endpoints and service discovery of Prometheus. This is the backend of how we presented this graph in our dashboard:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*axjD43HVZIeWjBUYv08Btw.png" /><figcaption>Serverless Operations Statistics Dashboard</figcaption></figure><ul><li>Learn how our friend and mentor at <a href="https://1800battery.com/">1800-Battery</a> reduces their AWS dependencies using our .NET Core 3.1 + ASP.NET implementation.</li><li>Learn how we package <a href="https://xgenecloud.com/">XgeneCloud</a> NodeJS 12.x + Express application as a Lyrid Serverless and deliver a low-code CRUD HTTP REST API into your SQL-based Database.</li><li>And many more topics…</li></ul><p>We will share these processes in future blogs and publish more guides on how to build different things using a mixture of open-source materials hosted on our GitHub page at <a href="https://github.com/LyridInc">https://github.com/LyridInc</a>, blog, and video content. It will take us some time to create these contents and if you are interested to know about one of the above topics sooner, just contact us at hello@lyrid.io!</p><p>As for what we are looking for:</p><ol><li><strong>Feedback:</strong> So far, all the features that we have and built have been coming from all the feedback from our users. This helps us prioritize what we are working on in order to build this platform that everyone can benefit from. We want to be able to support more languages, and more native serverless platforms. Join our <a href="https://api.lyrid.io/slack">Slack</a> channel to engage with us, tell us what you want to see in the platform and how you want us to build it.</li><li><strong>Community Supporters and Contributors:</strong> Internal contributor to build on the platform or external contributors to build for the ecosystem (or both). We are not quite open-source end-to-end, but we are not shy about sharing our technology to the world.</li><li><strong>Strategic Partnerships and/or Investors:</strong> We are looking to grow and we will need help doing it. I am one of those people that values your time and effort more than anything else in the world.</li></ol><p>We want to be more available all across the world and expand our network and ecosystem to include as much support for every cloud vendor, web framework, and programming language!</p><p>With that said and done, you can register a Free Lyrid account to get started with this following link:</p><p><a href="https://app.lyrid.io/register/campaign?_key=MEDIUM_Q12021">Register Here To Start Lyrid</a></p><p>Lastly, please don’t be shy to contact me hsutanto@lyrid.io or join our <a href="https://api.lyrid.io/slack">Slack </a>channel to say hi. Let us know what you want to build with our platform!</p><p>Thank you for reading and stay safe!</p><p>Handoyo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85e9b07121fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/lyrid/lyrid-85e9b07121fe">LYRID</a> was originally published in <a href="https://medium.com/lyrid">Lyrid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>