最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - NODEJS Express application generator for API - Stack Overflow

programmeradmin1浏览0评论

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 mands 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.

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 mands 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.

Share Improve this question asked Oct 2, 2019 at 4:20 mapmathmapmath 1,53222 silver badges41 bronze badges 3
  • 1 No, express-generator generates a plete application including views/styles. You need to manually remove the files. You would only need to do this once ever for an application, what issue are you specifically running into? – Alexander Staroselsky Commented Oct 2, 2019 at 4:29
  • 1 If you really need to achieve this then you can go with shell script. It will help you much at certain level. – Sachin Shah Commented Oct 2, 2019 at 5:58
  • @AlexanderStaroselsky There is no specific issues I am running into but wanted to know if there is standard way of achieving this. – mapmath Commented Oct 2, 2019 at 6:37
Add a ment  | 

2 Answers 2

Reset to default 5

My answer is too late, but this could be an interesting option to use.

https://www.npmjs./package/express-generator-api

It creates a lightweight express app with all you need to start developing an API using expressjs.

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.

发布评论

评论列表(0)

  1. 暂无评论