@boilerz/super-server
v1.6.42
Published
Super server.
Downloads
66
Readme
@boilerz/super-server
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