A minimal, modular and optionally opinionated library for building microservices


0.0.1-763 years ago3 years agoMinified + gzip package size for @libresat/service in KB


LibreSat Service

A minimal, modular and optionally opinionated library for building microservices for microplatforms based on GraphQL via Apollo Server and MongoDB via Mongoose. If you want to, it allows you to easily use the MTRC (Model - TypeDef - Resolver - Controller) paradigm to make your microservices maintainable and reduce boilerplate to the absolute minimum.

Part of LibreSat


See global README.


First, setup a project directory:

$ mkdir todos
$ cd todos
$ git init
$ npm init

Next, add LibreSat Service and TypeScript:

$ npm i -s @libresat/service
$ npm i -D typescript
$ echo \
  "extends": "./node_modules/@libresat/service/tsconfig.json"
}' > tsconfig.json

Now, add an index.ts and start.ts script:

$ mkdir src/
$ echo \
'import { GraphQLMongoDB as Service, loadPath } from "@libresat/service";

const service = new Service(
  loadPath(__dirname, "typeDefs"),
  loadPath(__dirname, "resolvers")

export { service };
' > src/index.ts
$ echo \
'import { service } from "./index";
const {
  description: pkgDescription,
} = require("../package.json");

const description = `LibreSat Todos

  Usage: libresat-todos [OPTION...]

  -p,     --port            Port to run the GraphQL server on
  -db,    --database-url    MongoDB server to connect to
  -hds,   --headers         Whether to use HTTP headers for authentication or not

Version: ${name}#${version} by ${author}
License: ${license}
More info: ${homepage}`;

service.startWithArgs(description, process.argv);
' > src/start.ts

Nice, you can start adding some MRTCs! Consider checking out LibreSat Identity for a complete example and best practices.

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.