1.0.2 โข Published 5 years ago
@thebinaryfelix/create-iron-api v1.0.2
๐ฆ create-iron-api
A simple base structure for designing a REST API.
This package creates a simple API demo, using as context an API that serves data about galaxies. If you wish to know more about this demo, you can check it out on @thebinaryfelix/galaxies-api-demo.
โ๏ธ Installation & Usage
$ npm init @thebinaryfelix/iron-api
# or
$ npx @thebinaryfelix/create-iron-api
# or
$ npm install -g @thebinaryfelix/create-iron-api
$ create-iron-api
Quick Start
Create the project with default name iron-api
and install dependencies:
$ create-iron-api --yes --install
๐กUse a custom folder name and install dependencies manually:
$ create-iron-api project-name
$ cd project-name
$ npm install
๐ Run the created project
On project-name
root folder
$ npm start
Open http://localhost:3000/api-docs
to see API documentation.
๐ด Important
For this demo API to work properly, you need MongoDB Community Edition ^4.2 running on your machine.
Command Line Options
This generator can also be configured with the following flags.
-g, --git initialize Git
-i, --install install dependencies
-y, --yes skip prompts
๐งฉ Project structure
iron-api/
โโโ api
โ โโโ config
โ โ โโโ swagger.js
โ โโโ controllers
โ โ โโโ galaxy.controller.js
โ โโโ models
โ โ โโโ galaxy.model.js
โ โ โโโ response.model.js
โ โโโ routes
โ โ โโโ galaxy.routes.js
โ โ โโโ index.js
โ โโโ app.js
โโโ bin
โ โโโ www
โโโ package.json
โโโ prettier.config.js
โโโ .prettierignore
โโโ .eslintrc.js
โโโ .eslintignore
โโโ .gitignore
๐ References
- How to build a CLI with Node.js - by Dominik Kundel
- express-generator
- @thebinaryfelix/galaxies-api-demo
๐ง Next steps
๐งช Tests
- Add unitary tests to:
- src/
- cli.js
- main.js
- template/api
- controllers/*
- models/*
- routes/*
- app.js
- src/