<?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[Stories by Egbaaibon Christopher on Medium]]></title>
        <description><![CDATA[Stories by Egbaaibon Christopher on Medium]]></description>
        <link>https://medium.com/@christopheregbaaibon?source=rss-19e15701a0ed------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zC4AhRL4a4nvry-v.jpg</url>
            <title>Stories by Egbaaibon Christopher on Medium</title>
            <link>https://medium.com/@christopheregbaaibon?source=rss-19e15701a0ed------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 02:58:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christopheregbaaibon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Node.js Apps with Dolph: A Comprehensive Guide to Modern Web Development Best Practice]]></title>
            <link>https://christopheregbaaibon.medium.com/building-node-js-apps-with-dolph-a-comprehensive-guide-to-modern-web-development-best-practice-ff9368ca16b4?source=rss-19e15701a0ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff9368ca16b4</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[dolphjs]]></category>
            <category><![CDATA[expressjs]]></category>
            <dc:creator><![CDATA[Egbaaibon Christopher]]></dc:creator>
            <pubDate>Sat, 11 Mar 2023 22:00:39 GMT</pubDate>
            <atom:updated>2023-05-30T17:54:15.373Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Node.js Applications with Dolph: A Comprehensive Guide to Modern Web Development Best Practices</h3><figure><img alt="DolphJs Image" src="https://cdn-images-1.medium.com/max/400/1*1G-eORenUu7OEl-MfJ6w5w.png" /></figure><h3>Introduction</h3><p>DolphJs is a lightweight JavaScript library for building APIs in both large and small-scale applications. It is a modified version of the popular Express.js library, providing a simpler and more streamlined API for building scalable and performant APIs.</p><p>DolphJs supports both Object-Oriented and Functional Programming paradigms, making it suitable for developers who prefer either approach.</p><p>Additionally, DolphJs supports both TypeScript and JavaScript, providing developers with the flexibility to choose the language that best suits their needs.</p><p>In addition to the library, DolphJs also includes a command-line interface (CLI) tool that provides a set of tools for working with DolphJs projects. The DolphJs CLI includes commands for creating new projects, generating code templates, building and testing your APIs, and more.</p><h3>Overview</h3><p>DolphJs is a lightweight and easy-to-use JavaScript library for building RESTful APIs in both small and large-scale applications. It provides a simpler and more streamlined API compared to popular alternatives like Express.js, making it ideal for developers who want to build scalable and performant APIs without sacrificing simplicity.</p><p>DolphJs is designed to be flexible and customizable, with a modular architecture that allows developers to easily add or remove functionality as needed. It includes a number of middleware functions that make it easy to add common features like authentication, logging, and error handling to your API.</p><p>One of the key benefits of using DolphJs is its speed and performance. It uses efficient code to ensure that your API responds quickly and can handle a large volume of requests without slowing down. It also provides tools for caching and load balancing, making it easy to optimize your API for high-traffic volumes.</p><p>DolphJs is well-documented and comes with a number of tools to help developers get started quickly. The command-line interface (CLI) provides a set of tools for creating and managing DolphJs projects, generating code templates, building and testing your APIs, and more.</p><p>Overall, DolphJs is a powerful and flexible library for building high-quality RESTful APIs in JavaScript. It is suitable for developers of all skill levels and can be used for a wide range of applications, from simple prototypes to large-scale production projects.</p><h3>Installation</h3><p><strong>Installing DolphJs as a Library:<br></strong>To use DolphJs as a library in your project, you can install it via npm by running the following command:</p><pre>npm install @dolphjs/core</pre><p>This will install the core DolphJs library and its dependencies in your project’s `node_modules` directory.</p><p><strong>Installing DolphJs CLI</strong></p><p>DolphJs also comes with a command-line interface (CLI) tool that provides a set of tools for working with DolphJs projects. You can install the DolphJs CLI globally by running the following command:</p><pre>npm install -g @dolph/cli</pre><p>This will install the DolphJs CLI globally on your system, making it available from any directory.</p><h3>Setup</h3><p><strong>Creating a New DolphJs Project</strong></p><p>Once you have installed the DolphJs CLI, you can create a new DolphJs project by running the following command:</p><pre>dolph create-app &lt;name-of-your-app&gt;</pre><p>Replace `&lt;name-of-your-app&gt;` with the desired name for your project. The `create-app` command will create a new DolphJs project with the specified name and generate a set of default files and directories.<br>You can also choose a project template when creating a new app. DolphJs provides four project templates to choose from, including: <br>— <strong>JavaScript OOP</strong><br> —<strong> JavaScript Functional Programming</strong><br> — <strong>TypeScript OOP</strong><br> — <strong>TypeScript Functional Programming</strong></p><h3>Getting Started</h3><p>After creating the app using the command above, <br>You can create a new route and controller. Here is and example of a simple test controller and route:</p><pre>    const Dolph, { catchAsync, AppRes httpStatus, Router } = require(&#39;@dolphjs/core&#39;);<br><br>    class TestController {<br>     constructor() {}<br><br>     getMsg = catchAsync(async (req, res, next) =&gt; {<br>      res.send(&#39;welcome to this endpoint&#39;);<br>     });<br>     sendMsg = catchAsync(async (req, res, next) =&gt; {<br>      const { body } = req;<br>      if (!body.name)<br>       return next(<br>        new AppRes(<br>         httpStatus.BAD_REQUEST,<br>         &#39;error, provide name in json&#39;<br>        )<br>       );<br><br>      res.status(httpStatus.OK).json(body);<br>     });<br>    }<br><br>    class TestRoute {<br>     path = &#39;/test&#39;;<br>     router = Router();<br>     controller = new TestController();<br>     constructor() {<br>      this.initializeRoutes();<br>     }<br>     initializeRoutes() {<br>      this.router.get(`${this.path}`, this.controller.getMsg);<br>      this.router.post(`${this.path}`, this.controller.sendMsg);<br>     }<br>    }<br><br>    const dolph = new Dolph([new TestRoute()], &#39;1919&#39;, &quot;development&quot;, { url: null }, []);<br><br>    dolph.listen();</pre><p>or</p><pre>const { Router } = require(&#39;@dolphjs/core&#39;);<br>const router = Router();<br><br>router.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Heyoooo!!&#39;);<br>});<br><br>const routes = [{ path: &#39;/api/v1&#39;, router }];<br><br>const dolph = new Dolph(routes, &#39;1919&#39;, &#39;development&#39;, null, []);<br>dolph.listen();</pre><p>The Dolph class takes 5 arguments when instantiated: <em>routes, port, node_env, mongodb connection params </em>and <em>middleware.</em></p><h3>Code Usage Examples</h3><p>To see some examples of how to use DolphJs in your projects, you can check out our GitHub <a href="https://github.com/dolphjs/example">repository</a> which contains several code usage examples for DolphJs. These examples cover a variety of use cases and demonstrate how to use DolphJs to build APIs using both OOP and functional programming paradigms.</p><p>We encourage you to explore the examples and see how DolphJs can help you build fast and scalable APIs for your projects. If you have any questions or feedback, please feel free to open an issue on the repository.</p><h3>Best Practices</h3><h3>CatchAsync</h3><p>The catchAsync function is a utility function that wraps your route handler functions and catches any errors that may occur inside them. This is useful for handling errors in an async route handler without having to use try-catch blocks.</p><p>Here’s an example of how you can use it:</p><pre>const { catchAsync } = require(&#39;@dolphjs/core&#39;);<br>const routeHandler = catchAsync(async (req, res, next) =&gt; {<br>  // your route code here<br>});<br>module.exports = routerHandler;</pre><h3>AppRes</h3><p>The AppRes class is a custom error class that you can use to return custom error responses to the client. It takes two arguments: an HTTP status code and a message.</p><p>Here’s an example of how you can use it:</p><pre>if (!body.name) return next(new Dolph.AppRes(httpStatus.BAD_REQUEST, &#39;error, provide name in json&#39;));</pre><h3>HttpStatus</h3><p>The httpStatus object is an object containing commonly used HTTP status codes as properties. You can use this to set the status code of your custom error responses. It is just an export of the original http-status package, which you can find <a href="https://github.com/adaltas/node-http-status">here</a>.</p><p>Here’s an example of how you can use it:</p><pre>const { AppRes, httpStatus } = require(&#39;@dolphjs/core&#39;);<br>new AppRes(httpStatus.BAD_REQUEST, &#39;error message&#39;);Conclusion</pre><h3><strong>MediaParser</strong></h3><p>The mediaParser function uses the multer package under the hood to parse media files. Thus freeing you from the stress of setting up the package.</p><p>Here’s an example of how you can use it:</p><pre>const { Router, mediaParser } = require(&#39;@dolphjs/core&#39;);<br>const TestController = require(&#39;@/controllers/test.controller&#39;);<br><br>class TestRoute {<br>  path = &#39;/test&#39;;<br>  router = Router();<br>  controller = new TestController();<br>  constructor() {<br>    this.initializeRoutes();<br>  }<br>  initializeRoutes() {<br>    this.router.get(`${this.path}`, this.controller.getMsg);<br>    this.router.post(<br>      `${this.path}`,<br>      mediaParser({ type: &#39;single&#39;, storage: {}, fieldname: &#39;upload&#39; }),<br>      this.controller.sendMsg<br>    );<br>  }<br>}</pre><p>alternatively,</p><pre>const { Router, mediaParser } = require(&#39;@dolphjs/core&#39;);<br>const TestController = require(&#39;@/controllers/test.controller&#39;);<br><br>const router = Router();<br><br>router.get(`${this.path}`, new TestController().getMsg);<br>router.post(`${this.path}`, mediaParser({ type: &#39;single&#39;, storage: {}, fieldname: &#39;upload&#39; }), new TestController().sendMsg);<br><br>const routes = [{ path: &#39;/&#39;, router }];</pre><h3><strong>Pick</strong></h3><p>The pick function allows for getting fields and values and setting to an object:</p><pre>const filter = pick(req.query, [&#39;limit&#39;, &#39;page&#39;]);<br>// console.log(filter)<br>// filter = {limit: 20, page: 1}</pre><p>the above code takes the limit and page properties of req.query express offers and adds them to a new object filter.</p><h3>Usage With Websockets</h3><p>Incase you wonder how you’ll attach a websocket server to the dolph engine then this would be of help: using socket.io</p><pre>const io = require(&#39;socket.io&#39;);<br><br>const dolph = new Dolph(routes, &#39;1313&#39;, &#39;development&#39;, { url: mongoConfig.url, options: mongoConfig.options }, middlewares);<br>const server = dolph.listen();<br><br>const socket = io(server, {<br>  cors: {<br>    origin: &#39;*&#39;,<br>    credentials: true,<br>  },<br>});<br><br>global.onlineUsers = new Map();<br><br>socket.on(&#39;connection&#39;, (socket) =&gt; {<br>  socket.on(&#39;add-user&#39;, (userId) =&gt; {<br>    onlineUsers.set(userId, socket.id);<br><br>    if (onlineUsers.get(userId)) {<br>      socket.emit(&#39;active&#39;, userId);<br>    }<br>  });<br>});</pre><h3>Note</h3><p>Dolphjs makes use of the following middleware packages so you don’t need to install them again:</p><ul><li>helmet</li><li>httpStatus</li><li>express</li></ul><p>If you need a better guide on how to setup a dolphjs application it’s best you view an example application built with dolphjs <a href="https://github.com/dolphjs/example">here</a> or better still, use the CLI application which sets up your dolphjs application just how you want it.</p><h3><strong>Summary</strong></h3><p>Dolph is a simple and lightweight web framework that can help you create powerful Node.js applications quickly and easily. With its built-in middleware and error handling, Dolph makes it easy to build robust web APIs that can handle a wide range of tasks.</p><p>While the current version of Dolph already offers a lot of useful features, there is still room for improvement and expansion. In future versions, we plan to add more middleware options, such as rate limiting and authentication, as well as support for additional databases and libraries.</p><p>Overall, Dolph is a great choice for anyone looking for a flexible and efficient web framework for their Node.js projects. Give it a try and see how it can help you build better web applications today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff9368ca16b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create an ‘HTTP’ server in Nodejs]]></title>
            <link>https://christopheregbaaibon.medium.com/how-to-create-an-http-server-in-nodejs-b353a795190e?source=rss-19e15701a0ed------2</link>
            <guid isPermaLink="false">https://medium.com/p/b353a795190e</guid>
            <dc:creator><![CDATA[Egbaaibon Christopher]]></dc:creator>
            <pubDate>Mon, 12 Apr 2021 09:00:59 GMT</pubDate>
            <atom:updated>2021-04-12T09:00:59.550Z</atom:updated>
            <content:encoded><![CDATA[<p>When you view a webpage, you are making a request to another computer on the internet, which then provides you the webpage as a response. That computer you are talking to via the Internet is a web server. A web server receives HTTP requests from a client , like your browser and provides HTTP response like a HTML or JSON from an ‘APl’. Creating a HTTP requires a lot of software. This software is divided into to components; the Front-end and the Back-end. Front-end code is mainly concerned with how the content is presented i.e the text styling, color, navigation bar, e.t.c. While the Back-end code is concerned with how the exchange of data, the processing and storage takes place. The code that handles network requests from the browser or communicate with the database is primary managed by Back-end code. The basic functionality of the required function is that it reads JavaScript file, executes the file and then proceeds to return the export objects. So in this case, since we want to use the HTTP Module, we will use the required function to get the desired functions from the HTTP Module, so that it can be used in Our application. In this line of code, the creation of a server application which is based on a simple function is needed. This function is called whenever a request is made into our server application. However, when a request is received, a response with a header typed “200” is sent, this is the normal response which is sent in an HTTP header when a successful response is sent to the client. In the response itself, we are sending the string “Hello World”. Then the usage of the server’s listen function takes place to make our server application listen to client request or port number 7000, you can specify any available port here. The HTTP which is the Hyper Text Transfer Protocol was built by Node.js to transfer data. It can create an HTTP server that listens to server ports and gives a response back. Making a simple HTTP server in Node.js has become the de facto “Hello World” for the platform. On the one hand , Node.js provides extremely easy to use HTTP APl. A simple web server also serves as an excellent demonstration of the asynchronous strengths of Node.js. A function that takes request objects and response objects as parameters contains request URL, response objects is how we send the header and contents back to the user making the request. Here we return a 200 response code with the body “Hello World”, other headers will also be set here. In summary, the method creates a server that is called ‘request listener’ whenever a request comes in. The next line server listener 8080 called the listen method which causes the server to wait for incoming requests on the specified port 8080 in this case. And there you have your basic Node.js HTTP server.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b353a795190e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>