Skip to content

Commit

Permalink
feat(node): add templates for nodejs frameworks (#14231)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndcunningham authored Jan 10, 2023
1 parent a806fee commit 6fb0631
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
15 changes: 1 addition & 14 deletions packages/node/src/generators/application/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function addProject(tree: Tree, options: NormalizedSchema) {
targets: {},
tags: options.parsedTags,
};

project.targets.build =
options.bundler === 'esbuild'
? getEsBuildConfig(project, options)
Expand Down Expand Up @@ -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[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -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
})
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>, () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
Original file line number Diff line number Diff line change
@@ -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
});

0 comments on commit 6fb0631

Please sign in to comment.