crolopez / invoice-api-rest

Simple API Rest to manage invoices for testing purposes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invoice API REST

Simple API REST to manage invoices with the purpose of gaining knowledge about CI/CD and serverless applications in Azure.

Prerequisites

How to deploy

Just execute:

yarn install
yarn build
yarn start

You can check an Azure Pipeline example about how to generate the artifact here.

Configuration

It is necessary to set the MONGODB_TOKEN environment variable with a MongoDB connection string in order to manage the status of the invoices.

RESTful API

Register an invoice

Request:

POST /api/

curl -i -H 'Content-Type: application/json' http://localhost:7071/api/ \
-d '{ "invoiceId": "891248192B", "supplier": "Fake supplier", "dateIssued": "2019-10-10 13:30:01 T+0210", "currency": "EUR", "amount": 1000.00, "description": "New projector for confenrece room" }'

Response:

{
    "success": true
}

Get invoices

Request:

GET /api/

curl -i -H 'Content-Type: application/json' http://localhost:7071/api/'

Response:

{
    "success": true,
    "invoices": [<list of invoices>]
}

Get an invoice

Request:

GET /api/<invoiceID>

curl -i -H 'Content-Type: application/json' http://localhost:7071/api/<invoiceID>'

Response:

{
    "success": true,
    "invoices": [<requested invoice>]
}

Delete an invoice

Request:

DELETE /api/<invoiceID>

curl -X DELETE -i -H 'Content-Type: application/json' http://localhost:7071/api/<invoiceID>'

Response:

{
    "success": true
}

About

Simple API Rest to manage invoices for testing purposes.

License:GNU General Public License v3.0


Languages

Language:TypeScript 88.6%Language:JavaScript 11.4%