diff --git a/packages/node/src/generators/application/application.ts b/packages/node/src/generators/application/application.ts index 07293e4615320..34ddf6985a667 100644 --- a/packages/node/src/generators/application/application.ts +++ b/packages/node/src/generators/application/application.ts @@ -118,6 +118,7 @@ function addProject(tree: Tree, options: NormalizedSchema) { targets: {}, tags: options.parsedTags, }; + project.targets.build = options.bundler === 'esbuild' ? getEsBuildConfig(project, options) @@ -292,20 +293,6 @@ function updateTsConfigOptions(tree: Tree, options: NormalizedSchema) { } export async function applicationGenerator(tree: Tree, schema: Schema) { - // Prompt for bundler webpack / esbuild - if (schema.framework) { - schema.bundler = ( - await prompt<{ bundler: 'esbuild' | 'webpack' }>([ - { - message: 'What bundler would you like to use?', - type: 'select', - name: 'bundler', - choices: ['esbuild', 'webpack'], - }, - ]) - ).bundler; - } - const options = normalizeOptions(tree, schema); const tasks: GeneratorCallback[] = []; diff --git a/packages/node/src/generators/application/files/connect/src/main.ts__tmpl__ b/packages/node/src/generators/application/files/connect/src/main.ts__tmpl__ new file mode 100644 index 0000000000000..51ff1d4c91e9d --- /dev/null +++ b/packages/node/src/generators/application/files/connect/src/main.ts__tmpl__ @@ -0,0 +1,11 @@ +import connect from 'connect'; + +const app = connect(); + +app.use((req, res) => { + res.end(JSON.stringify({ 'message': 'Hello API' })); +}); + +app.listen(<%= port %>, () => { + // Server is running +}) \ No newline at end of file diff --git a/packages/node/src/generators/application/files/express/src/main.ts__tmpl__ b/packages/node/src/generators/application/files/express/src/main.ts__tmpl__ index 8c7daef188233..4b3ab24cd7340 100644 --- a/packages/node/src/generators/application/files/express/src/main.ts__tmpl__ +++ b/packages/node/src/generators/application/files/express/src/main.ts__tmpl__ @@ -3,7 +3,7 @@ const app = express(); app.get('/', (req, res) => { - res.send('Hello from Nrwl 🐳 API'); + res.send({ 'message': 'Hello API'}); }); app.listen(<%= port %>, () => { diff --git a/packages/node/src/generators/application/files/fastify/src/main.ts__tmpl__ b/packages/node/src/generators/application/files/fastify/src/main.ts__tmpl__ new file mode 100644 index 0000000000000..578ded217b4bb --- /dev/null +++ b/packages/node/src/generators/application/files/fastify/src/main.ts__tmpl__ @@ -0,0 +1,18 @@ +import fastify from 'fastify'; + +const app = fastify(); + +app.get('/', async (req, res) => { + return { 'message': 'Hello API'}; +}); + +const start = async() => { + try { + await app.listen({ port: <%= port %> }) + } catch (err) { + // Errors are logged here + process.exit(1); + } +} + +start(); \ No newline at end of file diff --git a/packages/node/src/generators/application/files/koa/src/main.ts__tmpl__ b/packages/node/src/generators/application/files/koa/src/main.ts__tmpl__ new file mode 100644 index 0000000000000..0266c0862196d --- /dev/null +++ b/packages/node/src/generators/application/files/koa/src/main.ts__tmpl__ @@ -0,0 +1,11 @@ +import koa from 'koa'; + +const app = new koa(); + +app.use(async ctx =>{ + ctx.body = { 'message': 'Hello API'}; +}); + +app.listen(<%= port %>, () => { + // Server is running +}); \ No newline at end of file