Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): add templates for nodejs frameworks #14231

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
});