2021-09-23 11:25:46 +00:00
|
|
|
//
|
|
|
|
// Copyright 2021 Vulcanize, Inc.
|
|
|
|
//
|
|
|
|
|
|
|
|
import fs from 'fs';
|
|
|
|
import path from 'path';
|
|
|
|
import Handlebars from 'handlebars';
|
|
|
|
import { Writable } from 'stream';
|
|
|
|
|
|
|
|
const TEMPLATE_FILE = './templates/server-template.handlebars';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes the server file generated from a template to a stream.
|
|
|
|
* @param outStream A writable output stream to write the server file to.
|
|
|
|
*/
|
2022-11-28 06:31:28 +00:00
|
|
|
export function exportServer (outStream: Writable): void {
|
2021-09-23 11:25:46 +00:00
|
|
|
const templateString = fs.readFileSync(path.resolve(__dirname, TEMPLATE_FILE)).toString();
|
|
|
|
const template = Handlebars.compile(templateString);
|
2022-11-28 06:31:28 +00:00
|
|
|
const server = template({});
|
2021-09-23 11:25:46 +00:00
|
|
|
outStream.write(server);
|
|
|
|
}
|