Reputation: 1532
Currently the Express JS Express application generator supports to generate initial App or we call it a Boilerplate using the npx express-generator
or express myapp
commands based on the Express version and the structure of the app is as below,
app/public/
app/public/javascripts/
app/public/images/
app/public/stylesheets/
app/public/stylesheets/style.css
app/routes/
app/routes/index.js
app/routes/users.js
app/views/
app/views/error.jade
app/views/index.jade
app/views/layout.jade
app/app.js
app/package.json
app/bin/
app/bin/www
Lets say I need to create only a API so in that case I do not need the followings in the generated app;
app/public/javascripts/
app/public/images/
app/public/stylesheets/
app/public/stylesheets/style.css
...
app/views/
app/views/error.jade
app/views/index.jade
app/views/layout.jade
in such cases is there a WAY or COMMAND to generate the App only specified to API APP including packages like body-parser
and without unwanted files and folders that I have mentioned above.
TIA.
Upvotes: 7
Views: 7169
Reputation: 301
My answer is too late, but this could be an interesting option to use.
https://www.npmjs.com/package/express-generator-api
It creates a lightweight express app with all you need to start developing an API using expressjs.
Upvotes: 5
Reputation: 8490
express-generator
does not have such an option. There is some movement towards this.
The "standard" way to bootstrap a new Express application that is optimized for modern Node environments and applications is to roll your own bootstrap/starter project and reuse this.
There are some tools like Cookiecutter out there that claim to help you with this task.
I personally have an my-express-starter
repo which does not include any view engines etc, but middleware for Apis.
Upvotes: 1