1.1.5 • Published 5 years ago

real-men v1.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

real-men.png

MEN stack API generator

License Version

Installation

npm i -g real-men

(if npm is not installed you will need Node.js)

Simple example

men test1

The result would be:

Screen-Shot-2019-05-28-at-3-14-50-PM.png

where each controller (only one in this case) will have the typical CRUD functions:

  • GET: getAllFromItem (gets all documents from a given collection)
  • GET: getOneItem (gets only one, given an id)
  • POST: saveNewItem (saves a new document)
  • PUT: updateItem (updates a document)
  • DELETE: deleteItem (deletes a document)

Specifying entities

Many entities can be specified (being an entity the union controller + model + routes) as long as they're separated by commas with no spaces, for instance:

men test1 -e user,cat,cow,coffee

will generate:

Screen-Shot-2019-05-28-at-3-25-52-PM.png

Attributes specification

For a more specific data structure, a configuration file is needed. Such file must have a json extension and it looks like this:

{
  "entities": {
    "user": {
      "name": "String",
      "email": "String",
      "age": "Number"
    },
    "cat": {
      "isItAJerk": "Boolean",
      "catName": "String"
    },
    "cow": {
      "isItHoly": "Boolean",
      "birthday": "Date"
    },
    "coffee": {
      "isDecaf": "Boolean",
      "hasMilk": "Boolean"
    }
  }
}

and instead of this:

men test1 -e user,cat,cow,coffee

the line would be:

men test1 -e customMapping.json

API tester

The API tester will look different depending on the level of detail specified (being the highest the config file). For instance, the one for men test1 -e user,cat,cow,coffee would be:

Screen-Shot-2019-07-10-at-10-49-54-AM.png

and the one for men test1 -e customMapping.json would look like this (note that some data has been added):

Screen-Shot-2019-07-10-at-10-50-40-AM.png

Notes

  • The default entity name is 'Item' and its model has just a string attribute: data
  • Currently, the API tester does have support for String, Number, Date and Boolean types (based on the moongoose SchemaTypes), any type should be functional with the appropriate settings though
  • The config file attribute types must always be strings ("String", "Number", "[]", etc.)
  • If not given, the default database to connect/create will be <your-proyect-name>_DB, to specify a database use --database or -d
  • The default port to run the server is 5501, change it with --port or -p
  • Use --open or -o to automatically open the broswer and test the API
  • Entity names and attributes must match ^[a-zA-Z_][0-9a-zA-Z_]*$
  • Entity names are automatically capitalized
  • Mongo daemon (mongod) must be running to be able to create/connect to the DB
  • More info with men --help
1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago