Framework

Framework on GitHub

Create enterprise level server-side TypeScript applications. For REST, GraphQL, and Microservices.

GraphQL

GraphQL on GitHub

Write Apollo GraphQL resolvers in a OOP fashion with TypeScript decorators.

IoC Container

IoC Container on GitHub

Lightweight Inversion of Control and Dependency Injection for TypeScript applications.

Message Broker

Message Broker on GitHub

TCP-based Redis-like Pub/Sub type of message broker, almost configuration-less.

Framework

Node.js framework for backend applications.

  • ModularModular
  • Setup REST endpoints in no timeSetup REST endpoints in no time
  • MicroservicesMicroservices
$ npx peque new project-name
import { Controller, Get, Module, PequeFactory } from '@pequehq/framework';

@Controller('/test')
class MyController {
  @Get('/hello')
  hello() {
    return { test: 'hello world' };
  }
}

@Module({ controllers: [MyController] })
class MyModule {}

const webserver = PequeFactory.createServer({
  cors: true,
  isCpuClustered: false,
  rootModule: MyModule,
});

webserver.start();

GraphQL

OOP transposition of Apollo Server resolvers.

  • Code resolvers in an OOP fashionCode resolvers in an OOP fashion
  • Use decorators like @Query() and @Mutation()Use decorators like @Query() and @Mutation()
  • Easy testableEasy testable
$ npm i @pequehq/graphql reflect-metadata
import { Resolver, ResolverService } from '@pequehq/graphql';

@Resolver()
class ResolverExample {
  @Query()
  countries(@Args('continent') continent: string): unknown {
    return [
      { id: 1, name: 'italy', continent: 'europe' },
      { id: 2, name: 'spain', continent: 'europe' },
      { id: 3, name: 'china', continent: 'asia' },
    ].filter((country) => country.continent === continent);
  }
}

const resolverService = new ResolverService();

const resolvers = resolverService.get([new ResolverExample()]);

// Add resolvers to your Apollo Server.

IoC Container

TypeScript Dependency Injection.

  • Easy dependency injectionEasy dependency injection
  • Use it in backend or frontend appsUse it in backend or frontend apps
  • Full TypeScript supportFull TypeScript support
$ npm i @pequehq/di reflect-metadata
import { Container, Injectable } from '@pequehq/di';

@Injectable()
class Foo {
  getPizza() {
    return 'pizza';
  }
}

@Injectable()
class Bar {
  constructor(private foo: Foo) {}
  
  test() {
    console.log(this.foo.getPizza())
  }
}

const DI = new Container();

DI.set(Foo, 'Foo');
DI.set(Bar, 'Bar');

DI.get<Bar>('Bar').test(); // prints "pizza"

Message Broker

TCP-based Message Broker.

  • Event-drivenEvent-driven
  • Lightweight client dependency (< 100 KB)Lightweight client dependency (< 100 KB)
  • Almost configuration-lessAlmost configuration-less
$ npx peque add smb
import { BrokerFactory } from '@pequehq/smb-broker';

const broker = new BrokerFactory().createBroker();

broker.create().then(() => {
  // things.
});
import { BrokerClientFactory } from '@pequehq/smb-client';

const client = new BrokerClientFactory().make();

await client.connect({ connectionTimeout: 10000 });

client.subscribe('^topic', (command) => {
  console.log(command.action.message); // prints {"test":"message"}
});

client.message('topic', { test: 'message' });