简体   繁体   中英

NODEJS Express application generator for API

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM