@ancxkush/create-ts-express-mongo-starter-code
Version:
NodeJS/Express starter code with - TypeScript, MongoDB setup, Exception Handler, Logger, HTTP testing example, Swagger Docs example, Mongoose model example, JOI validation example, CRUD operations example
183 lines (182 loc) • 3.93 kB
JSON
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "TS-Express-Mongo Starter Code",
"description": "NodeJS/Express starter code with - TypeScript, MongoDB setup, Exception Handler, Logger, HTTP testing example, Swagger Docs example, Mongoose model example, JOI validation example, CRUD operations example",
"contact": {
"author": "Ankush Kunwar",
"email": "ank.knr@gmail.com"
}
},
"host": "localhost:5800",
"basePath": "/api",
"schemes": ["http"],
"consumes": ["application/json"],
"produces": ["application/json"],
"paths": {
"/books": {
"get": {
"description": "Returns all books",
"operationId": "findBooks",
"produces": ["application/json"],
"responses": {
"200": {
"description": "Book response",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/Book"
}
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
},
"post": {
"description": "Creates a new book",
"operationId": "addBook",
"produces": ["application/json"],
"parameters": [
{
"name": "Book",
"in": "body",
"description": "Book to add to the store",
"required": true,
"schema": {
"$ref": "#/definitions/NewBook"
}
}
],
"responses": {
"201": {
"description": "Book response",
"schema": {
"$ref": "#/definitions/Book"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
},
"/books/{bookId}": {
"get": {
"description": "Returns a user based on a single ID, if the user does not have access to the Book",
"operationId": "findBookById",
"produces": [
"application/json",
"application/xml",
"text/xml",
"text/html"
],
"parameters": [
{
"name": "bookId",
"in": "path",
"description": "ID of Book to fetch",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "Book response",
"schema": {
"$ref": "#/definitions/Book"
}
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
},
"delete": {
"description": "deletes a single book based on the bookId supplied",
"operationId": "deleteBook",
"parameters": [
{
"name": "bookId",
"in": "path",
"description": "bookId of book to delete",
"required": true,
"type": "integer",
"format": "int64"
}
],
"responses": {
"200": {
"description": "Book deleted"
},
"default": {
"description": "unexpected error",
"schema": {
"$ref": "#/definitions/ErrorModel"
}
}
}
}
}
},
"definitions": {
"Book": {
"type": "object",
"allOf": [
{
"$ref": "#/definitions/NewBook"
},
{
"required": ["_id"],
"properties": {
"_id": {
"type": "string"
}
}
}
]
},
"NewBook": {
"type": "object",
"required": ["bookId", "name", "price"],
"properties": {
"bookId": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string"
},
"price": {
"type": "integer",
"format": "int32"
}
}
},
"ErrorModel": {
"type": "object",
"required": ["code", "message"],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
}
}