Deploy declarative APIs in a few minutes
Create declarative APIs in few minutes
mkdir myapicd myapinpm install --save apibox
Save the following file as config.js
moduleexports ="db": "test" // the name of the MongoDB database"collection": "data" // the name of the MongoDB Collection"documentation": "./docs.yml" // the file where the API is declared"api":"hostname": "localhost""port": 9987"cors":"activate": false // activate Cross-origin resource sharing"hostname": "example.com";
and then document your API entrypoints in your docs.yml (or somewhere else, if you defined another location in your config.js)
resourcePath: /api/v1description: Test API Entrypointapis:- path: /operations:- httpMethod: GETsummary: Get all entriesnotes: All entries will be sent back to the clientresponseClass: Entriesnickname: getAllEntriesconsumes:- application/json- path: /entry/operations:- httpMethod: GETsummary: Get a single entrynotes: Return only one entry objectresponseClass: Entrynickname: getEntryconsumes:- application/jsonparameters:- name: namedescription: The name you are searching forparamType: querydataType: stringrequired: true- httpMethod: POSTsummary: Post a new entrynotes: Return the object "message ok" if workednickname: PostEntryconsumes:- application/jsonparameters:- name: namedescription: The name of the new entryparamType: querydataType: stringmodels:Entry:id: _idproperties:name:type: String
Please refer to the Swagger-core API Declaration specification editing your docs.yml
If you didn't it before, add the folder ./node_modules/.bin to your PATH, so you will be able to access the commands provided by the installed node.js modules.
and finally run the server using
Open your browser at http://localhost:9987/docs (or the domain/port you have choosen) to see it working.
If you want to use the CLI, you can run for example: