Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions models/software.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const softwareSchema = new mongoose.Schema(
trim: true,
default: '0.0.0',
},
shortDescription: {
type: String,
trim: true,
maxlength: 100,
required: [true, 'Software short description is required'],
},
description: {
type: String,
trim: true,
Expand All @@ -52,6 +58,12 @@ const softwareSchema = new mongoose.Schema(
type: Boolean,
required: true,
},
pricing: {
type: String,
trim: true,
lowercase: true,
required: [true, 'Software pricing is required'],
},
buildOn: {
type: [
{
Expand Down Expand Up @@ -82,6 +94,27 @@ const softwareSchema = new mongoose.Schema(
],
default: [],
},
videoLink: {
type: String,
validate: [
(value) => {
if (value) {
return isURL(value, {
protocols: ['http', 'https'],
host_whitelist: ['youtube.com', 'vimeo.com'],
});
}
return true;
},
'A valid video url is required (Only youtube.com or vimeo.com are supported)',
],
default: '',
},
twitterUsername: {
type: String,
trim: true,
lowercase: true,
},
query: {
isEnabled: {
type: Boolean,
Expand Down
10 changes: 6 additions & 4 deletions requests/api/softwares/post_software.rest
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
POST http://localhost:3001/api/software/
Content-Type: application/json
Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6InNhbXBsZSIsImlkIjoiNWY4ZGEzODcwODlmZmY0ZGIwNmJjMGFmIiwiaWF0IjoxNjAzODkzMzExfQ.ARy4EKDMzJqd4DcZyWXP5hygSQ9A2Bw1YfMQ-Nb03JU
Authorization: bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImM1MzYyNGFmMTYwMGRhNzlmMzFmMDMxNGYyMDVkNGYzN2FkNmUyNDYiLCJ0eXAiOiJKV1QifQ.eyJuYW1lIjoiQWxpY2UiLCJiYWNrZW5kSWQiOiI2MGZlNDdkZjAzZDA3NDZjODA3YThhZDQiLCJ1c2VybmFtZSI6ImFsaWNlIiwiaXNzIjoiaHR0cHM6Ly9zZWN1cmV0b2tlbi5nb29nbGUuY29tL2F1dGgtaW1wbC1kZXYiLCJhdWQiOiJhdXRoLWltcGwtZGV2IiwiYXV0aF90aW1lIjoxNjI3NzExMDczLCJ1c2VyX2lkIjoiWnBJWWFMak9Oak1PV3R1bTM2WGFPSDVURVc4MiIsInN1YiI6IlpwSVlhTGpPTmpNT1d0dW0zNlhhT0g1VEVXODIiLCJpYXQiOjE2Mjc3MTEwNzMsImV4cCI6MTYyNzcxNDY3MywiZW1haWwiOiJsZWNhbWl2OTIwQGFjdGl2ZXNuaXBlci5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiZmlyZWJhc2UiOnsiaWRlbnRpdGllcyI6eyJlbWFpbCI6WyJsZWNhbWl2OTIwQGFjdGl2ZXNuaXBlci5jb20iXX0sInNpZ25faW5fcHJvdmlkZXIiOiJwYXNzd29yZCJ9fQ.Y8bdJfSJalhf1HDNQ1jEjpD4vyg-yV6vh1tSezd3F0jCEdr61AXC-exy6TFsj9jizqk8N9jeUXAniUndxBF80n9hCl_SAY4PFnORsgfkFeOH-KS91Z0Dhjr16KyCjENutMjpOVmutZKboIVZhOcjkE1RKLgeki4mdP6V7uY1wwKIrg39DMx-2pu_6TiAUf1grFOtxkIbu3BG48keqNzokCKPj45VZmS2cWjrvQgp1ND1CsJxgl-CaRtcQt_ziVUaZ4wJuNX5iAx8tdeYN3UvA-cNvL9d4mwy68mOK-oFbZRuC119A7zYb5HD2vo5j-7-prot6k3tmQKvtP6suMLEUw

{
"name": "SampleSoftware8",
"description": "A sample software",
"name": "MyApp3",
"shortDescription": "MyApp3 Short descrption",
"description": "A sample software long description",
"homePage": "http://example.com",
"platform": "Windows",
"isActiveDevelopment": true
"isActiveDevelopment": true,
"pricing": "free"
}
4 changes: 4 additions & 0 deletions tests/utils/api/softwareTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ const Software = require('../../../models/software');

const sampleSoftwareInDb1 = {
name: 'SampleSoftware',
shortDescription: 'A sample short description 1',
description: 'A sample software 1',
homePage: 'http://example.com',
platform: 'Windows',
pricing: 'free',
isActiveDevelopment: true,
};

const sampleSoftwareInDb2 = {
name: 'SampleSoftware2',
shortDescription: 'A sample short description 2',
description: 'A sample software 1',
homePage: 'http://apple.com',
platform: 'MacOS',
pricing: 'paid',
isActiveDevelopment: false,
};

Expand Down