Building A P2P Network With Deno 🌐

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • Newman

    Newman is a command-line collection runner for Postman

  • Here is the second API to create a new WebSocket client. Explicitly, the user will need to provide the client node's target URL via a REST protocol POST call. When the client is opened (onopen), it is added to the peer list of the current server; on the other hand, when the client is closed (onclose), this same client is removed from the list. Finally, the API returns a simple message with a status 201 (CREATED), or an HTTP 400 code (BAD REQUEST) if the URL value isn't present in the body of the call. Since this is a POST request, it is necessary to use a REST client: cURL, Postman, etc...; to query the API.

  • Socket.io

    Realtime application framework (Node.JS server)

  • Naturally, I immediately sought to develop this kind of system in... JavaScript! That's indeed possible, thanks to the WebSocket protocol. In this post, I propose to build, step by step, a (decentralized) P2P network based, not on ExpressJS x SocketIO, nor NestJS (to speed up the project), but directly from Deno πŸ¦•

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • Nest

    A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript πŸš€

  • Naturally, I immediately sought to develop this kind of system in... JavaScript! That's indeed possible, thanks to the WebSocket protocol. In this post, I propose to build, step by step, a (decentralized) P2P network based, not on ExpressJS x SocketIO, nor NestJS (to speed up the project), but directly from Deno πŸ¦•

  • Express

    Fast, unopinionated, minimalist web framework for node.

  • Naturally, I immediately sought to develop this kind of system in... JavaScript! That's indeed possible, thanks to the WebSocket protocol. In this post, I propose to build, step by step, a (decentralized) P2P network based, not on ExpressJS x SocketIO, nor NestJS (to speed up the project), but directly from Deno πŸ¦•

  • deno

    A modern runtime for JavaScript and TypeScript.

  • import { serve } from 'https://deno.land/[email protected]/http/server.ts'; import { urlWrapper } from './utils.ts'; let allPeers = []; let allRecords = []; async function handler(req: Request): Promise { const url = new URL(req.url); // ... socket.onopen = () => console.log('on:open'); socket.onmessage = ({ data }) => { const parsedData = JSON.parse(data); switch (parsedData.type) { case 'HANDSHAKE': const [_, wsUrl] = urlWrapper(parsedData.payload); const wsClient = new WebSocket(wsUrl); wsClient.onopen = () => { allPeers = [...allPeers, wsClient]; }; wsClient.onclose = () => { allPeers = allPeers.filter((client) => { const reUrl = new RegExp(wsUrl); return !reUrl.test(client.url); }); }; break; case 'NEW_RECORD': const foundedRecord = allRecords.find( (record) => record.key === parsedData.payload.key ); if (!foundedRecord) { allRecords = [...allRecords, parsedData.payload]; } break; default: throw new Error(); } }; socket.onclose = () => console.log('on:close'); socket.onerror = () => console.log('on:error'); return response; } serve(handler, { port: 3030 });

  • libcurl

    A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET, TFTP, WS and WSS. libcurl offers a myriad of powerful features

  • Here is the second API to create a new WebSocket client. Explicitly, the user will need to provide the client node's target URL via a REST protocol POST call. When the client is opened (onopen), it is added to the peer list of the current server; on the other hand, when the client is closed (onclose), this same client is removed from the list. Finally, the API returns a simple message with a status 201 (CREATED), or an HTTP 400 code (BAD REQUEST) if the URL value isn't present in the body of the call. Since this is a POST request, it is necessary to use a REST client: cURL, Postman, etc...; to query the API.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts