Skip to content

Commit 1e65c93

Browse files
committed
merge from project and product templates
1 parent 5166c9a commit 1e65c93

32 files changed

+3237
-151
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ workflows:
7676
- test
7777
filters:
7878
branches:
79-
only: [dev, 'feature/db-lock-issue']
79+
only: dev
8080
- deployProd:
8181
requires:
8282
- test

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Run image:
7171
`docker run -p 3000:3000 -i -t -e DB_HOST=172.17.0.1 tc_projects_services`
7272
You may replace 172.17.0.1 with your docker0 IP.
7373

74-
You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** to verify endpoints.
74+
You can paste **swagger.yaml** to [swagger editor](http://editor.swagger.io/) or import **postman.json** and **postman_environment.json** to verify endpoints.
7575

7676
#### Deploying without docker
7777
If you don't want to use docker to deploy to localhost. You can simply run `npm run start` from root of project. This should start the server on default port `3000`.

postman.json

Lines changed: 240 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"info": {
3+
"_postman_id": "469f0f40-b34a-40f9-b89d-bd7fde996676",
34
"name": "tc-project-service ",
4-
"_postman_id": "8f323d9c-63bd-5f2c-87f1-1e99083786f3",
5-
"description": "",
65
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
76
},
87
"item": [
98
{
109
"name": "Project Attachments",
10+
"description": null,
1111
"item": [
1212
{
1313
"name": "Upload attachment",
@@ -82,6 +82,7 @@
8282
},
8383
{
8484
"name": "Project Members",
85+
"description": null,
8586
"item": [
8687
{
8788
"name": "Create project member with no payload",
@@ -900,6 +901,7 @@
900901
},
901902
{
902903
"name": "bookmarks",
904+
"description": null,
903905
"item": [
904906
{
905907
"name": " Create project without bookmarks",
@@ -1077,6 +1079,7 @@
10771079
},
10781080
{
10791081
"name": "issue1",
1082+
"description": null,
10801083
"item": [
10811084
{
10821085
"name": "get projects with copilot token",
@@ -1100,6 +1103,7 @@
11001103
},
11011104
{
11021105
"name": "issue10",
1106+
"description": null,
11031107
"item": [
11041108
{
11051109
"name": "wrong role",
@@ -1149,6 +1153,7 @@
11491153
},
11501154
{
11511155
"name": "issue5",
1156+
"description": null,
11521157
"item": [
11531158
{
11541159
"name": "launch a project by topcoder managers ",
@@ -1220,6 +1225,7 @@
12201225
},
12211226
{
12221227
"name": "issue8",
1228+
"description": null,
12231229
"item": [
12241230
{
12251231
"name": "mock direct projects",
@@ -1376,6 +1382,238 @@
13761382
"response": []
13771383
}
13781384
]
1385+
},
1386+
{
1387+
"name": "Project Templates",
1388+
"description": "",
1389+
"item": [
1390+
{
1391+
"name": "Create project template",
1392+
"request": {
1393+
"method": "POST",
1394+
"header": [
1395+
{
1396+
"key": "Content-Type",
1397+
"value": "application/json"
1398+
},
1399+
{
1400+
"key": "Authorization",
1401+
"value": "Bearer {{jwt-token}}"
1402+
}
1403+
],
1404+
"body": {
1405+
"mode": "raw",
1406+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\"\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\"\r\n }\r\n }\r\n}"
1407+
},
1408+
"url": "{{api-url}}/v4/projectTemplates"
1409+
},
1410+
"response": []
1411+
},
1412+
{
1413+
"name": "List project templates",
1414+
"request": {
1415+
"method": "GET",
1416+
"header": [
1417+
{
1418+
"key": "Content-Type",
1419+
"value": "application/json"
1420+
},
1421+
{
1422+
"key": "Authorization",
1423+
"value": "Bearer {{jwt-token}}"
1424+
}
1425+
],
1426+
"body": {
1427+
"mode": "raw",
1428+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\"\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\"\r\n }\r\n }\r\n}"
1429+
},
1430+
"url": "{{api-url}}/v4/projectTemplates"
1431+
},
1432+
"response": []
1433+
},
1434+
{
1435+
"name": "Get project template",
1436+
"request": {
1437+
"method": "GET",
1438+
"header": [
1439+
{
1440+
"key": "Content-Type",
1441+
"value": "application/json"
1442+
},
1443+
{
1444+
"key": "Authorization",
1445+
"value": "Bearer {{jwt-token}}"
1446+
}
1447+
],
1448+
"body": {
1449+
"mode": "raw",
1450+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\"\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\"\r\n }\r\n }\r\n}"
1451+
},
1452+
"url": "{{api-url}}/v4/projectTemplates/1"
1453+
},
1454+
"response": []
1455+
},
1456+
{
1457+
"name": "Update project template",
1458+
"request": {
1459+
"method": "PATCH",
1460+
"header": [
1461+
{
1462+
"key": "Content-Type",
1463+
"value": "application/json"
1464+
},
1465+
{
1466+
"key": "Authorization",
1467+
"value": "Bearer {{jwt-token}}"
1468+
}
1469+
],
1470+
"body": {
1471+
"mode": "raw",
1472+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\",\r\n \"scope2\": [\"a\"]\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\",\r\n \"phase2\": {\r\n \t\"another\": \"another\"\r\n }\r\n }\r\n }\r\n}"
1473+
},
1474+
"url": "{{api-url}}/v4/projectTemplates/1"
1475+
},
1476+
"response": []
1477+
},
1478+
{
1479+
"name": "Delete project template",
1480+
"request": {
1481+
"method": "DELETE",
1482+
"header": [
1483+
{
1484+
"key": "Content-Type",
1485+
"value": "application/json"
1486+
},
1487+
{
1488+
"key": "Authorization",
1489+
"value": "Bearer {{jwt-token}}"
1490+
}
1491+
],
1492+
"body": {
1493+
"mode": "raw",
1494+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\",\r\n \"scope2\": [\"a\"]\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\",\r\n \"phase2\": {\r\n \t\"another\": \"another\"\r\n }\r\n }\r\n }\r\n}"
1495+
},
1496+
"url": "{{api-url}}/v4/projectTemplates/1"
1497+
},
1498+
"response": []
1499+
}
1500+
]
1501+
},
1502+
{
1503+
"name": "Product Templates",
1504+
"description": "",
1505+
"item": [
1506+
{
1507+
"name": "Create product template",
1508+
"request": {
1509+
"method": "POST",
1510+
"header": [
1511+
{
1512+
"key": "Content-Type",
1513+
"value": "application/json"
1514+
},
1515+
{
1516+
"key": "Authorization",
1517+
"value": "Bearer {{jwt-token}}"
1518+
}
1519+
],
1520+
"body": {
1521+
"mode": "raw",
1522+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"productKey\":\"new productKey\",\r\n \"icon\":\"http://example.com/icon-new.ico\",\r\n \"brief\": \"new brief\",\r\n \"details\": \"new details\",\r\n \"aliases\":{\r\n \"alias1\":\"alias 1\"\r\n },\r\n \"template\":{\r\n \"template1\":\"template 1\"\r\n }\r\n }\r\n}"
1523+
},
1524+
"url": "{{api-url}}/v4/productTemplates"
1525+
},
1526+
"response": []
1527+
},
1528+
{
1529+
"name": "List product templates",
1530+
"request": {
1531+
"method": "GET",
1532+
"header": [
1533+
{
1534+
"key": "Content-Type",
1535+
"value": "application/json"
1536+
},
1537+
{
1538+
"key": "Authorization",
1539+
"value": "Bearer {{jwt-token}}"
1540+
}
1541+
],
1542+
"body": {
1543+
"mode": "raw",
1544+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\"\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\"\r\n }\r\n }\r\n}"
1545+
},
1546+
"url": "{{api-url}}/v4/productTemplates"
1547+
},
1548+
"response": []
1549+
},
1550+
{
1551+
"name": "Get product template",
1552+
"request": {
1553+
"method": "GET",
1554+
"header": [
1555+
{
1556+
"key": "Content-Type",
1557+
"value": "application/json"
1558+
},
1559+
{
1560+
"key": "Authorization",
1561+
"value": "Bearer {{jwt-token}}"
1562+
}
1563+
],
1564+
"body": {
1565+
"mode": "raw",
1566+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\"\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\"\r\n }\r\n }\r\n}"
1567+
},
1568+
"url": "{{api-url}}/v4/productTemplates/1"
1569+
},
1570+
"response": []
1571+
},
1572+
{
1573+
"name": "Update product template",
1574+
"request": {
1575+
"method": "PATCH",
1576+
"header": [
1577+
{
1578+
"key": "Content-Type",
1579+
"value": "application/json"
1580+
},
1581+
{
1582+
"key": "Authorization",
1583+
"value": "Bearer {{jwt-token}}"
1584+
}
1585+
],
1586+
"body": {
1587+
"mode": "raw",
1588+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"productKey\":\"new productKey\",\r\n \"icon\":\"http://example.com/icon-new.ico\",\r\n \"brief\": \"new brief\",\r\n \"details\": \"new details\",\r\n \"aliases\":{\r\n \"alias1\":\"scope 1\",\r\n \"alias2\": [\"a\"]\r\n },\r\n \"template\":{\r\n \"template1\":\"template 1\",\r\n \"template2\": {\r\n \t\"another\": \"another\"\r\n }\r\n }\r\n }\r\n}"
1589+
},
1590+
"url": "{{api-url}}/v4/productTemplates/1"
1591+
},
1592+
"response": []
1593+
},
1594+
{
1595+
"name": "Delete product template",
1596+
"request": {
1597+
"method": "DELETE",
1598+
"header": [
1599+
{
1600+
"key": "Content-Type",
1601+
"value": "application/json"
1602+
},
1603+
{
1604+
"key": "Authorization",
1605+
"value": "Bearer {{jwt-token}}"
1606+
}
1607+
],
1608+
"body": {
1609+
"mode": "raw",
1610+
"raw": "{\r\n \"param\":{\r\n \"name\":\"new name\",\r\n \"key\":\"new key\",\r\n \"category\":\"new category\",\r\n \"scope\":{\r\n \"scope1\":\"scope 1\",\r\n \"scope2\": [\"a\"]\r\n },\r\n \"phases\":{\r\n \"phase1\":\"phase 1\",\r\n \"phase2\": {\r\n \t\"another\": \"another\"\r\n }\r\n }\r\n }\r\n}"
1611+
},
1612+
"url": "{{api-url}}/v4/productTemplates/1"
1613+
},
1614+
"response": []
1615+
}
1616+
]
13791617
}
13801618
]
13811619
}

postman_environment.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"id": "e6b30b4b-1388-4622-8314-bc49ba1d752b",
3+
"name": "tc-project-service",
4+
"values": [
5+
{
6+
"key": "api-url",
7+
"value": "http://localhost:3000",
8+
"description": "",
9+
"type": "text",
10+
"enabled": true
11+
},
12+
{
13+
"key": "jwt-token",
14+
"value": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJUb3Bjb2RlciBVc2VyIiwiYWRtaW5pc3RyYXRvciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoidGVzdDEiLCJleHAiOjI1NjMwNzY2ODksInVzZXJJZCI6IjQwMDUxMzMzIiwiaWF0IjoxNDYzMDc2MDg5LCJlbWFpbCI6InRlc3RAdG9wY29kZXIuY29tIiwianRpIjoiYjMzYjc3Y2QtYjUyZS00MGZlLTgzN2UtYmViOGUwYWU2YTRhIn0.wKWUe0-SaiFVN-VR_-GwgFlvWaDkSbc8H55ktb9LAVw",
15+
"description": "",
16+
"type": "text",
17+
"enabled": true
18+
}
19+
],
20+
"_postman_variable_scope": "environment",
21+
"_postman_exported_at": "2018-05-18T18:54:18.167Z",
22+
"_postman_exported_using": "Postman/6.0.10"
23+
}

src/models/productTemplate.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint-disable valid-jsdoc */
2+
3+
/**
4+
* The Product Template model
5+
*/
6+
module.exports = (sequelize, DataTypes) => {
7+
const ProductTemplate = sequelize.define('ProductTemplate', {
8+
id: { type: DataTypes.BIGINT, primaryKey: true, autoIncrement: true },
9+
name: { type: DataTypes.STRING(255), allowNull: false },
10+
productKey: { type: DataTypes.STRING(45), allowNull: false },
11+
icon: { type: DataTypes.STRING(255), allowNull: false },
12+
brief: { type: DataTypes.STRING(45), allowNull: false },
13+
details: { type: DataTypes.STRING(255), allowNull: false },
14+
aliases: { type: DataTypes.JSON, allowNull: false },
15+
template: { type: DataTypes.JSON, allowNull: false },
16+
deletedAt: DataTypes.DATE,
17+
createdAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
18+
updatedAt: { type: DataTypes.DATE, defaultValue: DataTypes.NOW },
19+
deletedBy: DataTypes.BIGINT,
20+
createdBy: { type: DataTypes.BIGINT, allowNull: false },
21+
updatedBy: { type: DataTypes.BIGINT, allowNull: false },
22+
}, {
23+
tableName: 'product_templates',
24+
paranoid: true,
25+
timestamps: true,
26+
updatedAt: 'updatedAt',
27+
createdAt: 'createdAt',
28+
deletedAt: 'deletedAt',
29+
});
30+
31+
return ProductTemplate;
32+
};

0 commit comments

Comments
 (0)