[英]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,目前 Express JS Express 应用程序生成器支持生成初始 App 或者我们称之为Boilerplate使用 npx
npx express-generator
或express myapp
命令基于 Express 版本,应用程序的结构如下,
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;假设我只需要创建一个 API 所以在这种情况下我不需要生成的应用程序中的以下内容;
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.在这种情况下,是否有一种方式或命令来生成仅指定给API APP 的应用程序,包括像
body-parser
这样的包,并且没有我上面提到的不需要的文件和文件夹。
TIA. TIA。
express-generator
does not have such an option. express-generator
没有这样的选项。 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.引导针对现代 Node 环境和应用程序优化的新 Express 应用程序的“标准”方法是滚动您自己的引导程序/启动器项目并重用它。
There are some tools like Cookiecutter out there that claim to help you with this task.有一些像Cookiecutter这样的工具声称可以帮助您完成这项任务。
I personally have an my-express-starter
repo which does not include any view engines etc, but middleware for Apis.我个人有一个
my-express-starter
存储库,其中不包括任何视图引擎等,而是用于 APIs 的中间件。
My answer is too late, but this could be an interesting option to use.我的回答为时已晚,但这可能是一个有趣的选择。
https://www.npmjs.com/package/express-generator-api 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.它创建了一个轻量级的 express 应用程序,您可以使用 expressjs 开始开发 API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.