-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[updates] - added an example repo for strapi-custom-endpoint
- Loading branch information
Showing
58 changed files
with
15,836 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[{package.json,*.yml}] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
HOST=0.0.0.0 | ||
PORT=1337 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.cache | ||
build | ||
**/node_modules/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"extends": "eslint:recommended", | ||
"env": { | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true, | ||
"browser": false | ||
}, | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"experimentalObjectRestSpread": true, | ||
"jsx": false | ||
}, | ||
"sourceType": "module" | ||
}, | ||
"globals": { | ||
"strapi": true | ||
}, | ||
"rules": { | ||
"indent": ["error", 2, { "SwitchCase": 1 }], | ||
"linebreak-style": ["error", "unix"], | ||
"no-console": 0, | ||
"quotes": ["error", "single"], | ||
"semi": ["error", "always"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
############################ | ||
# OS X | ||
############################ | ||
|
||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
Icon | ||
.Spotlight-V100 | ||
.Trashes | ||
._* | ||
|
||
|
||
############################ | ||
# Linux | ||
############################ | ||
|
||
*~ | ||
|
||
|
||
############################ | ||
# Windows | ||
############################ | ||
|
||
Thumbs.db | ||
ehthumbs.db | ||
Desktop.ini | ||
$RECYCLE.BIN/ | ||
*.cab | ||
*.msi | ||
*.msm | ||
*.msp | ||
|
||
|
||
############################ | ||
# Packages | ||
############################ | ||
|
||
*.7z | ||
*.csv | ||
*.dat | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.o | ||
*.seed | ||
*.so | ||
*.swo | ||
*.swp | ||
*.swn | ||
*.swm | ||
*.out | ||
*.pid | ||
|
||
|
||
############################ | ||
# Logs and databases | ||
############################ | ||
|
||
.tmp | ||
*.log | ||
*.sql | ||
*.sqlite | ||
*.sqlite3 | ||
|
||
|
||
############################ | ||
# Misc. | ||
############################ | ||
|
||
*# | ||
ssl | ||
.idea | ||
nbproject | ||
public/uploads/* | ||
!public/uploads/.gitkeep | ||
|
||
############################ | ||
# Node.js | ||
############################ | ||
|
||
lib-cov | ||
lcov.info | ||
pids | ||
logs | ||
results | ||
node_modules | ||
.node_history | ||
|
||
############################ | ||
# Tests | ||
############################ | ||
|
||
testApp | ||
coverage | ||
|
||
############################ | ||
# Strapi | ||
############################ | ||
|
||
.env | ||
license.txt | ||
exports | ||
*.cache | ||
build | ||
.strapi-updater.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Strapi application | ||
|
||
A quick description of your strapi application |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"routes": [ | ||
{ | ||
"method": "GET", | ||
"path": "/articles", | ||
"handler": "article.find", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "/customarticles", | ||
"handler": "article.customFind", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "/articles/count", | ||
"handler": "article.count", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "/articles/:slug", | ||
"handler": "article.findOne", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "POST", | ||
"path": "/articles", | ||
"handler": "article.create", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "PUT", | ||
"path": "/articles/:id", | ||
"handler": "article.update", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "DELETE", | ||
"path": "/articles/:id", | ||
"handler": "article.delete", | ||
"config": { | ||
"policies": [] | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { sanitizeEntity } = require('strapi-utils'); | ||
|
||
module.exports = { | ||
/** | ||
* Retrieve a record. | ||
* | ||
* @return {Object} | ||
*/ | ||
|
||
|
||
async customFind() { | ||
const entity = await strapi.query('article').model.fetchAll( { | ||
columns: ['id','title', 'description'] | ||
}); | ||
return sanitizeEntity(entity, { model: strapi.models.article }); | ||
}, | ||
|
||
async findOne(ctx) { | ||
const { slug } = ctx.params; | ||
|
||
const entity = await strapi.services.article.findOne({ slug }); | ||
return sanitizeEntity(entity, { model: strapi.models.article }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/models.html#lifecycle-hooks) | ||
* to customize this model | ||
*/ | ||
|
||
module.exports = {}; |
53 changes: 53 additions & 0 deletions
53
strapi-custom-endpoint/api/article/models/article.settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"kind": "collectionType", | ||
"collectionName": "articles", | ||
"info": { | ||
"name": "article", | ||
"description": "" | ||
}, | ||
"options": { | ||
"increments": true, | ||
"timestamps": true, | ||
"draftAndPublish": true | ||
}, | ||
"pluginOptions": {}, | ||
"attributes": { | ||
"title": { | ||
"type": "string", | ||
"required": true | ||
}, | ||
"description": { | ||
"type": "text", | ||
"required": true | ||
}, | ||
"content": { | ||
"type": "richtext", | ||
"required": true | ||
}, | ||
"slug": { | ||
"type": "uid", | ||
"targetField": "title", | ||
"required": true | ||
}, | ||
"category": { | ||
"model": "category", | ||
"via": "articles" | ||
}, | ||
"image": { | ||
"model": "file", | ||
"via": "related", | ||
"allowedTypes": [ | ||
"files", | ||
"images", | ||
"videos" | ||
], | ||
"plugin": "upload", | ||
"required": true, | ||
"pluginOptions": {} | ||
}, | ||
"author": { | ||
"via": "articles", | ||
"model": "writer" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Read the documentation (https://strapi.io/documentation/v3.x/concepts/services.html#core-services) | ||
* to customize this service | ||
*/ | ||
|
||
module.exports = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"routes": [ | ||
{ | ||
"method": "GET", | ||
"path": "/categories", | ||
"handler": "category.find", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "/categories/count", | ||
"handler": "category.count", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "GET", | ||
"path": "/categories/:slug", | ||
"handler": "category.findOne", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "POST", | ||
"path": "/categories", | ||
"handler": "category.create", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "PUT", | ||
"path": "/categories/:id", | ||
"handler": "category.update", | ||
"config": { | ||
"policies": [] | ||
} | ||
}, | ||
{ | ||
"method": "DELETE", | ||
"path": "/categories/:id", | ||
"handler": "category.delete", | ||
"config": { | ||
"policies": [] | ||
} | ||
} | ||
] | ||
} |
Oops, something went wrong.