- 
                Notifications
    You must be signed in to change notification settings 
- Fork 71
feat: added Helia Remix example #368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            paschal533
  wants to merge
  10
  commits into
  ipfs-examples:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
paschal533:Remix-example
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      938bc56
              
                feat: added Helia Remix example
              
              
                paschal533 285ab33
              
                Updated ci.yml
              
              
                paschal533 8cf013a
              
                Update examples/helia-remix/components/ipfs.tsx
              
              
                paschal533 d34d625
              
                Update examples/helia-remix/components/ipfs.tsx
              
              
                paschal533 99b87b1
              
                feat: add test and eslint
              
              
                paschal533 e1b372a
              
                feat: add test and eslint
              
              
                paschal533 bbfcea3
              
                refactor: remove entry.server.tsx and entry.client.tsx files
              
              
                paschal533 4a3ecff
              
                Update examples/helia-remix/components/helia.tsx
              
              
                paschal533 ca81e17
              
                Update examples/helia-remix/components/helia.tsx
              
              
                paschal533 853d993
              
                Update ci.yml
              
              
                paschal533 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| /** | ||
|         
                  paschal533 marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| * This is intended to be a basic starting point for linting in your app. | ||
| * It relies on recommended configs out of the box for simplicity, but you can | ||
| * and should modify this configuration to best suit your team's needs. | ||
| */ | ||
|  | ||
| /** @type {import('eslint').Linter.Config} */ | ||
| module.exports = { | ||
| root: true, | ||
| parserOptions: { | ||
| ecmaVersion: "latest", | ||
| sourceType: "module", | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| }, | ||
| env: { | ||
| browser: true, | ||
| commonjs: true, | ||
| es6: true, | ||
| }, | ||
| ignorePatterns: ["!**/.server", "!**/.client"], | ||
|  | ||
| // Base config | ||
| extends: ["eslint:recommended", "ipfs"], | ||
|  | ||
| overrides: [ | ||
| // React | ||
| { | ||
| files: ["**/*.{js,jsx,ts,tsx}"], | ||
| plugins: ["react", "jsx-a11y"], | ||
| extends: [ | ||
| "plugin:react/recommended", | ||
| "plugin:react/jsx-runtime", | ||
| "plugin:react-hooks/recommended", | ||
| "plugin:jsx-a11y/recommended", | ||
| ], | ||
| settings: { | ||
| react: { | ||
| version: "detect", | ||
| }, | ||
| formComponents: ["Form"], | ||
| linkComponents: [ | ||
| { name: "Link", linkAttribute: "to" }, | ||
| { name: "NavLink", linkAttribute: "to" }, | ||
| ], | ||
| "import/resolver": { | ||
| typescript: {}, | ||
| }, | ||
| }, | ||
| }, | ||
|  | ||
| // Typescript | ||
| { | ||
| files: ["**/*.{ts,tsx}"], | ||
| plugins: ["@typescript-eslint", "import"], | ||
| parser: "@typescript-eslint/parser", | ||
| settings: { | ||
| "import/internal-regex": "^~/", | ||
| "import/resolver": { | ||
| node: { | ||
| extensions: [".ts", ".tsx"], | ||
| }, | ||
| typescript: { | ||
| alwaysTryTypes: true, | ||
| }, | ||
| }, | ||
| }, | ||
| extends: [ | ||
| "plugin:@typescript-eslint/recommended", | ||
| "plugin:import/recommended", | ||
| "plugin:import/typescript", | ||
| "ipfs" | ||
| ], | ||
| }, | ||
|  | ||
| // Node | ||
| { | ||
| files: [".eslintrc.cjs"], | ||
| env: { | ||
| node: true, | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| node_modules | ||
|  | ||
| /.cache | ||
| /build | ||
| .env | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| <p align="center"> | ||
| <a href="https://github.com/ipfs/helia" title="Helia"> | ||
| <img src="https://raw.githubusercontent.com/ipfs/helia/main/assets/helia.png" alt="Helia logo" width="300" /> | ||
| </a> | ||
| </p> | ||
|  | ||
| <h3 align="center"><b>Using Helia inside a Remix app</b></h3> | ||
|  | ||
| <p align="center"> | ||
| <img src="https://raw.githubusercontent.com/jlord/forkngo/gh-pages/badges/cobalt.png" width="200"> | ||
| <br> | ||
| <a href="https://ipfs.github.io/helia/modules/helia.html">Explore the docs</a> | ||
| · | ||
| <a href="https://codesandbox.io/">View Demo</a> | ||
| · | ||
| <a href="https://github.com/ipfs-examples/helia-examples/issues">Report Bug</a> | ||
| · | ||
| <a href="https://github.com/ipfs-examples/helia-examples/issues">Request Feature/Example</a> | ||
| </p> | ||
|  | ||
| ## Table of Contents | ||
|  | ||
| See https://github.com/ipfs-examples/helia-examples#table-of-contents for more information about Helia examples. | ||
|  | ||
| ## Getting Started | ||
|  | ||
| ### Prerequisites | ||
|  | ||
| https://github.com/ipfs-examples/helia-examples#prerequisites | ||
|  | ||
| ### Installation and Running example | ||
|  | ||
| ```console | ||
| > npm install | ||
| > npm run dev | ||
| ``` | ||
|  | ||
| Now open your browser at `http://localhost:5173/` | ||
|  | ||
| ### Available Scripts | ||
|  | ||
| In the project directory, you can run: | ||
|  | ||
| #### `npm run dev` | ||
|  | ||
| Runs the app in the development mode.<br> | ||
| Open [http://localhost:5173/](http://localhost:5173/) to view it in the browser. | ||
|  | ||
| The page will reload if you make edits.<br> | ||
| You will also see any lint errors in the console. | ||
|  | ||
| #### `npm run build` | ||
|  | ||
| Builds the app for production to the `dist` folder.<br> | ||
| It correctly bundles in production mode and optimizes the build for the best performance. | ||
|  | ||
| ## Usage | ||
|  | ||
| This is a [Remix.js](https://remix.run/) project bootstrapped with [`create-remix@latest`](https://github.com/remix-run/remix/blob/main/packages/create-remix) integrated with `helia`. | ||
|  | ||
| You can start editing the page by modifying `app/routes/_index.tsx`. The page auto-updates as you edit the file. | ||
|  | ||
| ### Learn More | ||
|  | ||
| To learn more about Next.js, take a look at the following resources: | ||
|  | ||
| - [Remix Documentation](https://remix.run/docs/en/main) - learn about Remix features and API. | ||
| - [Learn Remix](https://remix.run/docs/en/main/start/tutorial) - an interactive Remix tutorial. | ||
|  | ||
| You can check out [the Remix GitHub repository](https://github.com/remix-run/remix) - your feedback and contributions are welcome! | ||
|  | ||
| ### Deploy on Vercel | ||
|  | ||
| The easiest way to deploy your Remix app is to use the [Vercel Platform](https://vercel.com/guides/deploying-remix-with-vercel). | ||
|  | ||
| Check out our [Remix deployment documentation](https://vercel.com/docs/frameworks/remix) for more details. | ||
|  | ||
| _For more examples, please refer to the [Documentation](https://github.com/ipfs-examples/helia-examples#documentation)_ | ||
|  | ||
| ## Documentation | ||
|  | ||
| - [IPFS Primer](https://dweb-primer.ipfs.io/) | ||
| - [IPFS Docs](https://docs.ipfs.io/) | ||
| - [Tutorials](https://proto.school) | ||
| - [More examples](https://github.com/ipfs-examples/helia-examples) | ||
| - [API - Helia](https://ipfs.github.io/helia/modules/helia.html) | ||
| - [API - @helia/unixfs](https://ipfs.github.io/helia-unixfs/modules/helia.html) | ||
|  | ||
| ## Contributing | ||
|  | ||
| Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**. | ||
|  | ||
| 1. Fork the IPFS Project | ||
| 2. Create your Feature Branch (`git checkout -b feature/amazing-feature`) | ||
| 3. Commit your Changes (`git commit -a -m 'feat: add some amazing feature'`) | ||
| 4. Push to the Branch (`git push origin feature/amazing-feature`) | ||
| 5. Open a Pull Request | ||
|  | ||
| ## Want to hack on IPFS? | ||
|  | ||
| [](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) | ||
|  | ||
| The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out: | ||
|  | ||
| Read the [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md) and [JavaScript Contributing Guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md). | ||
|  | ||
| - **Check out existing issues** The [issue list](https://github.com/ipfs/helia/issues) has many that are marked as ['help wanted'](https://github.com/ipfs/helia/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3A%22help+wanted%22) or ['difficulty:easy'](https://github.com/ipfs/helia/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc+label%3Adifficulty%3Aeasy) which make great starting points for development, many of which can be tackled with no prior IPFS knowledge | ||
| - **Look at the [Helia Roadmap](https://github.com/ipfs/helia/blob/main/ROADMAP.md)** This are the high priority items being worked on right now | ||
| - **Perform code reviews** More eyes will help | ||
| a. speed the project along | ||
| b. ensure quality, and | ||
| c. reduce possible future bugs | ||
| - **Add tests**. There can never be enough tests | ||
|  | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const createHelia = jest.fn().mockResolvedValue({ | ||
| libp2p: { | ||
| peerId: { toString: () => 'mock-peer-id' }, | ||
| status: 'started' | ||
| } | ||
| }); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { initHelia } from "../components/helia"; | ||
|  | ||
| describe('initialize Helia', () => { | ||
| it('checks if HeliaNode has started', async () => { | ||
|  | ||
| const { heliaNode } = await initHelia(); | ||
|  | ||
| expect(heliaNode.libp2p.status).toEqual('started'); | ||
| }) | ||
|  | ||
| it('checks if there is a nodeId', async () => { | ||
|  | ||
| const { nodeId } = await initHelia(); | ||
|  | ||
| expect(nodeId).toEqual('mock-peer-id'); | ||
| }) | ||
|  | ||
| it('checks if nodeId is online', async () => { | ||
|  | ||
| const { nodeIsOnline } = await initHelia(); | ||
|  | ||
| expect(nodeIsOnline).toBe(true); | ||
| }) | ||
| }) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { | ||
| Links, | ||
| Meta, | ||
| Outlet, | ||
| Scripts, | ||
| ScrollRestoration, | ||
| } from "@remix-run/react"; | ||
| import type { LinksFunction } from "@remix-run/node"; | ||
|  | ||
| import "./tailwind.css"; | ||
|  | ||
| export const links: LinksFunction = () => [ | ||
| { rel: "preconnect", href: "https://fonts.googleapis.com" }, | ||
| { | ||
| rel: "preconnect", | ||
| href: "https://fonts.gstatic.com", | ||
| crossOrigin: "anonymous", | ||
| }, | ||
| { | ||
| rel: "stylesheet", | ||
| href: "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap", | ||
| }, | ||
| ]; | ||
|  | ||
| export function Layout({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charSet="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <Meta /> | ||
| <Links /> | ||
| </head> | ||
| <body> | ||
| {children} | ||
| <ScrollRestoration /> | ||
| <Scripts /> | ||
| </body> | ||
| </html> | ||
| ); | ||
| } | ||
|  | ||
| export default function App() { | ||
| return <Outlet />; | ||
| } | 
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.