npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@arachne/core

v0.3.1

Published

A web framework focused on modularization for web apis focused on GraphQL and Fastify compatibility.

Downloads

1,161

Readme

Build CI Coverage Status

Arachne

A web framework to create GraphQL APIs with Fastify and Mercurius, in a modular and way, with IoC and DI containers to resolve dependencies.

🏗️ STILL UNDER DEVELOPMENT 🚧

About

Arachne is designed to simplify the creation of GraphQL APIs by leveraging the power of Fastify and Mercurius. It promotes a modular architecture, making it easier to manage and scale your application. With built-in Inversion of Control (IoC) and Dependency Injection (DI) containers, Arachne ensures that your dependencies are resolved efficiently and cleanly, leading to more maintainable and testable code. Whether you're building a small project or a large-scale application, Arachne provides the tools and structure needed to develop robust and performant GraphQL APIs.

How to use

Installation

  1. Install @arachne/core, fastify, mercurius and graphql packages
npm i @arachne/core fastify mercurius graphql

Usage

  1. Create Modules: Define your modules with services and resolvers.
// auth.module.ts
import { Injectable, Query, Mutation, Resolver, Module } from '@arachne/core'

@Injectable()
class AuthService {
  signIn() {
    return true
  }

  signOut() {
    return true
  }

  register() {
    return {
      id: 1,
      name: 'Alice'
    }
  }
}

@Resolver()
export class AuthResolver {
  constructor(private authService: AuthService) {}

  @Query()
  signIn() {
    return this.authService.signIn()
  }

  @Mutation()
  signOut() {
    return this.authService.signOut()
  }

  @Mutation()
  register() {
    return this.authService.register()
  }
}

@Module({
  schema: `
    type Query {
      signIn: Boolean
    }

    type Mutation {
      signOut: Boolean
      register: User
    }

    type User {
      id: ID
      name: String
    }
  `,
  providers: [AuthService],
  resolvers: [AuthResolver]
})
export class AuthModule {}
  1. Combine Modules: Import your modules into the main application module.
// app.module.ts
import { Module } from '@arachne/core'

import { AuthModule } from '@/modules/auth/auth.module'
import { UsersModule } from '@/modules/users/users.module'

@Module({
  imports: [UsersModule, AuthModule]
})
export class AppModule {}
  1. Start the Application: Initialize and start your Fastify server with the application module.
// index.ts
import Fastify from 'fastify'
import mercurius, { MercuriusOptions } from 'mercurius'

import { createApp } from '@arachne/core'

import { AppModule } from '@/app/app.module'

async function startupServer() {
  const fastify = Fastify()

  const app = await createApp(AppModule)

  app.setServer(fastify)

  app.use(async ({ server, graphqlContext }) => {
    server.register(mercurius, {
      ...graphqlContext,
      graphiql: true,
      path: '/api/graphql', // To access http://localhost:5000/api/graphql to consume data
      allowBatchedQueries: true
    } as MercuriusOptions)
  })

  await app.listen(5000)
}

startupServer()

Now you have a running GraphQL API with Fastify and Mercurius using a modular architecture.

Running app

Running the Server

  1. Ensure you have all the necessary dependencies installed. You can install them using:

    npm install
  2. Start the server by running:

    npm start
  3. Once the server is running, you can access the GraphiQL playground (if enabled) by navigating to:

    http://localhost:PORT/graphiql # or path passed on mercurius config

    Replace PORT with the actual port number your server is configured to use.