@boilerz/super-server

1.6.42 • Public • Published

@boilerz/super-server

GitHub license GitHub package.json version GH CI Action codecov Typedoc

Express server with type-graphql.

Install

npx install-peerdeps @boilerz/super-server

Usage

import * as superServer from '@boilerz/super-server';
import { Arg, Query, Resolver } from 'type-graphql';

@Resolver()
class GreetingResolver {
  @Query(() => String)
  public hello(@Arg('name') name: string): string {
    return `Hello ${name}`;
  }
}

// Start the server with your resolvers
superServer.start({ resolvers: [GreetingResolver] });

// OR

// For more control on the underlying express app (the server is not automatically started):
const server = superServer.setup({
  graphQLServerOptions: {
    buildSchemaOptions: {
      resolvers: [GreetingResolver],
    },
  },
});

// Express configuration
superServer.getExpressApp().get('/yo', (req, res) => res.send('Yo'));

// Manually start the server
server.listen(process.env.PORT);

Some configuration can only be changed by env vars:

Name Default Description
PORT 3000 Server port.
ALLOWED_DOMAINS /http:\/\/localhost.*/ CORS whitelisted domains (separated using a comma).
SSL_REDIRECT false Have to be set to true to redirect any http request to https.

For the @boilerz/logger's configuration here the readme.

Release

yarn version
yarn build
yarn publish dist --access public

Readme

Keywords

none

Package Sidebar

Install

npm i @boilerz/super-server

Weekly Downloads

1

Version

1.6.42

License

MIT

Unpacked Size

13.6 kB

Total Files

18

Last publish

Collaborators

  • boilerz-tech