An open API service indexing awesome lists of open source software.

https://github.com/thalesgomest/drivenpass-api

DrivenPass is your newest password manager, where you can save data such as: credentials, networks, notes and cards
https://github.com/thalesgomest/drivenpass-api

backend nodejs prisma

Last synced: about 2 months ago
JSON representation

DrivenPass is your newest password manager, where you can save data such as: credentials, networks, notes and cards

Awesome Lists containing this project

README

          

## ๐Ÿ“‘ Contents

- [Project Description](#-project-description)
- [Status of work](#-status-of-work)
- [Features](#โœ…-features)
- [API Documentation](#๐Ÿ“ฎ-api-documentation)
- [Enviroment Variables](#๐Ÿ”‘-environment-variables)
- [How to run](#%EF%B8%8F-how-to-run)
- [Build with](#%EF%B8%8F-build-with)
- [Contact](#-contact)

## ๐Ÿ“Œ Project Description


Browsing the internet can be a very fun activity, but at the same time, very dangerous. Numerous studies and surveys (national and international) show that the number of virtual scams continues to grow. Which raises the question: how to protect ourselves?
There are several different ways to protect yourself. It all starts with using different and secure passwords. For a password to be security, it must contain several characters and numbers mixed in, not to mention that the longer it ii, etc.
But how are we going to memorize giant passwords with no semantic meaning? It is to solve this pain that password managers were created! With them,
we only create one โ€œmasterโ€ password and all other passwords kept secret! So when we need it, just remember the โ€œmasterโ€ password! DrivenPass is your newest password manager, where you can save data such as: credentials, networks, notes and cards

## ๐Ÿšง Status of work

![status](https://img.shields.io/badge/Status-Finished-00920F?style=plastic)

## โœ… Features

- [x] Sign In and Sign Up account
- [x] Create/Get/Delete Credentials
- [x] Create/Get/Delete Notes
- [x] Create/Get/Delete Networks
- [x] Create/Get/Delete Bank Cards

## ๐Ÿ“ฎ API Documentation

### ๐Ÿ”Authentication

### Sign Up

```http
POST /auth/signup
```

#### Request:

| Body | Type | Description |
| :---------------- | :------- | :--------------------------- |
| `name` | `string` | **Required** โ†’ user name |
| `email` | `string` | **Required** โ†’ user email |
| `password` | `string` | **Required** โ†’ user password |
| `confirmPassword` | `string` | **Required** โ†’ user password |

`Password length min(10)`

#

#### Response:

```json
{
"message": "user created"
}
```

### Sign In

```http
POST /auth/signin
```

#### Request:

| Body | Type | Description |
| :------ | :------- | :------------------------ |
| `name` | `string` | **Required** โ†’ user name |
| `email` | `string` | **Required** โ†’ user email |

#

#### Response:

```json
{
"token": "jasonwebtoken (JWT)"
}
```

### ๐Ÿ‘ค Credentials

### Create a credential

```http
POST /credentials/${userId}/create
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

| Body | Type | Description |
| :--------- | :------- | :--------------------------------- |
| `url` | `string` | **Required** โ†’ credential url |
| `username` | `string` | **Required** โ†’ user name |
| `password` | `string` | **Required** โ†’ credential password |
| `title` | `string` | **Required** โ†’ credential password |

#

#### Response:

```json
{
"message": "credential created"
}
```

#

### Get all credentials by userId

```http
GET /credentials/${userId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"credentials": [
{
"id": 3,
"url": "http://ultimate-certification.name",
"username": "LorenzoFranco_Batista",
"password": "v7GcM",
"title": "Unifei",
"createdAt": "2022-07-18T19:46:40.846Z",
"userId": 2
}
]
}
```

#

### Get a specific credential by userId and credentialId

```http
GET /credentials/${userId}/${credentialId}
```

#### Request:

| Params | Type | Description |
| :------------- | :-------- | :--------------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `credentialId` | `integer` | **Required** โ†’ credential Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"credential": [
{
"id": 3,
"url": "http://ultimate-certification.name",
"username": "LorenzoFranco_Batista",
"password": "v7GcM",
"title": "Unifei",
"createdAt": "2022-07-18T19:46:40.846Z",
"userId": 2
}
]
}
```

#

### Delete a specific credential by credentialId

```http
DELETE /credentials/${userId}/${credentialId}
```

#### Request:

| Params | Type | Description |
| :------------- | :-------- | :--------------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `credentialId` | `integer` | **Required** โ†’ credential Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"message": "credential deleted"
}
```

#

### ๐Ÿ“ Secrete Notes

### Create a note

```http
POST /notes/${userId}/create
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

| Body | Type | Description |
| :-------- | :------- | :-------------------------- |
| `title` | `string` | **Required** โ†’ note title |
| `content` | `string` | **Required** โ†’ note content |

`title length min(50) and max(1000)`

#### Response:

```json
{
"message": "credential created"
}
```

#

### Get all notes by userId

```http
GET /notes/${userId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"notes": [
{
"id": 1,
"title": "consequatur",
"content": "Ratione suscipit nihil quia dolore sunt minima omnis.",
"createdAt": "2022-07-18T13:02:20.263Z",
"userId": 2
}
]
}
```

#

### Get a specific note by userId and noteId

```http
GET /notes/${userId}/${noteId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `noteId` | `integer` | **Required** โ†’ note Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"note": {
"id": 1,
"title": "consequatur",
"content": "Ratione suscipit nihil quia dolore sunt minima omnis.",
"createdAt": "2022-07-18T13:02:20.263Z",
"userId": 2
}
}
```

#

### Delete a specific note by noteId

```http
DELETE /notes/${userId}/${notesId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `noteId` | `integer` | **Required** โ†’ note Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"message": "Note deleted"
}
```

#

### ๐Ÿ’ณ Cards

### Create a card

```http
POST /cards/${userId}/create
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

| Body | Type | Description |
| :--------------- | :-------- | :------------------------------------- |
| `title` | `string` | **Required** โ†’ card title |
| `number` | `string` | **Required** โ†’ card number |
| `cardholderName` | `string` | **Required** โ†’ card holder name |
| `securityCode` | `string` | **Required** โ†’ user card security code |
| `expirationDate` | `string` | **Required** โ†’ card expiration date |
| `password` | `string` | **Required** โ†’ card password |
| `isVirtual` | `boolean` | **Required** โ†’ card is virtual |
| `type` | `string` | **Required** โ†’ user type |

`Number Format: "1111 1111 1111 1111"`

`Expiration Date Format: "MM/YY"`

`Password length: 4 and only numeric characters`

`Security Code length: 3 and only numeric characters`

`Valid types: [credit, debit, both]`

#### Response:

```json
{
"message": "card created"
}
```

#

### Get all cards by userId

```http
GET /cards/${userId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"cards": [
{
"id": 2,
"title": "vel qui expedita",
"number": "1089 8176 0498 7127",
"cardholderName": "CARLA H SILVA",
"securityCode": "206",
"expirationDate": "07/27",
"password": "4964",
"isVirtual": false,
"type": "both",
"createdAt": "2022-07-18T13:03:16.959Z",
"userId": 1
}
]
}
```

#

### Get a specific card by userId and cardId

```http
GET /cards/${userId}/${cardId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `cardId` | `integer` | **Required** โ†’ card Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"card": {
"id": 1,
"title": "sed doloribus qui",
"number": "3650 3177 0788 8589",
"cardholderName": "CARLA H SILVA",
"securityCode": "682",
"expirationDate": "07/27",
"password": "1265",
"isVirtual": false,
"type": "both",
"createdAt": "2022-07-18T13:03:01.120Z",
"userId": 1
}
}
```

#

### Delete a specific card by cardId

```http
DELETE /cards/${userId}/${cardId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `cardId` | `integer` | **Required** โ†’ card Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"message": "card deleted"
}
```

#

### ๐Ÿ“ถ Networks

### Create a network

```http
POST /wifis/${userId}/create
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

| Body | Type | Description |
| :--------- | :------- | :--------------------------- |
| `title` | `string` | **Required** โ†’ wifi title |
| `name` | `string` | **Required** โ†’ wifi name |
| `password` | `string` | **Required** โ†’ wifi password |

#### Response:

```json
{
"message": "wifi created"
}
```

#

### Get all wifis by userId

```http
GET /wifis/${userId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"wifis": [
{
"id": 1,
"title": "sit",
"name": "possimus",
"password": "xSxR7jefH4rZ3aB",
"createdAt": "2022-07-18T13:03:46.190Z",
"userId": 1
}
]
}
```

#

### Get a specific note by userId and wifiId

```http
GET /wifis/${userId}/${wifiId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `wifiId` | `integer` | **Required** โ†’ wifi Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"wifi": {
"id": 1,
"title": "sit",
"name": "possimus",
"password": "xSxR7jefH4rZ3aB",
"createdAt": "2022-07-18T13:03:46.190Z",
"userId": 1
}
}
```

#

### Delete a specific note by wifiId

```http
DELETE /wifis/${userId}/${wifiId}
```

#### Request:

| Params | Type | Description |
| :------- | :-------- | :--------------------- |
| `userId` | `integer` | **Required** โ†’ user Id |
| `wifiId` | `integer` | **Required** โ†’ wifi Id |

####

| Headers | Type | Description |
| :--------------- | :------- | :------------------- |
| `Authentication` | `string` | **Required** โ†’ token |

`Authorization format: Bearer jsonwebtoken`

####

#### Response:

```json
{
"message": "Wifi deleted"
}
```

## ๐Ÿ”‘ Environment Variables

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`

`JWT_SECRET = any string`

`CRYPTR_SECRET = any string`

## โš™๏ธ How to run

```bash
# Clone this repoository
$ git clone https://github.com/thalesgomest/drivenpass-API.git

# Change to project directory
$ cd cd drivenpass-API

# Install all dependencies
$ npm install

# Start the server
$ npm run start
```

## ๐Ÿ“š Lessons Learned

In this project I learned a lot about how to structure an API with TypeScript and database with Prisma

## ๐Ÿ› ๏ธ Build with

![uses-postgresql](https://img.shields.io/badge/PostgreSQL-316192?style=plastic&logo=postgresql&logoColor=white)
![uses-prisma](https://img.shields.io/badge/Prisma-3982CE?style=plastic&logo=Prisma&logoColor=white)
![uses-typescript](https://img.shields.io/badge/TypeScript-007ACC?style=plastic&logo=typescript&logoColor=white)
![uses-node](https://img.shields.io/badge/Node.js-43853D?style=plastic&logo=node.js&logoColor=white)
![uses-express](https://img.shields.io/badge/Express.js-404D59?style=plastic&logo=express.js&logoColor=white)
![built-with-heroku](https://img.shields.io/badge/Heroku-430098?style=plastic&logo=heroku&logoColor=white)
![built-with-vsc](https://img.shields.io/badge/Visual%20Studio%20Code-blue?style=plastic&logo=visualstudiocode)

## ๐Ÿ“ซ Contact