1.0.1 • Published 4 years ago
sion-apis v1.0.1
Sion Apis
Endpoints to work with apis in dashboard.
Dependencies
Setup
git clone git@bitbucket.org:profitfy/sion-apis.git
cd sion-apis
yarn install
Deploy
This script uses the same environment variables as libpq to connect to a PostgreSQL server and NODE_ENV=<STAGE>
to run config file.
To deploy, have your aws settings configured, environment variables, and use:
yarn run deploy [OPTIONS]
API
All requests below must have the jwt cookie that are received of requests above.
POST /api/v1/auth/signup
Create a new user.
Request body params
Name | Type | Required | Description |
---|---|---|---|
firstName | string | true | The user first name |
lastName | string | true | The user last name |
string | true | The user email | |
password | string | true | The user password |
confirmPassword | string | true | The user confirm password |
planName | string | true | The user plan. Possible values TRIAL, STARTER |
Request body example
POST /api/v1/auth/signup
{
"firstName": "Kevin",
"lastName": "Silva",
"email": "kevsilva07@gmail.com",
"password": "kevin8988",
"confirmPassword": "kevin8988",
"planName": "TRIAL"
}
Request example
curl --request POST \
--url 'http://localhost:3000/api/v1/auth/signup' \
--header 'content-type: application/json' \
--data '{"firstName":"Kevin","lastName":"Silva","email":"kevsilva07@gmail.com","password":"kevin8988","confirmPassword":"kevin8988","planName":"TRIAL"}' \
--include
Response example
HTTP/1.1 201 Created
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: application/json; charset=utf-8
Content-Length: 2
ETag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
Vary: Accept-Encoding
Date: Tue, 02 Jul 2019 09:13:37 GMT
Connection: keep-alive
{"status": "success","data": {"stores":[]}}
POST /api/v1/auth/login
Login.
Request body params
Name | Type | Description |
---|---|---|
string | The user email | |
password | string | The user password |
Request body example
POST /api/v1/auth/login
{
"email": "kevsilva07@gmail.com",
"password": "kevin8988"
}
Request example
curl --request POST \
--url 'http://localhost:3000/api/v1/auth/login' \
--header 'content-type: application/json' \
--data '{"email":"kevsilva07@gmail.com","password":"kevin8988"}' \
--include
Response example
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: application/json; charset=utf-8
Content-Length: 2097
ETag: W/"831-JIMUzB9LV54mD8GqTscE32TTzIo"
Vary: Accept-Encoding
Date: Tue, 02 Jul 2019 09:38:04 GMT
Connection: keep-alive
{"status": "success","data": {"stores":[]}}
GET /api/v1/users/stores
List user stores.
Response body params
An array of stores that contain:
Name | Type | Description |
---|---|---|
id | string | The store id |
name | string | The store name |
country | string | The store country |
domain | string | The store |
accessToken | string | The store access token |
dashboardUserId | string | The user id of that is store owner |
slug | string | The store slug |
Products | array | An array of products |
Profits | array | An array of profits |
createdAt | date | The date that was created |
updatedAt | date | The date that was updated |
Request example
curl --url 'http://localhost:3000/api/v1/users/stores' --include
Response example
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: application/json; charset=utf-8
Content-Length: 41
ETag: W/"29-zMxJefaVfxTPUE50GOPHJdaSjMI"
Vary: Accept-Encoding
Date: Tue, 02 Jul 2019 09:59:15 GMT
Connection: keep-alive
{"status":"success","data":{"stores":[{"id":"093c41fe-22fc-4511-91c5-828c0c36021f","name":"Super Hero Case","country":"BR","domain":"superheroscase.com","accessToken":"0354586f4911a616de9df1b5f7f81d7e","dashboardUserId":"f8392b2c-d363-4686-a906-bbac6bc0a161","createdAt":"2019-10-09T22:19:57.290Z", "updatedAt":"2019-10-09T22:19:57.290Z","Products":[],"Profits":[]}]}}
POST /api/v1/users/stores/shopify
Create user store getting data from shopify.
Request query params
Name | Type | Description |
---|---|---|
shop | string | The store name on shopify |
Request example
curl --request POST \
--url 'http://localhost:3000/api/v1/users/stores?shop=super-hero-case' --include
Response body params
An array of stores that contain:
Name | Type | Description |
---|---|---|
id | string | The store id |
name | string | The store name |
country | string | The store country |
domain | string | The store |
accessToken | string | The store access token |
dashboardUserId | string | The user id of that is store owner |
slug | string | The store slug |
Products | array | An array of products |
Profits | array | An array of profits |
createdAt | date | The date that was created |
updatedAt | date | The date that was updated |
Response example
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: application/json; charset=utf-8
Content-Length: 41
ETag: W/"29-zMxJefaVfxTPUE50GOPHJdaSjMI"
Vary: Accept-Encoding
Date: Tue, 02 Jul 2019 09:59:15 GMT
Connection: keep-alive
{"status":"success","data":{"stores":[{"id":"093c41fe-22fc-4511-91c5-828c0c36021f","name":"Super Hero Case","country":"BR","domain":"superheroscase.com","accessToken":"0354586f4911a616de9df1b5f7f81d7e","dashboardUserId":"f8392b2c-d363-4686-a906-bbac6bc0a161","createdAt":"2019-10-09T22:19:57.290Z", "updatedAt":"2019-10-09T22:19:57.290Z","Products":[],"Profits":[]}]}}
GET /api/v1/users/stores/:slug
List a store by slug.
Response body params
A store object that contains:
Name | Type | Description |
---|---|---|
id | string | The store id |
name | string | The store name |
country | string | The store country |
domain | string | The store |
accessToken | string | The store access token |
dashboardUserId | string | The user id of that is store owner |
slug | string | The store slug |
Products | array | An array of products |
Profits | array | An array of profits |
createdAt | date | The date that was created |
updatedAt | date | The date that was updated |
Request example
curl --url 'http://localhost:3000/api/v1/users/stores/profitfy-devs-321932032301293023' --include
Response example
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Content-Type: application/json; charset=utf-8
Content-Length: 41
ETag: W/"29-zMxJefaVfxTPUE50GOPHJdaSjMI"
Vary: Accept-Encoding
Date: Tue, 02 Jul 2019 09:59:15 GMT
Connection: keep-alive
{"status":"success","store":{"id":"247afadd-994c-4eb8-bef9-722defd3ff3d","name":"Profitfy-devs", "country":"BR","domain":"profitfy-devs.myshopify.com","accessToken":"3d15f6f83d4865723eb3b0b293c10139","image":null,"slug":"profitfy-devs-321932032301293023","dashboardUserId":"151336f8-010f-42fc-940b-508c3682b071","createdAt":"2019-10-21T15:28:55.263Z","updatedAt":"2019-10-21T15:28:55.263Z","Products":[], "Profits":[]}"```
## Development
Local tests, Full tests and test coverage
To test lambda offline
```bash
yarn run dev
and call the api
curl -X GET http://localhost:3000
Please, set environment variables to a test database.
yarn test
Unit tests and watch for changes
yarn run unit-test
License
© 2019 PROFITFY.ME ALL RIGHTS RESERVED
1.0.1
4 years ago