@athenna/http
Version:
The Athenna Http server. Built on top of fastify.
34 lines (33 loc) • 973 B
JavaScript
/**
* @athenna/http
*
* (c) João Lenon <lenon@athenna.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { Options } from '@athenna/common';
import { ServiceProvider } from '@athenna/ioc';
import { ServerImpl } from '#src/server/ServerImpl';
export class HttpServerProvider extends ServiceProvider {
register() {
const fastifyOptions = Options.create(Config.get('http.fastify'), {
ajv: {
customOptions: {
coerceTypes: false
}
}
});
this.container.instance('Athenna/Core/HttpServer', new ServerImpl(fastifyOptions));
}
async shutdown() {
const Server = this.container.use('Athenna/Core/HttpServer');
if (!Server) {
return;
}
if (!Server.isListening) {
return;
}
await Server.close();
}
}