A Typescript designed project to manage benefit cards among companies and employees
Valex simulates an API that manages a benefit card, generally made available by companies to their employees.
- Get the card balance and transactions
- Create cards
- Activate / Block / Unlock a card
- Recharge a card
- Make card payments with online payment option
GET /card/balance/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
POST /card/create
Headers | Type | Description |
---|---|---|
x-api-key |
string |
Required. api key |
Body | Type | Description |
---|---|---|
employeeId |
integer |
Required. user Id |
type |
string |
Required. type of card benefit |
Valid types: [groceries, restaurant, transport, education, health]
{
"number": "1111 1111 1111 1111",
"name": "NAME N NAME",
"CVC": "111",
"expiration": "01/27",
"type": "card type",
}
number has no defined format
PUT /card/activate/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
Body | Type | Description |
---|---|---|
securityCode |
string |
Required. card cvv |
password |
string |
Required. card password |
Password length: 4
Password pattern: only numbers
Cvc max length: 3
PUT /card/block/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
Body | Type | Description |
---|---|---|
password |
string |
Required. card password |
PUT /card/unlock/:cardId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
Body | Type | Description |
---|---|---|
password |
string |
Required. card password |
POST /card/recharge/:cardId
Headers | Type | Description |
---|---|---|
x-api-key |
string |
Required. api key |
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
Body | Type | Description |
---|---|---|
amount |
integer |
Required. recharge amount |
POST /card/payment/:cardId/:businessId
Params | Type | Description |
---|---|---|
cardId |
integer |
Required. card Id |
businessId |
integer |
Required. business Id |
Body | Type | Description |
---|---|---|
password |
string |
Required. card password |
amount |
integer |
Required. payment amount |
To run this project, you will need to add the following environment variables to your .env file
DATABASE_URL = postgres://UserName:Password@Hostname:5432/DatabaseName
PORT = number #recommended:5000
CRYPTR_SECRET_KEY = any string
Clone the project
git clone https://github.com/tutuezin/projeto18-valex
Go to the project directory
cd projeto18-valex/
Install dependencies
npm install
Create database
cd database
bash ./create-database
cd ../
Start the server
npm start
In this project I learned a lot about how to structure an API with TypeScript
- Arthur Alcantara is a junior full stack developer and student of Information Systems at UFPE and Driven Education.